Skip to content

Commit 6b49b40

Browse files
authored
Merge pull request #9 from modelai/fzp/update_convertlabel_code
use imagesize to get img w and h instead of read img
2 parents 3c8da7b + 680147b commit 6b49b40

3 files changed

Lines changed: 4 additions & 7 deletions

File tree

det-yolov4-tmi/convert_label_ark2txt.py

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import os
2+
import imagesize
23

3-
import cv2
44

55

66
def _annotation_path_for_image(image_path: str, annotations_dir: str) -> str:
@@ -30,10 +30,7 @@ def _convert_annotations(index_file_path: str, dst_annotations_dir: str) -> None
3030
# each_txtfile: annotation path
3131
each_imgpath, each_txtfile = each_img_anno_path.split()
3232

33-
img = cv2.imread(each_imgpath)
34-
if img is None:
35-
raise ValueError(f"can not read image: {each_imgpath}")
36-
img_h, img_w, _ = img.shape
33+
img_w, img_h = imagesize.get(each_imgpath)
3734

3835
with open(each_txtfile, 'r') as f:
3936
txt_content = f.readlines()

det-yolov4-tmi/cuda101.dockerfile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ RUN wget https://github.com/AlexeyAB/darknet/releases/download/darknet_yolo_v3_o
1515
RUN rm /usr/bin/python3
1616
RUN ln -s /usr/bin/python3.7 /usr/bin/python3
1717
RUN python3 get-pip.py
18-
RUN pip3 install -i ${PIP_SOURCE} mxnet-cu101==1.5.1 numpy opencv-python pyyaml watchdog tensorboardX six scipy tqdm
18+
RUN pip3 install -i ${PIP_SOURCE} mxnet-cu101==1.5.1 numpy opencv-python pyyaml watchdog tensorboardX six scipy tqdm imagesize
1919

2020
ENV DEBIAN_FRONTEND noninteractive
2121
RUN apt-get update && apt-get install -y libopencv-dev

det-yolov4-tmi/cuda112.dockerfile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ RUN wget https://github.com/AlexeyAB/darknet/releases/download/darknet_yolo_v3_o
1515
RUN rm /usr/bin/python3
1616
RUN ln -s /usr/bin/python3.7 /usr/bin/python3
1717
RUN python3 get-pip.py
18-
RUN pip3 install -i ${PIP_SOURCE} mxnet-cu112==1.9.1 numpy opencv-python pyyaml watchdog tensorboardX six scipy tqdm
18+
RUN pip3 install -i ${PIP_SOURCE} mxnet-cu112==1.9.1 numpy opencv-python pyyaml watchdog tensorboardX six scipy tqdm imagesize
1919

2020
ENV DEBIAN_FRONTEND noninteractive
2121
RUN apt-get update && apt-get install -y libopencv-dev

0 commit comments

Comments
 (0)