Skip to content

Commit

Permalink
Incorporate PR feedbacks
Browse files Browse the repository at this point in the history
  • Loading branch information
raghavanone committed Nov 27, 2023
1 parent fc8aab6 commit 7e15fbd
Showing 1 changed file with 13 additions and 3 deletions.
16 changes: 13 additions & 3 deletions src/transformers/models/textnet/image_processing_textnet.py
Original file line number Diff line number Diff line change
Expand Up @@ -177,7 +177,6 @@ def resize(
**kwargs,
)

# Copied from transformers.models.clip.image_processing_clip.CLIPImageProcessor.preprocess
def preprocess(
self,
images: ImageInput,
Expand All @@ -195,6 +194,7 @@ def preprocess(
return_tensors: Optional[Union[str, TensorType]] = None,
data_format: Optional[ChannelDimension] = ChannelDimension.FIRST,
input_data_format: Optional[Union[str, ChannelDimension]] = None,
default_to_square: bool = False,
**kwargs,
) -> PIL.Image.Image:
"""
Expand Down Expand Up @@ -247,10 +247,14 @@ def preprocess(
- `"channels_first"` or `ChannelDimension.FIRST`: image in (num_channels, height, width) format.
- `"channels_last"` or `ChannelDimension.LAST`: image in (height, width, num_channels) format.
- `"none"` or `ChannelDimension.NONE`: image in (height, width) format.
default_to_square (`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`.
"""
do_resize = do_resize if do_resize is not None else self.do_resize
size = size if size is not None else self.size
size = get_size_dict(size, param_name="size", default_to_square=self.use_square_size)
size = get_size_dict(size, param_name="size", default_to_square=default_to_square)
resample = resample if resample is not None else self.resample
do_center_crop = do_center_crop if do_center_crop is not None else self.do_center_crop
crop_size = crop_size if crop_size is not None else self.crop_size
Expand Down Expand Up @@ -301,7 +305,13 @@ def preprocess(

if do_resize:
images = [
self.resize(image=image, size=size, resample=resample, input_data_format=input_data_format)
self.resize(
image=image,
size=size,
resample=resample,
input_data_format=input_data_format,
default_to_square=default_to_square,
)
for image in images
]

Expand Down

0 comments on commit 7e15fbd

Please sign in to comment.