MCPcopy Create free account
hub / github.com/ml-explore/mlx-examples / resize

Function resize

clip/image_processor.py:61–73  ·  view source on GitHub ↗

Resize so small size to short_size

(image: Image, short_size: int)

Source from the content-addressed store, hash-verified

59
60
61def resize(image: Image, short_size: int) -> Image:
62 """
63 Resize so small size to short_size
64 """
65 width, height = image.size
66 short = min(width, height)
67 long = max(width, height)
68 if short == short_size:
69 return image
70 new_short = short_size
71 new_long = int(short_size * long / short)
72 new_size = (new_short, new_long) if width <= height else (new_long, new_short)
73 return image.resize(new_size)
74
75
76def center_crop(image: Image, size: Tuple[int, int]) -> Image:

Callers 1

_preprocessMethod · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected