glenn-jocher commited on
Commit
916bdb1
·
unverified ·
1 Parent(s): b510957

Faster crop saving (#8696)

Browse files

Faster crops

Following https://github.com/ultralytics/yolov5/issues/8641#issuecomment-1193190325

Files changed (1) hide show
  1. 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(cv2.cvtColor(crop, cv2.COLOR_BGR2RGB)).save(f, quality=95, subsampling=0)
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