Unverified Commit 4d7a5b5b authored by amyeroberts's avatar amyeroberts Committed by GitHub
Browse files

🚨🚨🚨 Fix ordering of height, width for BLIP image processor (#22466)

Fix ordering of height,width for BLIP
parent 228792a9
...@@ -113,24 +113,28 @@ class BlipImageProcessor(BaseImageProcessor): ...@@ -113,24 +113,28 @@ class BlipImageProcessor(BaseImageProcessor):
**kwargs, **kwargs,
) -> np.ndarray: ) -> np.ndarray:
""" """
Resize an image. Resize an image to `(size["height"], size["width"])`.
Resizes the shorter side of the image to `size["shortest_edge"]` while preserving the aspect ratio. If the
longer side is larger than the max size `(int(`size["shortest_edge"]` * 1333 / 800))`, the longer side is then
resized to the max size while preserving the aspect ratio.
Args: Args:
image (`np.ndarray`): image (`np.ndarray`):
Image to resize. Image to resize.
size (`Dict[str, int]`): size (`Dict[str, int]`):
Controls the size of the output image. Should be of the form `{"shortest_edge": int}`. Dictionary in the format `{"height": int, "width": int}` specifying the size of the output image.
resample (`PILImageResampling` filter, *optional*, defaults to `PILImageResampling.BICUBIC`): resample (`PILImageResampling`, *optional*, defaults to `PILImageResampling.BICUBIC`):
Resampling filter to use when resiizing the image. `PILImageResampling` filter to use when resizing the image e.g. `PILImageResampling.BICUBIC`.
data_format (`str` or `ChannelDimension`, *optional*): data_format (`ChannelDimension` or `str`, *optional*):
The channel dimension format of the image. If not provided, it will be the same as the input image. The channel dimension format for the output image. If unset, the channel dimension format of the input
image is used. Can be one of:
- `"channels_first"` or `ChannelDimension.FIRST`: image in (num_channels, height, width) format.
- `"channels_last"` or `ChannelDimension.LAST`: image in (height, width, num_channels) format.
Returns:
`np.ndarray`: The resized image.
""" """
size = get_size_dict(size, default_to_square=True) size = get_size_dict(size, default_to_square=True)
output_size = (size["width"], size["height"]) if "height" not in size or "width" not in size:
raise ValueError(f"The `size` dictionary must contain the keys `height` and `width`. Got {size.keys()}")
output_size = (size["height"], size["width"])
return resize(image, size=output_size, resample=resample, data_format=data_format, **kwargs) return resize(image, size=output_size, resample=resample, data_format=data_format, **kwargs)
def rescale( def rescale(
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment