HUBDatasetStats() preview images to 50 quality (#8880)

@kalenmike should represent a 30% filesize reduction vs 75 quality
This commit is contained in:
Glenn Jocher 2022-08-05 14:45:41 +02:00 committed by GitHub
parent 731a2f8c1f
commit bc9fcb1767
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -1034,7 +1034,7 @@ class HUBDatasetStats():
r = max_dim / max(im.height, im.width) # ratio
if r < 1.0: # image too large
im = im.resize((int(im.width * r), int(im.height * r)))
im.save(f_new, 'JPEG', quality=75, optimize=True) # save
im.save(f_new, 'JPEG', quality=50, optimize=True) # save
except Exception as e: # use OpenCV
print(f'WARNING: HUB ops PIL failure {f}: {e}')
im = cv2.imread(f)