Skip to content

Commit

Permalink
Replaced opencv with imagesize to get the actual image size (#548)
Browse files Browse the repository at this point in the history
* replaced opencv with imagesize fixes #530

* fixed code style using per-commit

* fixed one_stage_detector as well for linter
  • Loading branch information
cansik committed Jan 8, 2024
1 parent 226d8cc commit be9b4a9
Show file tree
Hide file tree
Showing 3 changed files with 4 additions and 4 deletions.
5 changes: 2 additions & 3 deletions nanodet/data/dataset/yolo.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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 = {
Expand Down
2 changes: 1 addition & 1 deletion nanodet/model/arch/one_stage_detector.py
Original file line number Diff line number Diff line change
Expand Up @@ -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()

Expand Down
1 change: 1 addition & 0 deletions requirements.txt
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
Cython
imagesize
matplotlib
numpy
omegaconf>=2.0.1
Expand Down

0 comments on commit be9b4a9

Please sign in to comment.