diff --git a/sahi/models/huggingface.py b/sahi/models/huggingface.py index ad21e19b7..0145d9b6a 100644 --- a/sahi/models/huggingface.py +++ b/sahi/models/huggingface.py @@ -30,7 +30,6 @@ def __init__( load_at_init: bool = True, image_size: int = None, ): - self._processor = processor self._image_shapes = [] super().__init__( @@ -66,7 +65,6 @@ def num_categories(self) -> int: return self.model.config.num_labels def load_model(self): - from transformers import AutoModelForObjectDetection, AutoProcessor model = AutoModelForObjectDetection.from_pretrained(self.model_path) diff --git a/sahi/models/torchvision.py b/sahi/models/torchvision.py index 3685300e5..a792d5889 100644 --- a/sahi/models/torchvision.py +++ b/sahi/models/torchvision.py @@ -174,7 +174,6 @@ def _create_object_prediction_list_from_original_predictions( full_shape = None if full_shape_list is None else full_shape_list[0] for ind in range(len(boxes)): - if masks is not None: mask = np.array(masks[ind]) else: diff --git a/sahi/scripts/coco_error_analysis.py b/sahi/scripts/coco_error_analysis.py index ecaad70f6..07ed7f0ee 100644 --- a/sahi/scripts/coco_error_analysis.py +++ b/sahi/scripts/coco_error_analysis.py @@ -360,7 +360,6 @@ def _analyse_results( classname_to_export_path_list = {} for k, catId in enumerate(present_cat_ids): - nm = cocoGt.loadCats(catId)[0] print(f'--------------saving {k + 1}-{nm["name"]}---------------') analyze_result = analyze_results[k] diff --git a/sahi/utils/cv.py b/sahi/utils/cv.py index 0204df498..9363f2577 100644 --- a/sahi/utils/cv.py +++ b/sahi/utils/cv.py @@ -250,7 +250,6 @@ def read_video_frame(video_capture, frame_skip_interval): cv2.imshow("Prediction of {}".format(str(video_file_name)), cv2.WINDOW_AUTOSIZE) while video_capture.isOpened: - frame_num = video_capture.get(cv2.CAP_PROP_POS_FRAMES) video_capture.set(cv2.CAP_PROP_POS_FRAMES, frame_num + frame_skip_interval) diff --git a/sahi/utils/file.py b/sahi/utils/file.py index ec09a6075..bf2dd1621 100644 --- a/sahi/utils/file.py +++ b/sahi/utils/file.py @@ -228,7 +228,6 @@ def increment_path(path, exist_ok=True, sep=""): def download_from_url(from_url: str, to_path: str): - Path(to_path).parent.mkdir(parents=True, exist_ok=True) if not os.path.exists(to_path): diff --git a/sahi/utils/mmdet.py b/sahi/utils/mmdet.py index 229efc009..4d17697c4 100644 --- a/sahi/utils/mmdet.py +++ b/sahi/utils/mmdet.py @@ -31,7 +31,6 @@ class MmdetTestConstants: def download_mmdet_cascade_mask_rcnn_model(destination_path: Optional[str] = None): - if destination_path is None: destination_path = MmdetTestConstants.MMDET_CASCADEMASKRCNN_MODEL_PATH @@ -41,7 +40,6 @@ def download_mmdet_cascade_mask_rcnn_model(destination_path: Optional[str] = Non def download_mmdet_retinanet_model(destination_path: Optional[str] = None): - if destination_path is None: destination_path = MmdetTestConstants.MMDET_RETINANET_MODEL_PATH @@ -51,7 +49,6 @@ def download_mmdet_retinanet_model(destination_path: Optional[str] = None): def download_mmdet_yolox_tiny_model(destination_path: Optional[str] = None): - if destination_path is None: destination_path = MmdetTestConstants.MMDET_YOLOX_TINY_MODEL_PATH diff --git a/sahi/utils/yolonas.py b/sahi/utils/yolonas.py index 11119d1e8..f2aaeafca 100644 --- a/sahi/utils/yolonas.py +++ b/sahi/utils/yolonas.py @@ -16,7 +16,6 @@ class YoloNasTestConstants: def download_yolonas_s_model(destination_path: Optional[str] = None): - if destination_path is None: destination_path = YoloNasTestConstants.YOLONAS_S_MODEL_PATH @@ -30,7 +29,6 @@ def download_yolonas_s_model(destination_path: Optional[str] = None): def download_yolonas_m_model(destination_path: Optional[str] = None): - if destination_path is None: destination_path = YoloNasTestConstants.YOLONAS_M_MODEL_PATH @@ -44,7 +42,6 @@ def download_yolonas_m_model(destination_path: Optional[str] = None): def download_yolonas_l_model(destination_path: Optional[str] = None): - if destination_path is None: destination_path = YoloNasTestConstants.YOLONAS_L_MODEL_PATH diff --git a/sahi/utils/yolov5.py b/sahi/utils/yolov5.py index 9582f1138..de61eb595 100644 --- a/sahi/utils/yolov5.py +++ b/sahi/utils/yolov5.py @@ -16,7 +16,6 @@ class Yolov5TestConstants: def download_yolov5n_model(destination_path: Optional[str] = None): - if destination_path is None: destination_path = Yolov5TestConstants.YOLOV5N_MODEL_PATH @@ -30,7 +29,6 @@ def download_yolov5n_model(destination_path: Optional[str] = None): def download_yolov5s6_model(destination_path: Optional[str] = None): - if destination_path is None: destination_path = Yolov5TestConstants.YOLOV5S6_MODEL_PATH diff --git a/sahi/utils/yolov8.py b/sahi/utils/yolov8.py index 7d955cd35..b94dc5538 100644 --- a/sahi/utils/yolov8.py +++ b/sahi/utils/yolov8.py @@ -14,9 +14,11 @@ class Yolov8TestConstants: YOLOV8M_MODEL_URL = "https://github.com/ultralytics/assets/releases/download/v0.0.0/yolov8m.pt" YOLOV8M_MODEL_PATH = "tests/data/models/yolov8/yolov8m.pt" + YOLOV8M_MODEL_URL = "https://github.com/ultralytics/assets/releases/download/v0.0.0/yolov8l.pt" + YOLOV8M_MODEL_PATH = "tests/data/models/yolov8/yolov8l.pt" -def download_yolov8n_model(destination_path: Optional[str] = None): +def download_yolov8n_model(destination_path: Optional[str] = None): if destination_path is None: destination_path = Yolov8TestConstants.YOLOV8N_MODEL_PATH @@ -30,7 +32,6 @@ def download_yolov8n_model(destination_path: Optional[str] = None): def download_yolov8s_model(destination_path: Optional[str] = None): - if destination_path is None: destination_path = Yolov8TestConstants.YOLOV8S_MODEL_PATH @@ -41,3 +42,29 @@ def download_yolov8s_model(destination_path: Optional[str] = None): Yolov8TestConstants.YOLOV8S_MODEL_URL, destination_path, ) + + +def download_yolov8m_model(destination_path: Optional[str] = None): + if destination_path is None: + destination_path = Yolov8TestConstants.YOLOV8M_MODEL_PATH + + Path(destination_path).parent.mkdir(parents=True, exist_ok=True) + + if not path.exists(destination_path): + urllib.request.urlretrieve( + Yolov8TestConstants.YOLOV8M_MODEL_URL, + destination_path, + ) + + +def download_yolov8l_model(destination_path: Optional[str] = None): + if destination_path is None: + destination_path = Yolov8TestConstants.YOLOV8L_MODEL_PATH + + Path(destination_path).parent.mkdir(parents=True, exist_ok=True) + + if not path.exists(destination_path): + urllib.request.urlretrieve( + Yolov8TestConstants.YOLOV8L_MODEL_URL, + destination_path, + ) diff --git a/tests/test_cocoutils.py b/tests/test_cocoutils.py index bde0061ae..9de1ba5cb 100644 --- a/tests/test_cocoutils.py +++ b/tests/test_cocoutils.py @@ -453,7 +453,6 @@ def test_get_imageid2annotationlist_mapping(self): self.assertEqual(len(imageid2annotationlist_mapping), 2) def check_image_id(image_id): - image_ids = [annotationlist["image_id"] for annotationlist in imageid2annotationlist_mapping[image_id]] self.assertEqual(image_ids, [image_id] * len(image_ids)) diff --git a/tests/test_mmdetectionmodel.py b/tests/test_mmdetectionmodel.py index f78848cee..82db0b6ec 100644 --- a/tests/test_mmdetectionmodel.py +++ b/tests/test_mmdetectionmodel.py @@ -24,7 +24,6 @@ def download_mmdet_yolox_tiny_model(): - download_from_url(MMDET_YOLOX_TINY_MODEL_URL, MMDET_YOLOX_TINY_MODEL_PATH) download_from_url(MMDET_YOLOX_TINY_CONFIG_URL, MMDET_YOLOX_TINY_CONFIG_PATH)