Add default_to_square_for_size to CLIPImageProcessor#26965
Conversation
ArthurZucker
left a comment
There was a problem hiding this comment.
few very small nits
| image_mean: Optional[Union[float, List[float]]] = None, | ||
| image_std: Optional[Union[float, List[float]]] = None, | ||
| do_convert_rgb: bool = True, | ||
| default_to_square_for_size: bool = False, |
There was a problem hiding this comment.
| default_to_square_for_size: bool = False, | |
| use_square_size: bool = False, |
or something like this!
| default_to_square_for_size (`bool`, *optional*, defaults to `False`): | ||
| The value to be passed to `get_size_dict` as `default_to_square` when computing the image size. |
There was a problem hiding this comment.
let's say what it changes depending on this values!
There was a problem hiding this comment.
use_square_size (`bool`, *optional*, defaults to `False`):
The value to be passed to `get_size_dict` as `default_to_square` when computing the image size. If the
`size` argument in `get_size_dict` is an `int`, it determines whether to default to a square image or not.
Note that this attribute is not used in computing `crop_size` via calling `get_size_dict`.
| use_square_size (`bool`, *optional*, defaults to `False`): | ||
| The value to be passed to `get_size_dict` as `default_to_square` when computing the image size. If the | ||
| `size` argument in `get_size_dict` is an `int`, it determines whether to default to a square image or not. | ||
| Note that this attribute is not used in computing `crop_size` via calling `get_size_dict`. |
There was a problem hiding this comment.
Okay good enough for me, would be better to know what size are used if false for example
There was a problem hiding this comment.
I take this from the original get_size_dict.
def get_size_dict(
...
...
default_to_square (`bool`, *optional*, defaults to `True`):
If `size` is an int, whether to default to a square image or not.
other places like def get_resize_output_image_size
has sth like
How to convert `size` when it is a single int. If set to `True`, the `size` will be converted to a square
(`size`,`size`). If set to `False`, will replicate
[`torchvision.transforms.Resize`](https://pytorch.org/vision/stable/transforms.html#torchvision.transforms.Resize)
with support for resizing only the smallest edge and providing an optional `max_size`.
but this method has more logic than the canonical get_size_dict
|
The documentation is not available anymore as the PR was closed or merged. |
ArthurZucker
left a comment
There was a problem hiding this comment.
Thanks! I am pinging @amyeroberts so that she sees it when she comes back. Feel free to merge
|
Thanks a lot ! |
|
I forgot to change this line to will do it but wait on next Monday to merge |
…#26965) * fix * fix * fix * fix * fix --------- Co-authored-by: ydshieh <ydshieh@users.noreply.github.com>
…#26965) * fix * fix * fix * fix * fix --------- Co-authored-by: ydshieh <ydshieh@users.noreply.github.com>
What does this PR do?
Add
default_to_square_for_sizetoCLIPImageProcessor.As in the file, we also have
crop_size = get_size_dict(crop_size, default_to_square=True, param_name="crop_size"), so I give the namedefault_to_square_for_sizeforget_size_dict(size, default_to_square=default_to_square_for_size)to avoid confusion.Otherwise, I can give it
default_to_square, and we may adddefault_to_square_for_crop_sizelater (or in this PR).