From 6ee492a52848cb44d02610608c87ca94ff0fa5dd Mon Sep 17 00:00:00 2001 From: Glenn Jocher Date: Sat, 23 Jul 2022 23:30:30 +0200 Subject: [PATCH] Faster crop saving (#8696) Faster crops Following https://github.com/ultralytics/yolov5/issues/8641#issuecomment-1193190325 --- utils/plots.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/utils/plots.py b/utils/plots.py index 1bbb9c09c33a..53e326c23f6e 100644 --- a/utils/plots.py +++ b/utils/plots.py @@ -484,6 +484,6 @@ def save_one_box(xyxy, im, file=Path('im.jpg'), gain=1.02, pad=10, square=False, if save: file.parent.mkdir(parents=True, exist_ok=True) # make directory f = str(increment_path(file).with_suffix('.jpg')) - # cv2.imwrite(f, crop) # https://github.com/ultralytics/yolov5/issues/7007 chroma subsampling issue - Image.fromarray(cv2.cvtColor(crop, cv2.COLOR_BGR2RGB)).save(f, quality=95, subsampling=0) + # cv2.imwrite(f, crop) # save BGR, https://github.com/ultralytics/yolov5/issues/7007 chroma subsampling issue + Image.fromarray(crop[..., ::-1]).save(f, quality=95, subsampling=0) # save RGB return crop