Faster crop saving (#8696)
Browse filesFaster crops
Following https://github.com/ultralytics/yolov5/issues/8641#issuecomment-1193190325
- utils/plots.py +2 -2
utils/plots.py
CHANGED
@@ -484,6 +484,6 @@ def save_one_box(xyxy, im, file=Path('im.jpg'), gain=1.02, pad=10, square=False,
|
|
484 |
if save:
|
485 |
file.parent.mkdir(parents=True, exist_ok=True) # make directory
|
486 |
f = str(increment_path(file).with_suffix('.jpg'))
|
487 |
-
# cv2.imwrite(f, crop) # https://github.com/ultralytics/yolov5/issues/7007 chroma subsampling issue
|
488 |
-
Image.fromarray(
|
489 |
return crop
|
|
|
484 |
if save:
|
485 |
file.parent.mkdir(parents=True, exist_ok=True) # make directory
|
486 |
f = str(increment_path(file).with_suffix('.jpg'))
|
487 |
+
# cv2.imwrite(f, crop) # save BGR, https://github.com/ultralytics/yolov5/issues/7007 chroma subsampling issue
|
488 |
+
Image.fromarray(crop[..., ::-1]).save(f, quality=95, subsampling=0) # save RGB
|
489 |
return crop
|