|
|
|
@ -57,7 +57,6 @@ class BasePredictor: |
|
|
|
|
dataset (Dataset): Dataset used for prediction. |
|
|
|
|
vid_path (str): Path to video file. |
|
|
|
|
vid_writer (cv2.VideoWriter): Video writer for saving video output. |
|
|
|
|
show (bool): Whether to view image output. |
|
|
|
|
annotator (Annotator): Annotator used for prediction. |
|
|
|
|
data_path (str): Path to data. |
|
|
|
|
""" |
|
|
|
@ -88,7 +87,6 @@ class BasePredictor: |
|
|
|
|
self.device = None |
|
|
|
|
self.dataset = None |
|
|
|
|
self.vid_path, self.vid_writer = None, None |
|
|
|
|
self.show = None |
|
|
|
|
self.annotator = None |
|
|
|
|
self.data_path = None |
|
|
|
|
self.callbacks = defaultdict(list, {k: [v] for k, v in callbacks.default_callbacks.items()}) # add callbacks |
|
|
|
@ -108,7 +106,7 @@ class BasePredictor: |
|
|
|
|
|
|
|
|
|
def setup(self, source=None, model=None): |
|
|
|
|
# source |
|
|
|
|
source = str(source or self.args.source) |
|
|
|
|
source = str(source if source is not None else self.args.source) |
|
|
|
|
is_file = Path(source).suffix[1:] in (IMG_FORMATS + VID_FORMATS) |
|
|
|
|
is_url = source.lower().startswith(('rtsp://', 'rtmp://', 'http://', 'https://')) |
|
|
|
|
webcam = source.isnumeric() or source.endswith('.streams') or (is_url and not is_file) |
|
|
|
@ -126,8 +124,10 @@ class BasePredictor: |
|
|
|
|
|
|
|
|
|
# Dataloader |
|
|
|
|
bs = 1 # batch_size |
|
|
|
|
if self.args.show: |
|
|
|
|
self.args.show = check_imshow(warn=True) |
|
|
|
|
if webcam: |
|
|
|
|
self.show = check_imshow(warn=True) |
|
|
|
|
self.args.show = check_imshow(warn=True) |
|
|
|
|
self.dataset = LoadStreams(source, imgsz=imgsz, stride=stride, auto=pt, vid_stride=self.args.vid_stride) |
|
|
|
|
bs = len(self.dataset) |
|
|
|
|
elif screenshot: |
|
|
|
|