ultralytics 8.2.52 fix CenterCrop transforms for PIL Image inputs (#14308)

Signed-off-by: Glenn Jocher <glenn.jocher@ultralytics.com>
Co-authored-by: UltralyticsAssistant <web@ultralytics.com>
Co-authored-by: Lucas Buligon Antunes <lukasbuligonantunes@gmail.com>
This commit is contained in:
Glenn Jocher 2024-07-10 03:00:14 +02:00 committed by GitHub
parent 755dcd6ca0
commit 997f2c92cd
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
20 changed files with 38 additions and 30 deletions

View file

@ -1401,6 +1401,8 @@ class CenterCrop:
Returns:
(numpy.ndarray): The center-cropped and resized image as a numpy array.
"""
if isinstance(im, Image.Image): # convert from PIL to numpy array if required
im = np.asarray(im)
imh, imw = im.shape[:2]
m = min(imh, imw) # min dimension
top, left = (imh - m) // 2, (imw - m) // 2