From e6acae84e4ec0d7c3d227e29d2a48e07600e8afa Mon Sep 17 00:00:00 2001 From: Florian Bruggisser Date: Sat, 30 Dec 2023 20:42:06 +0100 Subject: [PATCH 1/3] replaced opencv with imagesize fixes #530 --- nanodet/data/dataset/yolo.py | 9 ++++----- requirements.txt | 1 + 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/nanodet/data/dataset/yolo.py b/nanodet/data/dataset/yolo.py index 6c5efff40..61dd7147f 100644 --- a/nanodet/data/dataset/yolo.py +++ b/nanodet/data/dataset/yolo.py @@ -18,8 +18,8 @@ from collections import defaultdict from typing import Optional, Sequence -import cv2 import numpy as np +from imagesize import imagesize from pycocotools.coco import COCO from .coco import CocoDataset @@ -53,8 +53,8 @@ def __init__(self, class_names, **kwargs): @staticmethod def _find_image( - image_prefix: str, - image_types: Sequence[str] = (".png", ".jpg", ".jpeg", ".bmp", ".tiff"), + image_prefix: str, + image_types: Sequence[str] = (".png", ".jpg", ".jpeg", ".bmp", ".tiff"), ) -> Optional[str]: for image_type in image_types: path = f"{image_prefix}{image_type}" @@ -92,8 +92,7 @@ def yolo_to_coco(self, ann_path): with open(ann_file, "r") as f: lines = f.readlines() - image = cv2.imread(image_file) - height, width = image.shape[:2] + width, height = imagesize.get(image_file) file_name = os.path.basename(image_file) info = { diff --git a/requirements.txt b/requirements.txt index 4f88e6515..d1a281b11 100644 --- a/requirements.txt +++ b/requirements.txt @@ -1,4 +1,5 @@ Cython +imagesize matplotlib numpy omegaconf>=2.0.1 From a02e25b75eb682ea58ffcf50f33a4afc8d6e2bd1 Mon Sep 17 00:00:00 2001 From: Florian Bruggisser Date: Sat, 30 Dec 2023 20:49:01 +0100 Subject: [PATCH 2/3] fixed code style using per-commit --- nanodet/data/dataset/yolo.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/nanodet/data/dataset/yolo.py b/nanodet/data/dataset/yolo.py index 61dd7147f..f6b75b986 100644 --- a/nanodet/data/dataset/yolo.py +++ b/nanodet/data/dataset/yolo.py @@ -53,8 +53,8 @@ def __init__(self, class_names, **kwargs): @staticmethod def _find_image( - image_prefix: str, - image_types: Sequence[str] = (".png", ".jpg", ".jpeg", ".bmp", ".tiff"), + image_prefix: str, + image_types: Sequence[str] = (".png", ".jpg", ".jpeg", ".bmp", ".tiff"), ) -> Optional[str]: for image_type in image_types: path = f"{image_prefix}{image_type}" From b87f72c1793bd8ab9829ba46bd0cfdd6b4062a23 Mon Sep 17 00:00:00 2001 From: Florian Bruggisser Date: Sat, 30 Dec 2023 20:50:51 +0100 Subject: [PATCH 3/3] fixed one_stage_detector as well for linter --- nanodet/model/arch/one_stage_detector.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/nanodet/model/arch/one_stage_detector.py b/nanodet/model/arch/one_stage_detector.py index 90aa3f6f3..8a0f61a81 100644 --- a/nanodet/model/arch/one_stage_detector.py +++ b/nanodet/model/arch/one_stage_detector.py @@ -60,7 +60,7 @@ def inference(self, meta): time2 = time.time() print("forward time: {:.3f}s".format((time2 - time1)), end=" | ") results = self.head.post_process(preds, meta) - + if is_cuda_available: torch.cuda.synchronize()