hhk7734 / tensorflow-yolov4

YOLOv4 Implemented in Tensorflow 2.
MIT License
136 stars 75 forks source link

Increase YOLODataset speed #85

Open ccasadei opened 3 years ago

ccasadei commented 3 years ago

Hi,

using TurboJpeg instead of cv2, I increased the dataset image reading speed from 80 images/sec to 126 images/sec on my pc.

Method: _convert_dataset_to_image_and_bboxes

try:
    # image = cv2.imread(dataset[0])
    # image = cv2.cvtColor(image, cv2.COLOR_BGR2RGB)
    with open(dataset[0], "rb") as f:
        image = self.jpgdecode.decode(f.read(), pixel_format=TJPF_RGB)
except:
    return None, None

where self.jpgdecode is assigned once in __init__ constructor:

...
    self.jpgdecode = turbojpeg.TurboJPEG()
...