|
|
|
@ -65,14 +65,13 @@ class BasePredictor:
|
|
|
|
|
Attributes:
|
|
|
|
|
args (SimpleNamespace): Configuration for the predictor.
|
|
|
|
|
save_dir (Path): Directory to save results.
|
|
|
|
|
done_setup (bool): Whether the predictor has finished setup.
|
|
|
|
|
done_warmup (bool): Whether the predictor has finished setup.
|
|
|
|
|
model (nn.Module): Model used for prediction.
|
|
|
|
|
data (dict): Data configuration.
|
|
|
|
|
device (torch.device): Device used for prediction.
|
|
|
|
|
dataset (Dataset): Dataset used for prediction.
|
|
|
|
|
vid_path (str): Path to video file.
|
|
|
|
|
vid_writer (cv2.VideoWriter): Video writer for saving video output.
|
|
|
|
|
annotator (Annotator): Annotator used for prediction.
|
|
|
|
|
data_path (str): Path to data.
|
|
|
|
|
"""
|
|
|
|
|
|
|
|
|
@ -85,9 +84,7 @@ class BasePredictor:
|
|
|
|
|
overrides (dict, optional): Configuration overrides. Defaults to None.
|
|
|
|
|
"""
|
|
|
|
|
self.args = get_cfg(cfg, overrides)
|
|
|
|
|
project = self.args.project or Path(SETTINGS['runs_dir']) / self.args.task
|
|
|
|
|
name = self.args.name or f'{self.args.mode}'
|
|
|
|
|
self.save_dir = increment_path(Path(project) / name, exist_ok=self.args.exist_ok)
|
|
|
|
|
self.save_dir = self.get_save_dir()
|
|
|
|
|
if self.args.conf is None:
|
|
|
|
|
self.args.conf = 0.25 # default conf=0.25
|
|
|
|
|
self.done_warmup = False
|
|
|
|
@ -108,6 +105,11 @@ class BasePredictor:
|
|
|
|
|
self.callbacks = _callbacks or callbacks.get_default_callbacks()
|
|
|
|
|
callbacks.add_integration_callbacks(self)
|
|
|
|
|
|
|
|
|
|
def get_save_dir(self):
|
|
|
|
|
project = self.args.project or Path(SETTINGS['runs_dir']) / self.args.task
|
|
|
|
|
name = self.args.name or f'{self.args.mode}'
|
|
|
|
|
return increment_path(Path(project) / name, exist_ok=self.args.exist_ok)
|
|
|
|
|
|
|
|
|
|
def preprocess(self, im):
|
|
|
|
|
"""Prepares input image before inference.
|
|
|
|
|
|
|
|
|
|