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:
parent
755dcd6ca0
commit
997f2c92cd
20 changed files with 38 additions and 30 deletions
|
|
@ -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
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue