From be9b4a9001d7f9b6fc89c2df31ae8d428e35b4f0 Mon Sep 17 00:00:00 2001 From: Florian Bruggisser Date: Mon, 8 Jan 2024 09:57:17 +0100 Subject: [PATCH] Replaced opencv with imagesize to get the actual image size (#548) * replaced opencv with imagesize fixes #530 * fixed code style using per-commit * fixed one_stage_detector as well for linter --- nanodet/data/dataset/yolo.py | 5 ++--- nanodet/model/arch/one_stage_detector.py | 2 +- requirements.txt | 1 + 3 files changed, 4 insertions(+), 4 deletions(-) diff --git a/nanodet/data/dataset/yolo.py b/nanodet/data/dataset/yolo.py index 6c5efff40..f6b75b986 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 @@ -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/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() 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