From df099743b3e46ebed5237e2e0b723c9176507849 Mon Sep 17 00:00:00 2001 From: HichTala <98521878+HichTala@users.noreply.github.com> Date: Thu, 28 Nov 2024 10:50:56 +0100 Subject: [PATCH 01/11] Remove unused `max_size` variable in processor which was always `None` and triggered unnecessary deprecated warning --- src/transformers/models/detr/image_processing_detr.py | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/src/transformers/models/detr/image_processing_detr.py b/src/transformers/models/detr/image_processing_detr.py index 85fbe698d10a12..a2075f281d851b 100644 --- a/src/transformers/models/detr/image_processing_detr.py +++ b/src/transformers/models/detr/image_processing_detr.py @@ -1337,7 +1337,6 @@ def preprocess( ) do_pad = kwargs.pop("pad_and_return_pixel_mask") - max_size = None if "max_size" in kwargs: logger.warning_once( "The `max_size` argument is deprecated and will be removed in a future version, use" @@ -1347,7 +1346,7 @@ def preprocess( do_resize = self.do_resize if do_resize is None else do_resize size = self.size if size is None else size - size = get_size_dict(size=size, max_size=max_size, default_to_square=False) + size = get_size_dict(size=size, default_to_square=False) resample = self.resample if resample is None else resample do_rescale = self.do_rescale if do_rescale is None else do_rescale rescale_factor = self.rescale_factor if rescale_factor is None else rescale_factor @@ -1443,7 +1442,7 @@ def preprocess( for image, target in zip(images, annotations): orig_size = get_image_size(image, input_data_format) resized_image = self.resize( - image, size=size, max_size=max_size, resample=resample, input_data_format=input_data_format + image, size=size, resample=resample, input_data_format=input_data_format ) resized_annotation = self.resize_annotation( target, orig_size, get_image_size(resized_image, input_data_format) From 12c74f6b678d1a1e976f4e89fd05370b0e4de74b Mon Sep 17 00:00:00 2001 From: HichTala <98521878+HichTala@users.noreply.github.com> Date: Thu, 28 Nov 2024 15:05:44 +0100 Subject: [PATCH 02/11] Remove unused `max_size` variable in processor which was always `None` and triggered unnecessary deprecated warning --- .../conditional_detr/image_processing_conditional_detr.py | 5 ++--- .../deformable_detr/image_processing_deformable_detr.py | 5 ++--- .../models/grounding_dino/image_processing_grounding_dino.py | 5 ++--- src/transformers/models/yolos/image_processing_yolos.py | 5 ++--- 4 files changed, 8 insertions(+), 12 deletions(-) diff --git a/src/transformers/models/conditional_detr/image_processing_conditional_detr.py b/src/transformers/models/conditional_detr/image_processing_conditional_detr.py index c7bc27207bd30d..bd7b49007fa0ea 100644 --- a/src/transformers/models/conditional_detr/image_processing_conditional_detr.py +++ b/src/transformers/models/conditional_detr/image_processing_conditional_detr.py @@ -1364,7 +1364,6 @@ def preprocess( ) do_pad = kwargs.pop("pad_and_return_pixel_mask") - max_size = None if "max_size" in kwargs: logger.warning_once( "The `max_size` argument is deprecated and will be removed in a future version, use" @@ -1374,7 +1373,7 @@ def preprocess( do_resize = self.do_resize if do_resize is None else do_resize size = self.size if size is None else size - size = get_size_dict(size=size, max_size=max_size, default_to_square=False) + size = get_size_dict(size=size, default_to_square=False) resample = self.resample if resample is None else resample do_rescale = self.do_rescale if do_rescale is None else do_rescale rescale_factor = self.rescale_factor if rescale_factor is None else rescale_factor @@ -1470,7 +1469,7 @@ def preprocess( for image, target in zip(images, annotations): orig_size = get_image_size(image, input_data_format) resized_image = self.resize( - image, size=size, max_size=max_size, resample=resample, input_data_format=input_data_format + image, size=size, resample=resample, input_data_format=input_data_format ) resized_annotation = self.resize_annotation( target, orig_size, get_image_size(resized_image, input_data_format) diff --git a/src/transformers/models/deformable_detr/image_processing_deformable_detr.py b/src/transformers/models/deformable_detr/image_processing_deformable_detr.py index 0b6a58eb8f1351..81bd9fcb491ee3 100644 --- a/src/transformers/models/deformable_detr/image_processing_deformable_detr.py +++ b/src/transformers/models/deformable_detr/image_processing_deformable_detr.py @@ -1362,7 +1362,6 @@ def preprocess( ) do_pad = kwargs.pop("pad_and_return_pixel_mask") - max_size = None if "max_size" in kwargs: logger.warning_once( "The `max_size` argument is deprecated and will be removed in a future version, use" @@ -1372,7 +1371,7 @@ def preprocess( do_resize = self.do_resize if do_resize is None else do_resize size = self.size if size is None else size - size = get_size_dict(size=size, max_size=max_size, default_to_square=False) + size = get_size_dict(size=size, default_to_square=False) resample = self.resample if resample is None else resample do_rescale = self.do_rescale if do_rescale is None else do_rescale rescale_factor = self.rescale_factor if rescale_factor is None else rescale_factor @@ -1468,7 +1467,7 @@ def preprocess( for image, target in zip(images, annotations): orig_size = get_image_size(image, input_data_format) resized_image = self.resize( - image, size=size, max_size=max_size, resample=resample, input_data_format=input_data_format + image, size=size, resample=resample, input_data_format=input_data_format ) resized_annotation = self.resize_annotation( target, orig_size, get_image_size(resized_image, input_data_format) diff --git a/src/transformers/models/grounding_dino/image_processing_grounding_dino.py b/src/transformers/models/grounding_dino/image_processing_grounding_dino.py index 569e22ba470007..f9c299c7e6502e 100644 --- a/src/transformers/models/grounding_dino/image_processing_grounding_dino.py +++ b/src/transformers/models/grounding_dino/image_processing_grounding_dino.py @@ -1370,7 +1370,6 @@ def preprocess( ) do_pad = kwargs.pop("pad_and_return_pixel_mask") - max_size = None if "max_size" in kwargs: logger.warning_once( "The `max_size` argument is deprecated and will be removed in a future version, use" @@ -1380,7 +1379,7 @@ def preprocess( do_resize = self.do_resize if do_resize is None else do_resize size = self.size if size is None else size - size = get_size_dict(size=size, max_size=max_size, default_to_square=False) + size = get_size_dict(size=size, default_to_square=False) resample = self.resample if resample is None else resample do_rescale = self.do_rescale if do_rescale is None else do_rescale rescale_factor = self.rescale_factor if rescale_factor is None else rescale_factor @@ -1476,7 +1475,7 @@ def preprocess( for image, target in zip(images, annotations): orig_size = get_image_size(image, input_data_format) resized_image = self.resize( - image, size=size, max_size=max_size, resample=resample, input_data_format=input_data_format + image, size=size, resample=resample, input_data_format=input_data_format ) resized_annotation = self.resize_annotation( target, orig_size, get_image_size(resized_image, input_data_format) diff --git a/src/transformers/models/yolos/image_processing_yolos.py b/src/transformers/models/yolos/image_processing_yolos.py index 19b21333f60912..8753f0e28d4fbc 100644 --- a/src/transformers/models/yolos/image_processing_yolos.py +++ b/src/transformers/models/yolos/image_processing_yolos.py @@ -1274,7 +1274,6 @@ def preprocess( ) do_pad = kwargs.pop("pad_and_return_pixel_mask") - max_size = None if "max_size" in kwargs: logger.warning_once( "The `max_size` argument is deprecated and will be removed in v4.33, use" @@ -1284,7 +1283,7 @@ def preprocess( do_resize = self.do_resize if do_resize is None else do_resize size = self.size if size is None else size - size = get_size_dict(size=size, max_size=max_size, default_to_square=False) + size = get_size_dict(size=size, default_to_square=False) resample = self.resample if resample is None else resample do_rescale = self.do_rescale if do_rescale is None else do_rescale rescale_factor = self.rescale_factor if rescale_factor is None else rescale_factor @@ -1379,7 +1378,7 @@ def preprocess( for image, target in zip(images, annotations): orig_size = get_image_size(image, input_data_format) resized_image = self.resize( - image, size=size, max_size=max_size, resample=resample, input_data_format=input_data_format + image, size=size, resample=resample, input_data_format=input_data_format ) resized_annotation = self.resize_annotation( target, orig_size, get_image_size(resized_image, input_data_format) From d8e7e6ff9025931468fc1f3827cda1fa391003d5 Mon Sep 17 00:00:00 2001 From: HichTala <98521878+HichTala@users.noreply.github.com> Date: Thu, 28 Nov 2024 16:03:49 +0100 Subject: [PATCH 03/11] Remove deprecated warnings and eliminate `max_size` usage --- .../image_processing_conditional_detr.py | 28 ++----------------- .../image_processing_deformable_detr.py | 28 ++----------------- .../image_processing_deformable_detr_fast.py | 17 +---------- .../models/detr/image_processing_detr.py | 28 ++----------------- .../models/detr/image_processing_detr_fast.py | 17 +---------- .../image_processing_grounding_dino.py | 28 ++----------------- .../models/yolos/image_processing_yolos.py | 28 ++----------------- 7 files changed, 12 insertions(+), 162 deletions(-) diff --git a/src/transformers/models/conditional_detr/image_processing_conditional_detr.py b/src/transformers/models/conditional_detr/image_processing_conditional_detr.py index bd7b49007fa0ea..9baa43b9e4d994 100644 --- a/src/transformers/models/conditional_detr/image_processing_conditional_detr.py +++ b/src/transformers/models/conditional_detr/image_processing_conditional_detr.py @@ -876,17 +876,8 @@ def __init__( if "pad_and_return_pixel_mask" in kwargs: do_pad = kwargs.pop("pad_and_return_pixel_mask") - if "max_size" in kwargs: - logger.warning_once( - "The `max_size` parameter is deprecated and will be removed in v4.26. " - "Please specify in `size['longest_edge'] instead`.", - ) - max_size = kwargs.pop("max_size") - else: - max_size = None if size is None else 1333 - size = size if size is not None else {"shortest_edge": 800, "longest_edge": 1333} - size = get_size_dict(size, max_size=max_size, default_to_square=False) + size = get_size_dict(size, default_to_square=False) # Backwards compatibility if do_convert_annotations is None: @@ -1010,15 +1001,7 @@ def resize( input_data_format (`ChannelDimension` or `str`, *optional*): The channel dimension format of the input image. If not provided, it will be inferred. """ - if "max_size" in kwargs: - logger.warning_once( - "The `max_size` parameter is deprecated and will be removed in v4.26. " - "Please specify in `size['longest_edge'] instead`.", - ) - max_size = kwargs.pop("max_size") - else: - max_size = None - size = get_size_dict(size, max_size=max_size, default_to_square=False) + size = get_size_dict(size, default_to_square=False) if "shortest_edge" in size and "longest_edge" in size: new_size = get_resize_output_image_size( image, size["shortest_edge"], size["longest_edge"], input_data_format=input_data_format @@ -1364,13 +1347,6 @@ def preprocess( ) do_pad = kwargs.pop("pad_and_return_pixel_mask") - if "max_size" in kwargs: - logger.warning_once( - "The `max_size` argument is deprecated and will be removed in a future version, use" - " `size['longest_edge']` instead." - ) - size = kwargs.pop("max_size") - do_resize = self.do_resize if do_resize is None else do_resize size = self.size if size is None else size size = get_size_dict(size=size, default_to_square=False) diff --git a/src/transformers/models/deformable_detr/image_processing_deformable_detr.py b/src/transformers/models/deformable_detr/image_processing_deformable_detr.py index 81bd9fcb491ee3..7c467841b18d2a 100644 --- a/src/transformers/models/deformable_detr/image_processing_deformable_detr.py +++ b/src/transformers/models/deformable_detr/image_processing_deformable_detr.py @@ -874,17 +874,8 @@ def __init__( if "pad_and_return_pixel_mask" in kwargs: do_pad = kwargs.pop("pad_and_return_pixel_mask") - if "max_size" in kwargs: - logger.warning_once( - "The `max_size` parameter is deprecated and will be removed in v4.26. " - "Please specify in `size['longest_edge'] instead`.", - ) - max_size = kwargs.pop("max_size") - else: - max_size = None if size is None else 1333 - size = size if size is not None else {"shortest_edge": 800, "longest_edge": 1333} - size = get_size_dict(size, max_size=max_size, default_to_square=False) + size = get_size_dict(size, default_to_square=False) # Backwards compatibility if do_convert_annotations is None: @@ -1008,15 +999,7 @@ def resize( input_data_format (`ChannelDimension` or `str`, *optional*): The channel dimension format of the input image. If not provided, it will be inferred. """ - if "max_size" in kwargs: - logger.warning_once( - "The `max_size` parameter is deprecated and will be removed in v4.26. " - "Please specify in `size['longest_edge'] instead`.", - ) - max_size = kwargs.pop("max_size") - else: - max_size = None - size = get_size_dict(size, max_size=max_size, default_to_square=False) + size = get_size_dict(size, default_to_square=False) if "shortest_edge" in size and "longest_edge" in size: new_size = get_resize_output_image_size( image, size["shortest_edge"], size["longest_edge"], input_data_format=input_data_format @@ -1362,13 +1345,6 @@ def preprocess( ) do_pad = kwargs.pop("pad_and_return_pixel_mask") - if "max_size" in kwargs: - logger.warning_once( - "The `max_size` argument is deprecated and will be removed in a future version, use" - " `size['longest_edge']` instead." - ) - size = kwargs.pop("max_size") - do_resize = self.do_resize if do_resize is None else do_resize size = self.size if size is None else size size = get_size_dict(size=size, default_to_square=False) diff --git a/src/transformers/models/deformable_detr/image_processing_deformable_detr_fast.py b/src/transformers/models/deformable_detr/image_processing_deformable_detr_fast.py index 0a2fbc14ee94f8..d4a4078ef9fb9d 100644 --- a/src/transformers/models/deformable_detr/image_processing_deformable_detr_fast.py +++ b/src/transformers/models/deformable_detr/image_processing_deformable_detr_fast.py @@ -352,17 +352,8 @@ def __init__( if "pad_and_return_pixel_mask" in kwargs: do_pad = kwargs.pop("pad_and_return_pixel_mask") - if "max_size" in kwargs: - logger.warning_once( - "The `max_size` parameter is deprecated and will be removed in v4.26. " - "Please specify in `size['longest_edge'] instead`.", - ) - max_size = kwargs.pop("max_size") - else: - max_size = None if size is None else 1333 - size = size if size is not None else {"shortest_edge": 800, "longest_edge": 1333} - size = get_size_dict(size, max_size=max_size, default_to_square=False) + size = get_size_dict(size, default_to_square=False) # Backwards compatibility if do_convert_annotations is None: @@ -778,12 +769,6 @@ def preprocess( ) do_pad = kwargs.pop("pad_and_return_pixel_mask") - if "max_size" in kwargs: - logger.warning_once( - "The `max_size` argument is deprecated and will be removed in a future version, use" - " `size['longest_edge']` instead." - ) - size = kwargs.pop("max_size") do_resize = self.do_resize if do_resize is None else do_resize size = self.size if size is None else size size = get_size_dict(size=size, default_to_square=False) diff --git a/src/transformers/models/detr/image_processing_detr.py b/src/transformers/models/detr/image_processing_detr.py index a2075f281d851b..c6da6c15c99988 100644 --- a/src/transformers/models/detr/image_processing_detr.py +++ b/src/transformers/models/detr/image_processing_detr.py @@ -858,17 +858,8 @@ def __init__( if "pad_and_return_pixel_mask" in kwargs: do_pad = kwargs.pop("pad_and_return_pixel_mask") - if "max_size" in kwargs: - logger.warning_once( - "The `max_size` parameter is deprecated and will be removed in v4.26. " - "Please specify in `size['longest_edge'] instead`.", - ) - max_size = kwargs.pop("max_size") - else: - max_size = None if size is None else 1333 - size = size if size is not None else {"shortest_edge": 800, "longest_edge": 1333} - size = get_size_dict(size, max_size=max_size, default_to_square=False) + size = get_size_dict(size, default_to_square=False) # Backwards compatibility if do_convert_annotations is None: @@ -989,15 +980,7 @@ def resize( input_data_format (`ChannelDimension` or `str`, *optional*): The channel dimension format of the input image. If not provided, it will be inferred. """ - if "max_size" in kwargs: - logger.warning_once( - "The `max_size` parameter is deprecated and will be removed in v4.26. " - "Please specify in `size['longest_edge'] instead`.", - ) - max_size = kwargs.pop("max_size") - else: - max_size = None - size = get_size_dict(size, max_size=max_size, default_to_square=False) + size = get_size_dict(size, default_to_square=False) if "shortest_edge" in size and "longest_edge" in size: new_size = get_resize_output_image_size( image, size["shortest_edge"], size["longest_edge"], input_data_format=input_data_format @@ -1337,13 +1320,6 @@ def preprocess( ) do_pad = kwargs.pop("pad_and_return_pixel_mask") - if "max_size" in kwargs: - logger.warning_once( - "The `max_size` argument is deprecated and will be removed in a future version, use" - " `size['longest_edge']` instead." - ) - size = kwargs.pop("max_size") - do_resize = self.do_resize if do_resize is None else do_resize size = self.size if size is None else size size = get_size_dict(size=size, default_to_square=False) diff --git a/src/transformers/models/detr/image_processing_detr_fast.py b/src/transformers/models/detr/image_processing_detr_fast.py index f010ffe272294f..3ca072aba4de33 100644 --- a/src/transformers/models/detr/image_processing_detr_fast.py +++ b/src/transformers/models/detr/image_processing_detr_fast.py @@ -361,17 +361,8 @@ def __init__( if "pad_and_return_pixel_mask" in kwargs: do_pad = kwargs.pop("pad_and_return_pixel_mask") - if "max_size" in kwargs: - logger.warning_once( - "The `max_size` parameter is deprecated and will be removed in v4.26. " - "Please specify in `size['longest_edge'] instead`.", - ) - max_size = kwargs.pop("max_size") - else: - max_size = None if size is None else 1333 - size = size if size is not None else {"shortest_edge": 800, "longest_edge": 1333} - size = get_size_dict(size, max_size=max_size, default_to_square=False) + size = get_size_dict(size, default_to_square=False) # Backwards compatibility if do_convert_annotations is None: @@ -778,12 +769,6 @@ def preprocess( ) do_pad = kwargs.pop("pad_and_return_pixel_mask") - if "max_size" in kwargs: - logger.warning_once( - "The `max_size` argument is deprecated and will be removed in a future version, use" - " `size['longest_edge']` instead." - ) - size = kwargs.pop("max_size") do_resize = self.do_resize if do_resize is None else do_resize size = self.size if size is None else size size = get_size_dict(size=size, default_to_square=False) diff --git a/src/transformers/models/grounding_dino/image_processing_grounding_dino.py b/src/transformers/models/grounding_dino/image_processing_grounding_dino.py index f9c299c7e6502e..a5851c4e7c55da 100644 --- a/src/transformers/models/grounding_dino/image_processing_grounding_dino.py +++ b/src/transformers/models/grounding_dino/image_processing_grounding_dino.py @@ -882,17 +882,8 @@ def __init__( if "pad_and_return_pixel_mask" in kwargs: do_pad = kwargs.pop("pad_and_return_pixel_mask") - if "max_size" in kwargs: - logger.warning_once( - "The `max_size` parameter is deprecated and will be removed in v4.26. " - "Please specify in `size['longest_edge'] instead`.", - ) - max_size = kwargs.pop("max_size") - else: - max_size = None if size is None else 1333 - size = size if size is not None else {"shortest_edge": 800, "longest_edge": 1333} - size = get_size_dict(size, max_size=max_size, default_to_square=False) + size = get_size_dict(size, default_to_square=False) # Backwards compatibility if do_convert_annotations is None: @@ -1016,15 +1007,7 @@ def resize( input_data_format (`ChannelDimension` or `str`, *optional*): The channel dimension format of the input image. If not provided, it will be inferred. """ - if "max_size" in kwargs: - logger.warning_once( - "The `max_size` parameter is deprecated and will be removed in v4.26. " - "Please specify in `size['longest_edge'] instead`.", - ) - max_size = kwargs.pop("max_size") - else: - max_size = None - size = get_size_dict(size, max_size=max_size, default_to_square=False) + size = get_size_dict(size, default_to_square=False) if "shortest_edge" in size and "longest_edge" in size: new_size = get_resize_output_image_size( image, size["shortest_edge"], size["longest_edge"], input_data_format=input_data_format @@ -1370,13 +1353,6 @@ def preprocess( ) do_pad = kwargs.pop("pad_and_return_pixel_mask") - if "max_size" in kwargs: - logger.warning_once( - "The `max_size` argument is deprecated and will be removed in a future version, use" - " `size['longest_edge']` instead." - ) - size = kwargs.pop("max_size") - do_resize = self.do_resize if do_resize is None else do_resize size = self.size if size is None else size size = get_size_dict(size=size, default_to_square=False) diff --git a/src/transformers/models/yolos/image_processing_yolos.py b/src/transformers/models/yolos/image_processing_yolos.py index 8753f0e28d4fbc..d241bad14321ea 100644 --- a/src/transformers/models/yolos/image_processing_yolos.py +++ b/src/transformers/models/yolos/image_processing_yolos.py @@ -790,17 +790,8 @@ def __init__( if "pad_and_return_pixel_mask" in kwargs: do_pad = kwargs.pop("pad_and_return_pixel_mask") - if "max_size" in kwargs: - logger.warning_once( - "The `max_size` parameter is deprecated and will be removed in v4.26. " - "Please specify in `size['longest_edge'] instead`.", - ) - max_size = kwargs.pop("max_size") - else: - max_size = None if size is None else 1333 - size = size if size is not None else {"shortest_edge": 800, "longest_edge": 1333} - size = get_size_dict(size, max_size=max_size, default_to_square=False) + size = get_size_dict(size, default_to_square=False) # Backwards compatibility if do_convert_annotations is None: @@ -924,15 +915,7 @@ def resize( input_data_format (`ChannelDimension` or `str`, *optional*): The channel dimension format of the input image. If not provided, it will be inferred. """ - if "max_size" in kwargs: - logger.warning_once( - "The `max_size` parameter is deprecated and will be removed in v4.26. " - "Please specify in `size['longest_edge'] instead`.", - ) - max_size = kwargs.pop("max_size") - else: - max_size = None - size = get_size_dict(size, max_size=max_size, default_to_square=False) + size = get_size_dict(size, default_to_square=False) if "shortest_edge" in size and "longest_edge" in size: new_size = get_resize_output_image_size( image, size["shortest_edge"], size["longest_edge"], input_data_format=input_data_format @@ -1274,13 +1257,6 @@ def preprocess( ) do_pad = kwargs.pop("pad_and_return_pixel_mask") - if "max_size" in kwargs: - logger.warning_once( - "The `max_size` argument is deprecated and will be removed in v4.33, use" - " `size['longest_edge']` instead.", - ) - size = kwargs.pop("max_size") - do_resize = self.do_resize if do_resize is None else do_resize size = self.size if size is None else size size = get_size_dict(size=size, default_to_square=False) From 1925ee38c7c5eabb11832316712df1d4ba8043d0 Mon Sep 17 00:00:00 2001 From: HichTala <98521878+HichTala@users.noreply.github.com> Date: Thu, 28 Nov 2024 17:35:13 +0100 Subject: [PATCH 04/11] Test use `int` as argument for `size` Add a test to ensure test can pass successfully and backward compatibility --- .../image_processing_conditional_detr.py | 1 + .../image_processing_deformable_detr.py | 1 + .../image_processing_deformable_detr_fast.py | 1 + src/transformers/models/detr/image_processing_detr.py | 1 + .../models/detr/image_processing_detr_fast.py | 1 + .../grounding_dino/image_processing_grounding_dino.py | 1 + .../models/rt_detr/image_processing_rt_detr.py | 11 ++--------- .../models/yolos/image_processing_yolos.py | 1 + 8 files changed, 9 insertions(+), 9 deletions(-) diff --git a/src/transformers/models/conditional_detr/image_processing_conditional_detr.py b/src/transformers/models/conditional_detr/image_processing_conditional_detr.py index 9baa43b9e4d994..1cd2b1eed1120a 100644 --- a/src/transformers/models/conditional_detr/image_processing_conditional_detr.py +++ b/src/transformers/models/conditional_detr/image_processing_conditional_detr.py @@ -877,6 +877,7 @@ def __init__( do_pad = kwargs.pop("pad_and_return_pixel_mask") size = size if size is not None else {"shortest_edge": 800, "longest_edge": 1333} + size = {'shortest_edge': size, 'longest_edge': 1333} if isinstance(size, int) else size # Backwards compatibility size = get_size_dict(size, default_to_square=False) # Backwards compatibility diff --git a/src/transformers/models/deformable_detr/image_processing_deformable_detr.py b/src/transformers/models/deformable_detr/image_processing_deformable_detr.py index 7c467841b18d2a..b973848015fd15 100644 --- a/src/transformers/models/deformable_detr/image_processing_deformable_detr.py +++ b/src/transformers/models/deformable_detr/image_processing_deformable_detr.py @@ -875,6 +875,7 @@ def __init__( do_pad = kwargs.pop("pad_and_return_pixel_mask") size = size if size is not None else {"shortest_edge": 800, "longest_edge": 1333} + size = {'shortest_edge': size, 'longest_edge': 1333} if isinstance(size, int) else size # Backwards compatibility size = get_size_dict(size, default_to_square=False) # Backwards compatibility diff --git a/src/transformers/models/deformable_detr/image_processing_deformable_detr_fast.py b/src/transformers/models/deformable_detr/image_processing_deformable_detr_fast.py index d4a4078ef9fb9d..a829444b25439a 100644 --- a/src/transformers/models/deformable_detr/image_processing_deformable_detr_fast.py +++ b/src/transformers/models/deformable_detr/image_processing_deformable_detr_fast.py @@ -353,6 +353,7 @@ def __init__( do_pad = kwargs.pop("pad_and_return_pixel_mask") size = size if size is not None else {"shortest_edge": 800, "longest_edge": 1333} + size = {'shortest_edge': size, 'longest_edge': 1333} if isinstance(size, int) else size # Backwards compatibility size = get_size_dict(size, default_to_square=False) # Backwards compatibility diff --git a/src/transformers/models/detr/image_processing_detr.py b/src/transformers/models/detr/image_processing_detr.py index c6da6c15c99988..8b1e60315a2ac3 100644 --- a/src/transformers/models/detr/image_processing_detr.py +++ b/src/transformers/models/detr/image_processing_detr.py @@ -859,6 +859,7 @@ def __init__( do_pad = kwargs.pop("pad_and_return_pixel_mask") size = size if size is not None else {"shortest_edge": 800, "longest_edge": 1333} + size = {'shortest_edge': size, 'longest_edge': 1333} if isinstance(size, int) else size # Backwards compatibility size = get_size_dict(size, default_to_square=False) # Backwards compatibility diff --git a/src/transformers/models/detr/image_processing_detr_fast.py b/src/transformers/models/detr/image_processing_detr_fast.py index 3ca072aba4de33..ad6b97d2e4b356 100644 --- a/src/transformers/models/detr/image_processing_detr_fast.py +++ b/src/transformers/models/detr/image_processing_detr_fast.py @@ -362,6 +362,7 @@ def __init__( do_pad = kwargs.pop("pad_and_return_pixel_mask") size = size if size is not None else {"shortest_edge": 800, "longest_edge": 1333} + size = {'shortest_edge': size, 'longest_edge': 1333} if isinstance(size, int) else size # Backwards compatibility size = get_size_dict(size, default_to_square=False) # Backwards compatibility diff --git a/src/transformers/models/grounding_dino/image_processing_grounding_dino.py b/src/transformers/models/grounding_dino/image_processing_grounding_dino.py index a5851c4e7c55da..5c6261e91e154f 100644 --- a/src/transformers/models/grounding_dino/image_processing_grounding_dino.py +++ b/src/transformers/models/grounding_dino/image_processing_grounding_dino.py @@ -883,6 +883,7 @@ def __init__( do_pad = kwargs.pop("pad_and_return_pixel_mask") size = size if size is not None else {"shortest_edge": 800, "longest_edge": 1333} + size = {'shortest_edge': size, 'longest_edge': 1333} if isinstance(size, int) else size # Backwards compatibility size = get_size_dict(size, default_to_square=False) # Backwards compatibility diff --git a/src/transformers/models/rt_detr/image_processing_rt_detr.py b/src/transformers/models/rt_detr/image_processing_rt_detr.py index d031f40848fb8c..e9904f5ccd5d4d 100644 --- a/src/transformers/models/rt_detr/image_processing_rt_detr.py +++ b/src/transformers/models/rt_detr/image_processing_rt_detr.py @@ -453,6 +453,7 @@ def __init__( **kwargs, ) -> None: size = size if size is not None else {"height": 640, "width": 640} + size = {'shortest_edge': size, 'longest_edge': 1333} if isinstance(size, int) else size # Backwards compatibility size = get_size_dict(size, default_to_square=False) if do_convert_annotations is None: @@ -530,15 +531,7 @@ def resize( input_data_format (`ChannelDimension` or `str`, *optional*): The channel dimension format of the input image. If not provided, it will be inferred. """ - if "max_size" in kwargs: - logger.warning_once( - "The `max_size` parameter is deprecated and will be removed in v4.26. " - "Please specify in `size['longest_edge'] instead`.", - ) - max_size = kwargs.pop("max_size") - else: - max_size = None - size = get_size_dict(size, max_size=max_size, default_to_square=False) + size = get_size_dict(size, default_to_square=False) if "shortest_edge" in size and "longest_edge" in size: new_size = get_resize_output_image_size( image, size["shortest_edge"], size["longest_edge"], input_data_format=input_data_format diff --git a/src/transformers/models/yolos/image_processing_yolos.py b/src/transformers/models/yolos/image_processing_yolos.py index d241bad14321ea..74a9f52e14afc7 100644 --- a/src/transformers/models/yolos/image_processing_yolos.py +++ b/src/transformers/models/yolos/image_processing_yolos.py @@ -791,6 +791,7 @@ def __init__( do_pad = kwargs.pop("pad_and_return_pixel_mask") size = size if size is not None else {"shortest_edge": 800, "longest_edge": 1333} + size = {'shortest_edge': size, 'longest_edge': 1333} if isinstance(size, int) else size # Backwards compatibility size = get_size_dict(size, default_to_square=False) # Backwards compatibility From eaed96f041ffc32459536e1524d87f7a12ddee29 Mon Sep 17 00:00:00 2001 From: HichTala <98521878+HichTala@users.noreply.github.com> Date: Thu, 28 Nov 2024 17:59:41 +0100 Subject: [PATCH 05/11] The test pipelines still use `max_size` Remove `max_size` from test pipelines and replace by `size` by a `Dict` with `'shortest_edge'` `'longest_edge'` as keys --- .../conditional_detr/test_image_processing_conditional_detr.py | 2 +- .../deformable_detr/test_image_processing_deformable_detr.py | 2 +- tests/models/detr/test_image_processing_detr.py | 2 +- .../grounding_dino/test_image_processing_grounding_dino.py | 2 +- tests/models/yolos/test_image_processing_yolos.py | 2 +- 5 files changed, 5 insertions(+), 5 deletions(-) diff --git a/tests/models/conditional_detr/test_image_processing_conditional_detr.py b/tests/models/conditional_detr/test_image_processing_conditional_detr.py index 32b135bcd220bd..e15e782206bbcc 100644 --- a/tests/models/conditional_detr/test_image_processing_conditional_detr.py +++ b/tests/models/conditional_detr/test_image_processing_conditional_detr.py @@ -156,7 +156,7 @@ def test_image_processor_from_dict_with_kwargs(self): self.assertEqual(image_processor.do_pad, True) image_processor = self.image_processing_class.from_dict( - self.image_processor_dict, size=42, max_size=84, pad_and_return_pixel_mask=False + self.image_processor_dict, size={"shortest_edge": 42, "longest_edge": 84}, pad_and_return_pixel_mask=False ) self.assertEqual(image_processor.size, {"shortest_edge": 42, "longest_edge": 84}) self.assertEqual(image_processor.do_pad, False) diff --git a/tests/models/deformable_detr/test_image_processing_deformable_detr.py b/tests/models/deformable_detr/test_image_processing_deformable_detr.py index 4a65f1b8d17864..c9dd88797d52e0 100644 --- a/tests/models/deformable_detr/test_image_processing_deformable_detr.py +++ b/tests/models/deformable_detr/test_image_processing_deformable_detr.py @@ -162,7 +162,7 @@ def test_image_processor_from_dict_with_kwargs(self): self.assertEqual(image_processor.do_pad, True) image_processor = image_processing_class.from_dict( - self.image_processor_dict, size=42, max_size=84, pad_and_return_pixel_mask=False + self.image_processor_dict, size={"shortest_edge": 42, "longest_edge": 84}, pad_and_return_pixel_mask=False ) self.assertEqual(image_processor.size, {"shortest_edge": 42, "longest_edge": 84}) self.assertEqual(image_processor.do_pad, False) diff --git a/tests/models/detr/test_image_processing_detr.py b/tests/models/detr/test_image_processing_detr.py index f91c520873668f..5321aa6dbc853a 100644 --- a/tests/models/detr/test_image_processing_detr.py +++ b/tests/models/detr/test_image_processing_detr.py @@ -165,7 +165,7 @@ def test_image_processor_from_dict_with_kwargs(self): self.assertEqual(image_processor.do_pad, True) image_processor = image_processing_class.from_dict( - self.image_processor_dict, size=42, max_size=84, pad_and_return_pixel_mask=False + self.image_processor_dict, size={"shortest_edge": 42, "longest_edge": 84}, pad_and_return_pixel_mask=False ) self.assertEqual(image_processor.size, {"shortest_edge": 42, "longest_edge": 84}) self.assertEqual(image_processor.do_pad, False) diff --git a/tests/models/grounding_dino/test_image_processing_grounding_dino.py b/tests/models/grounding_dino/test_image_processing_grounding_dino.py index bb8b9272efc952..45ac9918749a55 100644 --- a/tests/models/grounding_dino/test_image_processing_grounding_dino.py +++ b/tests/models/grounding_dino/test_image_processing_grounding_dino.py @@ -177,7 +177,7 @@ def test_image_processor_from_dict_with_kwargs(self): self.assertEqual(image_processor.do_pad, True) image_processor = image_processing_class.from_dict( - self.image_processor_dict, size=42, max_size=84, pad_and_return_pixel_mask=False + self.image_processor_dict, size={"shortest_edge": 42, "longest_edge": 84}, pad_and_return_pixel_mask=False ) self.assertEqual(image_processor.size, {"shortest_edge": 42, "longest_edge": 84}) self.assertEqual(image_processor.do_pad, False) diff --git a/tests/models/yolos/test_image_processing_yolos.py b/tests/models/yolos/test_image_processing_yolos.py index 67508532e9c829..bd0821ff3f56a7 100644 --- a/tests/models/yolos/test_image_processing_yolos.py +++ b/tests/models/yolos/test_image_processing_yolos.py @@ -167,7 +167,7 @@ def test_image_processor_from_dict_with_kwargs(self): self.assertEqual(image_processor.do_pad, True) image_processor = self.image_processing_class.from_dict( - self.image_processor_dict, size=42, max_size=84, pad_and_return_pixel_mask=False + self.image_processor_dict, size={"shortest_edge": 42, "longest_edge": 84}, pad_and_return_pixel_mask=False ) self.assertEqual(image_processor.size, {"shortest_edge": 42, "longest_edge": 84}) self.assertEqual(image_processor.do_pad, False) From ac4522e5c9a02d2d0c298295026db68ea26453df Mon Sep 17 00:00:00 2001 From: HichTala <98521878+HichTala@users.noreply.github.com> Date: Thu, 28 Nov 2024 18:36:49 +0100 Subject: [PATCH 06/11] Reformatting --- .../grounding_dino/test_image_processing_grounding_dino.py | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/tests/models/grounding_dino/test_image_processing_grounding_dino.py b/tests/models/grounding_dino/test_image_processing_grounding_dino.py index 45ac9918749a55..d3bc31ee1e123f 100644 --- a/tests/models/grounding_dino/test_image_processing_grounding_dino.py +++ b/tests/models/grounding_dino/test_image_processing_grounding_dino.py @@ -177,7 +177,9 @@ def test_image_processor_from_dict_with_kwargs(self): self.assertEqual(image_processor.do_pad, True) image_processor = image_processing_class.from_dict( - self.image_processor_dict, size={"shortest_edge": 42, "longest_edge": 84}, pad_and_return_pixel_mask=False + self.image_processor_dict, + size={"shortest_edge": 42, "longest_edge": 84}, + pad_and_return_pixel_mask=False, ) self.assertEqual(image_processor.size, {"shortest_edge": 42, "longest_edge": 84}) self.assertEqual(image_processor.do_pad, False) From c3040acee75440357cffd1f60c9d29ff5b2744b8 Mon Sep 17 00:00:00 2001 From: HichTala <98521878+HichTala@users.noreply.github.com> Date: Thu, 28 Nov 2024 18:42:01 +0100 Subject: [PATCH 07/11] Reformatting --- .../conditional_detr/image_processing_conditional_detr.py | 4 +++- .../deformable_detr/image_processing_deformable_detr.py | 4 +++- .../deformable_detr/image_processing_deformable_detr_fast.py | 4 +++- src/transformers/models/detr/image_processing_detr.py | 4 +++- src/transformers/models/detr/image_processing_detr_fast.py | 4 +++- .../models/grounding_dino/image_processing_grounding_dino.py | 4 +++- src/transformers/models/rt_detr/image_processing_rt_detr.py | 4 +++- src/transformers/models/yolos/image_processing_yolos.py | 4 +++- .../deformable_detr/test_image_processing_deformable_detr.py | 4 +++- tests/models/detr/test_image_processing_detr.py | 4 +++- 10 files changed, 30 insertions(+), 10 deletions(-) diff --git a/src/transformers/models/conditional_detr/image_processing_conditional_detr.py b/src/transformers/models/conditional_detr/image_processing_conditional_detr.py index 1cd2b1eed1120a..3d12410af744ed 100644 --- a/src/transformers/models/conditional_detr/image_processing_conditional_detr.py +++ b/src/transformers/models/conditional_detr/image_processing_conditional_detr.py @@ -877,7 +877,9 @@ def __init__( do_pad = kwargs.pop("pad_and_return_pixel_mask") size = size if size is not None else {"shortest_edge": 800, "longest_edge": 1333} - size = {'shortest_edge': size, 'longest_edge': 1333} if isinstance(size, int) else size # Backwards compatibility + size = ( + {"shortest_edge": size, "longest_edge": 1333} if isinstance(size, int) else size + ) # Backwards compatibility size = get_size_dict(size, default_to_square=False) # Backwards compatibility diff --git a/src/transformers/models/deformable_detr/image_processing_deformable_detr.py b/src/transformers/models/deformable_detr/image_processing_deformable_detr.py index b973848015fd15..f620fa76fff741 100644 --- a/src/transformers/models/deformable_detr/image_processing_deformable_detr.py +++ b/src/transformers/models/deformable_detr/image_processing_deformable_detr.py @@ -875,7 +875,9 @@ def __init__( do_pad = kwargs.pop("pad_and_return_pixel_mask") size = size if size is not None else {"shortest_edge": 800, "longest_edge": 1333} - size = {'shortest_edge': size, 'longest_edge': 1333} if isinstance(size, int) else size # Backwards compatibility + size = ( + {"shortest_edge": size, "longest_edge": 1333} if isinstance(size, int) else size + ) # Backwards compatibility size = get_size_dict(size, default_to_square=False) # Backwards compatibility diff --git a/src/transformers/models/deformable_detr/image_processing_deformable_detr_fast.py b/src/transformers/models/deformable_detr/image_processing_deformable_detr_fast.py index a829444b25439a..8f0380be9d9492 100644 --- a/src/transformers/models/deformable_detr/image_processing_deformable_detr_fast.py +++ b/src/transformers/models/deformable_detr/image_processing_deformable_detr_fast.py @@ -353,7 +353,9 @@ def __init__( do_pad = kwargs.pop("pad_and_return_pixel_mask") size = size if size is not None else {"shortest_edge": 800, "longest_edge": 1333} - size = {'shortest_edge': size, 'longest_edge': 1333} if isinstance(size, int) else size # Backwards compatibility + size = ( + {"shortest_edge": size, "longest_edge": 1333} if isinstance(size, int) else size + ) # Backwards compatibility size = get_size_dict(size, default_to_square=False) # Backwards compatibility diff --git a/src/transformers/models/detr/image_processing_detr.py b/src/transformers/models/detr/image_processing_detr.py index 8b1e60315a2ac3..80ee10970f5d83 100644 --- a/src/transformers/models/detr/image_processing_detr.py +++ b/src/transformers/models/detr/image_processing_detr.py @@ -859,7 +859,9 @@ def __init__( do_pad = kwargs.pop("pad_and_return_pixel_mask") size = size if size is not None else {"shortest_edge": 800, "longest_edge": 1333} - size = {'shortest_edge': size, 'longest_edge': 1333} if isinstance(size, int) else size # Backwards compatibility + size = ( + {"shortest_edge": size, "longest_edge": 1333} if isinstance(size, int) else size + ) # Backwards compatibility size = get_size_dict(size, default_to_square=False) # Backwards compatibility diff --git a/src/transformers/models/detr/image_processing_detr_fast.py b/src/transformers/models/detr/image_processing_detr_fast.py index ad6b97d2e4b356..d837cca97b1d2e 100644 --- a/src/transformers/models/detr/image_processing_detr_fast.py +++ b/src/transformers/models/detr/image_processing_detr_fast.py @@ -362,7 +362,9 @@ def __init__( do_pad = kwargs.pop("pad_and_return_pixel_mask") size = size if size is not None else {"shortest_edge": 800, "longest_edge": 1333} - size = {'shortest_edge': size, 'longest_edge': 1333} if isinstance(size, int) else size # Backwards compatibility + size = ( + {"shortest_edge": size, "longest_edge": 1333} if isinstance(size, int) else size + ) # Backwards compatibility size = get_size_dict(size, default_to_square=False) # Backwards compatibility diff --git a/src/transformers/models/grounding_dino/image_processing_grounding_dino.py b/src/transformers/models/grounding_dino/image_processing_grounding_dino.py index 5c6261e91e154f..58b22c8fd08a4b 100644 --- a/src/transformers/models/grounding_dino/image_processing_grounding_dino.py +++ b/src/transformers/models/grounding_dino/image_processing_grounding_dino.py @@ -883,7 +883,9 @@ def __init__( do_pad = kwargs.pop("pad_and_return_pixel_mask") size = size if size is not None else {"shortest_edge": 800, "longest_edge": 1333} - size = {'shortest_edge': size, 'longest_edge': 1333} if isinstance(size, int) else size # Backwards compatibility + size = ( + {"shortest_edge": size, "longest_edge": 1333} if isinstance(size, int) else size + ) # Backwards compatibility size = get_size_dict(size, default_to_square=False) # Backwards compatibility diff --git a/src/transformers/models/rt_detr/image_processing_rt_detr.py b/src/transformers/models/rt_detr/image_processing_rt_detr.py index e9904f5ccd5d4d..5b1d1e7128c1fc 100644 --- a/src/transformers/models/rt_detr/image_processing_rt_detr.py +++ b/src/transformers/models/rt_detr/image_processing_rt_detr.py @@ -453,7 +453,9 @@ def __init__( **kwargs, ) -> None: size = size if size is not None else {"height": 640, "width": 640} - size = {'shortest_edge': size, 'longest_edge': 1333} if isinstance(size, int) else size # Backwards compatibility + size = ( + {"shortest_edge": size, "longest_edge": 1333} if isinstance(size, int) else size + ) # Backwards compatibility size = get_size_dict(size, default_to_square=False) if do_convert_annotations is None: diff --git a/src/transformers/models/yolos/image_processing_yolos.py b/src/transformers/models/yolos/image_processing_yolos.py index 74a9f52e14afc7..81e760ab261ad9 100644 --- a/src/transformers/models/yolos/image_processing_yolos.py +++ b/src/transformers/models/yolos/image_processing_yolos.py @@ -791,7 +791,9 @@ def __init__( do_pad = kwargs.pop("pad_and_return_pixel_mask") size = size if size is not None else {"shortest_edge": 800, "longest_edge": 1333} - size = {'shortest_edge': size, 'longest_edge': 1333} if isinstance(size, int) else size # Backwards compatibility + size = ( + {"shortest_edge": size, "longest_edge": 1333} if isinstance(size, int) else size + ) # Backwards compatibility size = get_size_dict(size, default_to_square=False) # Backwards compatibility diff --git a/tests/models/deformable_detr/test_image_processing_deformable_detr.py b/tests/models/deformable_detr/test_image_processing_deformable_detr.py index c9dd88797d52e0..93882ebef5c6d1 100644 --- a/tests/models/deformable_detr/test_image_processing_deformable_detr.py +++ b/tests/models/deformable_detr/test_image_processing_deformable_detr.py @@ -162,7 +162,9 @@ def test_image_processor_from_dict_with_kwargs(self): self.assertEqual(image_processor.do_pad, True) image_processor = image_processing_class.from_dict( - self.image_processor_dict, size={"shortest_edge": 42, "longest_edge": 84}, pad_and_return_pixel_mask=False + self.image_processor_dict, + size={"shortest_edge": 42, "longest_edge": 84}, + pad_and_return_pixel_mask=False, ) self.assertEqual(image_processor.size, {"shortest_edge": 42, "longest_edge": 84}) self.assertEqual(image_processor.do_pad, False) diff --git a/tests/models/detr/test_image_processing_detr.py b/tests/models/detr/test_image_processing_detr.py index 5321aa6dbc853a..90a9273151189a 100644 --- a/tests/models/detr/test_image_processing_detr.py +++ b/tests/models/detr/test_image_processing_detr.py @@ -165,7 +165,9 @@ def test_image_processor_from_dict_with_kwargs(self): self.assertEqual(image_processor.do_pad, True) image_processor = image_processing_class.from_dict( - self.image_processor_dict, size={"shortest_edge": 42, "longest_edge": 84}, pad_and_return_pixel_mask=False + self.image_processor_dict, + size={"shortest_edge": 42, "longest_edge": 84}, + pad_and_return_pixel_mask=False, ) self.assertEqual(image_processor.size, {"shortest_edge": 42, "longest_edge": 84}) self.assertEqual(image_processor.do_pad, False) From 621dad800e6797e783a76266aa36764c167cfde8 Mon Sep 17 00:00:00 2001 From: Hich Tala <98521878+HichTala@users.noreply.github.com> Date: Fri, 29 Nov 2024 10:39:24 +0100 Subject: [PATCH 08/11] Place comments above to avoid line breaks --- .../conditional_detr/image_processing_conditional_detr.py | 5 ++--- .../deformable_detr/image_processing_deformable_detr.py | 5 ++--- .../deformable_detr/image_processing_deformable_detr_fast.py | 5 ++--- src/transformers/models/detr/image_processing_detr.py | 5 ++--- src/transformers/models/detr/image_processing_detr_fast.py | 5 ++--- .../models/grounding_dino/image_processing_grounding_dino.py | 5 ++--- src/transformers/models/rt_detr/image_processing_rt_detr.py | 5 ++--- src/transformers/models/yolos/image_processing_yolos.py | 5 ++--- 8 files changed, 16 insertions(+), 24 deletions(-) diff --git a/src/transformers/models/conditional_detr/image_processing_conditional_detr.py b/src/transformers/models/conditional_detr/image_processing_conditional_detr.py index 3d12410af744ed..be09133378963e 100644 --- a/src/transformers/models/conditional_detr/image_processing_conditional_detr.py +++ b/src/transformers/models/conditional_detr/image_processing_conditional_detr.py @@ -877,9 +877,8 @@ def __init__( do_pad = kwargs.pop("pad_and_return_pixel_mask") size = size if size is not None else {"shortest_edge": 800, "longest_edge": 1333} - size = ( - {"shortest_edge": size, "longest_edge": 1333} if isinstance(size, int) else size - ) # Backwards compatibility + # Backwards compatibility + size = {"shortest_edge": size, "longest_edge": 1333} if isinstance(size, int) else size size = get_size_dict(size, default_to_square=False) # Backwards compatibility diff --git a/src/transformers/models/deformable_detr/image_processing_deformable_detr.py b/src/transformers/models/deformable_detr/image_processing_deformable_detr.py index f620fa76fff741..2e071095520e8b 100644 --- a/src/transformers/models/deformable_detr/image_processing_deformable_detr.py +++ b/src/transformers/models/deformable_detr/image_processing_deformable_detr.py @@ -875,9 +875,8 @@ def __init__( do_pad = kwargs.pop("pad_and_return_pixel_mask") size = size if size is not None else {"shortest_edge": 800, "longest_edge": 1333} - size = ( - {"shortest_edge": size, "longest_edge": 1333} if isinstance(size, int) else size - ) # Backwards compatibility + # Backwards compatibility + size = {"shortest_edge": size, "longest_edge": 1333} if isinstance(size, int) else size size = get_size_dict(size, default_to_square=False) # Backwards compatibility diff --git a/src/transformers/models/deformable_detr/image_processing_deformable_detr_fast.py b/src/transformers/models/deformable_detr/image_processing_deformable_detr_fast.py index 8f0380be9d9492..13238ad26150a8 100644 --- a/src/transformers/models/deformable_detr/image_processing_deformable_detr_fast.py +++ b/src/transformers/models/deformable_detr/image_processing_deformable_detr_fast.py @@ -353,9 +353,8 @@ def __init__( do_pad = kwargs.pop("pad_and_return_pixel_mask") size = size if size is not None else {"shortest_edge": 800, "longest_edge": 1333} - size = ( - {"shortest_edge": size, "longest_edge": 1333} if isinstance(size, int) else size - ) # Backwards compatibility + # Backwards compatibility + size = {"shortest_edge": size, "longest_edge": 1333} if isinstance(size, int) else size size = get_size_dict(size, default_to_square=False) # Backwards compatibility diff --git a/src/transformers/models/detr/image_processing_detr.py b/src/transformers/models/detr/image_processing_detr.py index 80ee10970f5d83..5aa62add7cee2c 100644 --- a/src/transformers/models/detr/image_processing_detr.py +++ b/src/transformers/models/detr/image_processing_detr.py @@ -859,9 +859,8 @@ def __init__( do_pad = kwargs.pop("pad_and_return_pixel_mask") size = size if size is not None else {"shortest_edge": 800, "longest_edge": 1333} - size = ( - {"shortest_edge": size, "longest_edge": 1333} if isinstance(size, int) else size - ) # Backwards compatibility + # Backwards compatibility + size = {"shortest_edge": size, "longest_edge": 1333} if isinstance(size, int) else size size = get_size_dict(size, default_to_square=False) # Backwards compatibility diff --git a/src/transformers/models/detr/image_processing_detr_fast.py b/src/transformers/models/detr/image_processing_detr_fast.py index d837cca97b1d2e..49f0f43f8c4411 100644 --- a/src/transformers/models/detr/image_processing_detr_fast.py +++ b/src/transformers/models/detr/image_processing_detr_fast.py @@ -362,9 +362,8 @@ def __init__( do_pad = kwargs.pop("pad_and_return_pixel_mask") size = size if size is not None else {"shortest_edge": 800, "longest_edge": 1333} - size = ( - {"shortest_edge": size, "longest_edge": 1333} if isinstance(size, int) else size - ) # Backwards compatibility + # Backwards compatibility + size = {"shortest_edge": size, "longest_edge": 1333} if isinstance(size, int) else size size = get_size_dict(size, default_to_square=False) # Backwards compatibility diff --git a/src/transformers/models/grounding_dino/image_processing_grounding_dino.py b/src/transformers/models/grounding_dino/image_processing_grounding_dino.py index 58b22c8fd08a4b..7437f56b08e29a 100644 --- a/src/transformers/models/grounding_dino/image_processing_grounding_dino.py +++ b/src/transformers/models/grounding_dino/image_processing_grounding_dino.py @@ -883,9 +883,8 @@ def __init__( do_pad = kwargs.pop("pad_and_return_pixel_mask") size = size if size is not None else {"shortest_edge": 800, "longest_edge": 1333} - size = ( - {"shortest_edge": size, "longest_edge": 1333} if isinstance(size, int) else size - ) # Backwards compatibility + # Backwards compatibility + size = {"shortest_edge": size, "longest_edge": 1333} if isinstance(size, int) else size size = get_size_dict(size, default_to_square=False) # Backwards compatibility diff --git a/src/transformers/models/rt_detr/image_processing_rt_detr.py b/src/transformers/models/rt_detr/image_processing_rt_detr.py index 5b1d1e7128c1fc..865e8d64f42e83 100644 --- a/src/transformers/models/rt_detr/image_processing_rt_detr.py +++ b/src/transformers/models/rt_detr/image_processing_rt_detr.py @@ -453,9 +453,8 @@ def __init__( **kwargs, ) -> None: size = size if size is not None else {"height": 640, "width": 640} - size = ( - {"shortest_edge": size, "longest_edge": 1333} if isinstance(size, int) else size - ) # Backwards compatibility + # Backwards compatibility + size = {"shortest_edge": size, "longest_edge": 1333} if isinstance(size, int) else size size = get_size_dict(size, default_to_square=False) if do_convert_annotations is None: diff --git a/src/transformers/models/yolos/image_processing_yolos.py b/src/transformers/models/yolos/image_processing_yolos.py index 81e760ab261ad9..e42f1955eb7065 100644 --- a/src/transformers/models/yolos/image_processing_yolos.py +++ b/src/transformers/models/yolos/image_processing_yolos.py @@ -791,9 +791,8 @@ def __init__( do_pad = kwargs.pop("pad_and_return_pixel_mask") size = size if size is not None else {"shortest_edge": 800, "longest_edge": 1333} - size = ( - {"shortest_edge": size, "longest_edge": 1333} if isinstance(size, int) else size - ) # Backwards compatibility + # Backwards compatibility + size = {"shortest_edge": size, "longest_edge": 1333} if isinstance(size, int) else size size = get_size_dict(size, default_to_square=False) # Backwards compatibility From 5b16e3eaf4d496f2f9c1eeb238949fad3130f15f Mon Sep 17 00:00:00 2001 From: Hich Tala <98521878+HichTala@users.noreply.github.com> Date: Fri, 29 Nov 2024 14:33:25 +0100 Subject: [PATCH 09/11] Add ValueError raising when `max_size` parameter is used, to avoid size mismatching results with previous processing --- .../image_processing_conditional_detr.py | 18 ++++++++++++++++++ .../image_processing_deformable_detr.py | 19 +++++++++++++++++++ .../image_processing_deformable_detr_fast.py | 12 ++++++++++++ .../models/detr/image_processing_detr.py | 18 ++++++++++++++++++ .../models/detr/image_processing_detr_fast.py | 12 ++++++++++++ .../image_processing_grounding_dino.py | 18 ++++++++++++++++++ .../rt_detr/image_processing_rt_detr.py | 6 ++++++ .../models/yolos/image_processing_yolos.py | 18 ++++++++++++++++++ 8 files changed, 121 insertions(+) diff --git a/src/transformers/models/conditional_detr/image_processing_conditional_detr.py b/src/transformers/models/conditional_detr/image_processing_conditional_detr.py index be09133378963e..c2660c9216cbf4 100644 --- a/src/transformers/models/conditional_detr/image_processing_conditional_detr.py +++ b/src/transformers/models/conditional_detr/image_processing_conditional_detr.py @@ -876,6 +876,12 @@ def __init__( if "pad_and_return_pixel_mask" in kwargs: do_pad = kwargs.pop("pad_and_return_pixel_mask") + if "max_size" in kwargs: + logger.error( + "The `max_size` parameter is deprecated. " + "Please specify in `size['longest_edge'] instead`.", + ) + size = size if size is not None else {"shortest_edge": 800, "longest_edge": 1333} # Backwards compatibility size = {"shortest_edge": size, "longest_edge": 1333} if isinstance(size, int) else size @@ -1003,6 +1009,12 @@ def resize( input_data_format (`ChannelDimension` or `str`, *optional*): The channel dimension format of the input image. If not provided, it will be inferred. """ + if "max_size" in kwargs: + logger.error( + "The `max_size` parameter is deprecated. " + "Please specify in `size['longest_edge'] instead`.", + ) + size = get_size_dict(size, default_to_square=False) if "shortest_edge" in size and "longest_edge" in size: new_size = get_resize_output_image_size( @@ -1349,6 +1361,12 @@ def preprocess( ) do_pad = kwargs.pop("pad_and_return_pixel_mask") + if "max_size" in kwargs: + logger.error( + "The `max_size` argument is deprecated, use" + " `size['longest_edge']` instead." + ) + do_resize = self.do_resize if do_resize is None else do_resize size = self.size if size is None else size size = get_size_dict(size=size, default_to_square=False) diff --git a/src/transformers/models/deformable_detr/image_processing_deformable_detr.py b/src/transformers/models/deformable_detr/image_processing_deformable_detr.py index 2e071095520e8b..8b3231e67047f3 100644 --- a/src/transformers/models/deformable_detr/image_processing_deformable_detr.py +++ b/src/transformers/models/deformable_detr/image_processing_deformable_detr.py @@ -874,6 +874,12 @@ def __init__( if "pad_and_return_pixel_mask" in kwargs: do_pad = kwargs.pop("pad_and_return_pixel_mask") + if "max_size" in kwargs: + logger.error( + "The `max_size` parameter is deprecated. " + "Please specify in `size['longest_edge'] instead`.", + ) + size = size if size is not None else {"shortest_edge": 800, "longest_edge": 1333} # Backwards compatibility size = {"shortest_edge": size, "longest_edge": 1333} if isinstance(size, int) else size @@ -1001,6 +1007,12 @@ def resize( input_data_format (`ChannelDimension` or `str`, *optional*): The channel dimension format of the input image. If not provided, it will be inferred. """ + if "max_size" in kwargs: + logger.error( + "The `max_size` parameter is deprecated. " + "Please specify in `size['longest_edge'] instead`.", + ) + size = get_size_dict(size, default_to_square=False) if "shortest_edge" in size and "longest_edge" in size: new_size = get_resize_output_image_size( @@ -1347,6 +1359,13 @@ def preprocess( ) do_pad = kwargs.pop("pad_and_return_pixel_mask") + if "max_size" in kwargs: + logger.error( + "The `max_size` argument is deprecated, use" + " `size['longest_edge']` instead." + ) + size = kwargs.pop("max_size") + do_resize = self.do_resize if do_resize is None else do_resize size = self.size if size is None else size size = get_size_dict(size=size, default_to_square=False) diff --git a/src/transformers/models/deformable_detr/image_processing_deformable_detr_fast.py b/src/transformers/models/deformable_detr/image_processing_deformable_detr_fast.py index 13238ad26150a8..0b7b18fc0ea5ef 100644 --- a/src/transformers/models/deformable_detr/image_processing_deformable_detr_fast.py +++ b/src/transformers/models/deformable_detr/image_processing_deformable_detr_fast.py @@ -352,6 +352,12 @@ def __init__( if "pad_and_return_pixel_mask" in kwargs: do_pad = kwargs.pop("pad_and_return_pixel_mask") + if "max_size" in kwargs: + logger.error( + "The `max_size` parameter is deprecated. " + "Please specify in `size['longest_edge'] instead`.", + ) + size = size if size is not None else {"shortest_edge": 800, "longest_edge": 1333} # Backwards compatibility size = {"shortest_edge": size, "longest_edge": 1333} if isinstance(size, int) else size @@ -771,6 +777,12 @@ def preprocess( ) do_pad = kwargs.pop("pad_and_return_pixel_mask") + if "max_size" in kwargs: + logger.warning_once( + "The `max_size` argument is deprecated and will be removed in a future version, use" + " `size['longest_edge']` instead." + ) + size = kwargs.pop("max_size") do_resize = self.do_resize if do_resize is None else do_resize size = self.size if size is None else size size = get_size_dict(size=size, default_to_square=False) diff --git a/src/transformers/models/detr/image_processing_detr.py b/src/transformers/models/detr/image_processing_detr.py index 5aa62add7cee2c..82480fb7e03d8c 100644 --- a/src/transformers/models/detr/image_processing_detr.py +++ b/src/transformers/models/detr/image_processing_detr.py @@ -858,6 +858,12 @@ def __init__( if "pad_and_return_pixel_mask" in kwargs: do_pad = kwargs.pop("pad_and_return_pixel_mask") + if "max_size" in kwargs: + logger.error( + "The `max_size` parameter is deprecated. " + "Please specify in `size['longest_edge'] instead`.", + ) + size = size if size is not None else {"shortest_edge": 800, "longest_edge": 1333} # Backwards compatibility size = {"shortest_edge": size, "longest_edge": 1333} if isinstance(size, int) else size @@ -982,6 +988,12 @@ def resize( input_data_format (`ChannelDimension` or `str`, *optional*): The channel dimension format of the input image. If not provided, it will be inferred. """ + if "max_size" in kwargs: + logger.error( + "The `max_size` parameter is deprecated. " + "Please specify in `size['longest_edge'] instead`.", + ) + size = get_size_dict(size, default_to_square=False) if "shortest_edge" in size and "longest_edge" in size: new_size = get_resize_output_image_size( @@ -1322,6 +1334,12 @@ def preprocess( ) do_pad = kwargs.pop("pad_and_return_pixel_mask") + if "max_size" in kwargs: + logger.error( + "The `max_size` argument is deprecated, use" + " `size['longest_edge']` instead." + ) + do_resize = self.do_resize if do_resize is None else do_resize size = self.size if size is None else size size = get_size_dict(size=size, default_to_square=False) diff --git a/src/transformers/models/detr/image_processing_detr_fast.py b/src/transformers/models/detr/image_processing_detr_fast.py index 49f0f43f8c4411..0ca645cde243fa 100644 --- a/src/transformers/models/detr/image_processing_detr_fast.py +++ b/src/transformers/models/detr/image_processing_detr_fast.py @@ -361,6 +361,12 @@ def __init__( if "pad_and_return_pixel_mask" in kwargs: do_pad = kwargs.pop("pad_and_return_pixel_mask") + if "max_size" in kwargs: + logger.error( + "The `max_size` parameter is deprecated. " + "Please specify in `size['longest_edge'] instead`.", + ) + size = size if size is not None else {"shortest_edge": 800, "longest_edge": 1333} # Backwards compatibility size = {"shortest_edge": size, "longest_edge": 1333} if isinstance(size, int) else size @@ -771,6 +777,12 @@ def preprocess( ) do_pad = kwargs.pop("pad_and_return_pixel_mask") + if "max_size" in kwargs: + logger.error( + "The `max_size` argument is deprecated, use" + " `size['longest_edge']` instead." + ) + do_resize = self.do_resize if do_resize is None else do_resize size = self.size if size is None else size size = get_size_dict(size=size, default_to_square=False) diff --git a/src/transformers/models/grounding_dino/image_processing_grounding_dino.py b/src/transformers/models/grounding_dino/image_processing_grounding_dino.py index 7437f56b08e29a..928a6c91109cd6 100644 --- a/src/transformers/models/grounding_dino/image_processing_grounding_dino.py +++ b/src/transformers/models/grounding_dino/image_processing_grounding_dino.py @@ -882,6 +882,12 @@ def __init__( if "pad_and_return_pixel_mask" in kwargs: do_pad = kwargs.pop("pad_and_return_pixel_mask") + if "max_size" in kwargs: + raise ValueError( + "The `max_size` parameter is deprecated. " + "Please specify in `size['longest_edge'] instead`.", + ) + size = size if size is not None else {"shortest_edge": 800, "longest_edge": 1333} # Backwards compatibility size = {"shortest_edge": size, "longest_edge": 1333} if isinstance(size, int) else size @@ -1009,6 +1015,12 @@ def resize( input_data_format (`ChannelDimension` or `str`, *optional*): The channel dimension format of the input image. If not provided, it will be inferred. """ + if "max_size" in kwargs: + raise ValueError( + "The `max_size` parameter is deprecated. " + "Please specify in `size['longest_edge'] instead`.", + ) + size = get_size_dict(size, default_to_square=False) if "shortest_edge" in size and "longest_edge" in size: new_size = get_resize_output_image_size( @@ -1355,6 +1367,12 @@ def preprocess( ) do_pad = kwargs.pop("pad_and_return_pixel_mask") + if "max_size" in kwargs: + raise ValueError( + "The `max_size` argument is deprecated, use" + " `size['longest_edge']` instead." + ) + do_resize = self.do_resize if do_resize is None else do_resize size = self.size if size is None else size size = get_size_dict(size=size, default_to_square=False) diff --git a/src/transformers/models/rt_detr/image_processing_rt_detr.py b/src/transformers/models/rt_detr/image_processing_rt_detr.py index 865e8d64f42e83..815b13793cba4b 100644 --- a/src/transformers/models/rt_detr/image_processing_rt_detr.py +++ b/src/transformers/models/rt_detr/image_processing_rt_detr.py @@ -532,6 +532,12 @@ def resize( input_data_format (`ChannelDimension` or `str`, *optional*): The channel dimension format of the input image. If not provided, it will be inferred. """ + if "max_size" in kwargs: + logger.error( + "The `max_size` parameter is deprecated. " + "Please specify in `size['longest_edge'] instead`.", + ) + size = get_size_dict(size, default_to_square=False) if "shortest_edge" in size and "longest_edge" in size: new_size = get_resize_output_image_size( diff --git a/src/transformers/models/yolos/image_processing_yolos.py b/src/transformers/models/yolos/image_processing_yolos.py index e42f1955eb7065..1c5059cf440108 100644 --- a/src/transformers/models/yolos/image_processing_yolos.py +++ b/src/transformers/models/yolos/image_processing_yolos.py @@ -790,6 +790,12 @@ def __init__( if "pad_and_return_pixel_mask" in kwargs: do_pad = kwargs.pop("pad_and_return_pixel_mask") + if "max_size" in kwargs: + logger.error( + "The `max_size` parameter is deprecated. " + "Please specify in `size['longest_edge'] instead`.", + ) + size = size if size is not None else {"shortest_edge": 800, "longest_edge": 1333} # Backwards compatibility size = {"shortest_edge": size, "longest_edge": 1333} if isinstance(size, int) else size @@ -917,6 +923,12 @@ def resize( input_data_format (`ChannelDimension` or `str`, *optional*): The channel dimension format of the input image. If not provided, it will be inferred. """ + if "max_size" in kwargs: + logger.error( + "The `max_size` parameter is deprecated. " + "Please specify in `size['longest_edge'] instead`.", + ) + size = get_size_dict(size, default_to_square=False) if "shortest_edge" in size and "longest_edge" in size: new_size = get_resize_output_image_size( @@ -1259,6 +1271,12 @@ def preprocess( ) do_pad = kwargs.pop("pad_and_return_pixel_mask") + if "max_size" in kwargs: + logger.error( + "The `max_size` argument is deprecated, use" + " `size['longest_edge']` instead.", + ) + do_resize = self.do_resize if do_resize is None else do_resize size = self.size if size is None else size size = get_size_dict(size=size, default_to_square=False) From 91370ab9dc9ee9fc7ee628d19cf68fad76a82a03 Mon Sep 17 00:00:00 2001 From: Hich Tala <98521878+HichTala@users.noreply.github.com> Date: Wed, 4 Dec 2024 18:18:28 +0100 Subject: [PATCH 10/11] Reformatting --- .../image_processing_deformable_detr.py | 6 +----- .../image_processing_deformable_detr_fast.py | 7 ++----- .../image_processing_grounding_dino.py | 15 +++++---------- 3 files changed, 8 insertions(+), 20 deletions(-) diff --git a/src/transformers/models/deformable_detr/image_processing_deformable_detr.py b/src/transformers/models/deformable_detr/image_processing_deformable_detr.py index 8b3231e67047f3..84f842b8631e31 100644 --- a/src/transformers/models/deformable_detr/image_processing_deformable_detr.py +++ b/src/transformers/models/deformable_detr/image_processing_deformable_detr.py @@ -1360,11 +1360,7 @@ def preprocess( do_pad = kwargs.pop("pad_and_return_pixel_mask") if "max_size" in kwargs: - logger.error( - "The `max_size` argument is deprecated, use" - " `size['longest_edge']` instead." - ) - size = kwargs.pop("max_size") + logger.error("The `max_size` argument is deprecated, use" " `size['longest_edge']` instead.") do_resize = self.do_resize if do_resize is None else do_resize size = self.size if size is None else size diff --git a/src/transformers/models/deformable_detr/image_processing_deformable_detr_fast.py b/src/transformers/models/deformable_detr/image_processing_deformable_detr_fast.py index 0b7b18fc0ea5ef..0644888622327d 100644 --- a/src/transformers/models/deformable_detr/image_processing_deformable_detr_fast.py +++ b/src/transformers/models/deformable_detr/image_processing_deformable_detr_fast.py @@ -778,11 +778,8 @@ def preprocess( do_pad = kwargs.pop("pad_and_return_pixel_mask") if "max_size" in kwargs: - logger.warning_once( - "The `max_size` argument is deprecated and will be removed in a future version, use" - " `size['longest_edge']` instead." - ) - size = kwargs.pop("max_size") + logger.error("The `max_size` argument is deprecated, use" " `size['longest_edge']` instead.") + do_resize = self.do_resize if do_resize is None else do_resize size = self.size if size is None else size size = get_size_dict(size=size, default_to_square=False) diff --git a/src/transformers/models/grounding_dino/image_processing_grounding_dino.py b/src/transformers/models/grounding_dino/image_processing_grounding_dino.py index 928a6c91109cd6..a86999aefe9a18 100644 --- a/src/transformers/models/grounding_dino/image_processing_grounding_dino.py +++ b/src/transformers/models/grounding_dino/image_processing_grounding_dino.py @@ -883,9 +883,8 @@ def __init__( do_pad = kwargs.pop("pad_and_return_pixel_mask") if "max_size" in kwargs: - raise ValueError( - "The `max_size` parameter is deprecated. " - "Please specify in `size['longest_edge'] instead`.", + logger.error( + "The `max_size` parameter is deprecated. " "Please specify in `size['longest_edge'] instead`.", ) size = size if size is not None else {"shortest_edge": 800, "longest_edge": 1333} @@ -1016,9 +1015,8 @@ def resize( The channel dimension format of the input image. If not provided, it will be inferred. """ if "max_size" in kwargs: - raise ValueError( - "The `max_size` parameter is deprecated. " - "Please specify in `size['longest_edge'] instead`.", + logger.error( + "The `max_size` parameter is deprecated. " "Please specify in `size['longest_edge'] instead`.", ) size = get_size_dict(size, default_to_square=False) @@ -1368,10 +1366,7 @@ def preprocess( do_pad = kwargs.pop("pad_and_return_pixel_mask") if "max_size" in kwargs: - raise ValueError( - "The `max_size` argument is deprecated, use" - " `size['longest_edge']` instead." - ) + logger.error("The `max_size` argument is deprecated, use" " `size['longest_edge']` instead.") do_resize = self.do_resize if do_resize is None else do_resize size = self.size if size is None else size From b31dda0dd022e3c8a30a8187c0b7a5d96b636a60 Mon Sep 17 00:00:00 2001 From: Hich Tala <98521878+HichTala@users.noreply.github.com> Date: Wed, 4 Dec 2024 18:24:55 +0100 Subject: [PATCH 11/11] Reformatting --- .../image_processing_conditional_detr.py | 11 +++-------- .../image_processing_deformable_detr.py | 6 ++---- .../image_processing_deformable_detr_fast.py | 3 +-- src/transformers/models/detr/image_processing_detr.py | 11 +++-------- .../models/detr/image_processing_detr_fast.py | 8 ++------ .../models/rt_detr/image_processing_rt_detr.py | 3 +-- .../models/yolos/image_processing_yolos.py | 9 +++------ 7 files changed, 15 insertions(+), 36 deletions(-) diff --git a/src/transformers/models/conditional_detr/image_processing_conditional_detr.py b/src/transformers/models/conditional_detr/image_processing_conditional_detr.py index c2660c9216cbf4..a2c4537bc48731 100644 --- a/src/transformers/models/conditional_detr/image_processing_conditional_detr.py +++ b/src/transformers/models/conditional_detr/image_processing_conditional_detr.py @@ -878,8 +878,7 @@ def __init__( if "max_size" in kwargs: logger.error( - "The `max_size` parameter is deprecated. " - "Please specify in `size['longest_edge'] instead`.", + "The `max_size` parameter is deprecated. " "Please specify in `size['longest_edge'] instead`.", ) size = size if size is not None else {"shortest_edge": 800, "longest_edge": 1333} @@ -1011,8 +1010,7 @@ def resize( """ if "max_size" in kwargs: logger.error( - "The `max_size` parameter is deprecated. " - "Please specify in `size['longest_edge'] instead`.", + "The `max_size` parameter is deprecated. " "Please specify in `size['longest_edge'] instead`.", ) size = get_size_dict(size, default_to_square=False) @@ -1362,10 +1360,7 @@ def preprocess( do_pad = kwargs.pop("pad_and_return_pixel_mask") if "max_size" in kwargs: - logger.error( - "The `max_size` argument is deprecated, use" - " `size['longest_edge']` instead." - ) + logger.error("The `max_size` argument is deprecated, use" " `size['longest_edge']` instead.") do_resize = self.do_resize if do_resize is None else do_resize size = self.size if size is None else size diff --git a/src/transformers/models/deformable_detr/image_processing_deformable_detr.py b/src/transformers/models/deformable_detr/image_processing_deformable_detr.py index 84f842b8631e31..05c2d24e9db241 100644 --- a/src/transformers/models/deformable_detr/image_processing_deformable_detr.py +++ b/src/transformers/models/deformable_detr/image_processing_deformable_detr.py @@ -876,8 +876,7 @@ def __init__( if "max_size" in kwargs: logger.error( - "The `max_size` parameter is deprecated. " - "Please specify in `size['longest_edge'] instead`.", + "The `max_size` parameter is deprecated. " "Please specify in `size['longest_edge'] instead`.", ) size = size if size is not None else {"shortest_edge": 800, "longest_edge": 1333} @@ -1009,8 +1008,7 @@ def resize( """ if "max_size" in kwargs: logger.error( - "The `max_size` parameter is deprecated. " - "Please specify in `size['longest_edge'] instead`.", + "The `max_size` parameter is deprecated. " "Please specify in `size['longest_edge'] instead`.", ) size = get_size_dict(size, default_to_square=False) diff --git a/src/transformers/models/deformable_detr/image_processing_deformable_detr_fast.py b/src/transformers/models/deformable_detr/image_processing_deformable_detr_fast.py index 0644888622327d..283599263fb895 100644 --- a/src/transformers/models/deformable_detr/image_processing_deformable_detr_fast.py +++ b/src/transformers/models/deformable_detr/image_processing_deformable_detr_fast.py @@ -354,8 +354,7 @@ def __init__( if "max_size" in kwargs: logger.error( - "The `max_size` parameter is deprecated. " - "Please specify in `size['longest_edge'] instead`.", + "The `max_size` parameter is deprecated. " "Please specify in `size['longest_edge'] instead`.", ) size = size if size is not None else {"shortest_edge": 800, "longest_edge": 1333} diff --git a/src/transformers/models/detr/image_processing_detr.py b/src/transformers/models/detr/image_processing_detr.py index 82480fb7e03d8c..412bb0d218f881 100644 --- a/src/transformers/models/detr/image_processing_detr.py +++ b/src/transformers/models/detr/image_processing_detr.py @@ -860,8 +860,7 @@ def __init__( if "max_size" in kwargs: logger.error( - "The `max_size` parameter is deprecated. " - "Please specify in `size['longest_edge'] instead`.", + "The `max_size` parameter is deprecated. " "Please specify in `size['longest_edge'] instead`.", ) size = size if size is not None else {"shortest_edge": 800, "longest_edge": 1333} @@ -990,8 +989,7 @@ def resize( """ if "max_size" in kwargs: logger.error( - "The `max_size` parameter is deprecated. " - "Please specify in `size['longest_edge'] instead`.", + "The `max_size` parameter is deprecated. " "Please specify in `size['longest_edge'] instead`.", ) size = get_size_dict(size, default_to_square=False) @@ -1335,10 +1333,7 @@ def preprocess( do_pad = kwargs.pop("pad_and_return_pixel_mask") if "max_size" in kwargs: - logger.error( - "The `max_size` argument is deprecated, use" - " `size['longest_edge']` instead." - ) + logger.error("The `max_size` argument is deprecated, use" " `size['longest_edge']` instead.") do_resize = self.do_resize if do_resize is None else do_resize size = self.size if size is None else size diff --git a/src/transformers/models/detr/image_processing_detr_fast.py b/src/transformers/models/detr/image_processing_detr_fast.py index 0ca645cde243fa..323bea2239a758 100644 --- a/src/transformers/models/detr/image_processing_detr_fast.py +++ b/src/transformers/models/detr/image_processing_detr_fast.py @@ -363,8 +363,7 @@ def __init__( if "max_size" in kwargs: logger.error( - "The `max_size` parameter is deprecated. " - "Please specify in `size['longest_edge'] instead`.", + "The `max_size` parameter is deprecated. " "Please specify in `size['longest_edge'] instead`.", ) size = size if size is not None else {"shortest_edge": 800, "longest_edge": 1333} @@ -778,10 +777,7 @@ def preprocess( do_pad = kwargs.pop("pad_and_return_pixel_mask") if "max_size" in kwargs: - logger.error( - "The `max_size` argument is deprecated, use" - " `size['longest_edge']` instead." - ) + logger.error("The `max_size` argument is deprecated, use" " `size['longest_edge']` instead.") do_resize = self.do_resize if do_resize is None else do_resize size = self.size if size is None else size diff --git a/src/transformers/models/rt_detr/image_processing_rt_detr.py b/src/transformers/models/rt_detr/image_processing_rt_detr.py index 815b13793cba4b..e4bb86203b9451 100644 --- a/src/transformers/models/rt_detr/image_processing_rt_detr.py +++ b/src/transformers/models/rt_detr/image_processing_rt_detr.py @@ -534,8 +534,7 @@ def resize( """ if "max_size" in kwargs: logger.error( - "The `max_size` parameter is deprecated. " - "Please specify in `size['longest_edge'] instead`.", + "The `max_size` parameter is deprecated. " "Please specify in `size['longest_edge'] instead`.", ) size = get_size_dict(size, default_to_square=False) diff --git a/src/transformers/models/yolos/image_processing_yolos.py b/src/transformers/models/yolos/image_processing_yolos.py index 1c5059cf440108..5d3b20e04f0a92 100644 --- a/src/transformers/models/yolos/image_processing_yolos.py +++ b/src/transformers/models/yolos/image_processing_yolos.py @@ -792,8 +792,7 @@ def __init__( if "max_size" in kwargs: logger.error( - "The `max_size` parameter is deprecated. " - "Please specify in `size['longest_edge'] instead`.", + "The `max_size` parameter is deprecated. " "Please specify in `size['longest_edge'] instead`.", ) size = size if size is not None else {"shortest_edge": 800, "longest_edge": 1333} @@ -925,8 +924,7 @@ def resize( """ if "max_size" in kwargs: logger.error( - "The `max_size` parameter is deprecated. " - "Please specify in `size['longest_edge'] instead`.", + "The `max_size` parameter is deprecated. " "Please specify in `size['longest_edge'] instead`.", ) size = get_size_dict(size, default_to_square=False) @@ -1273,8 +1271,7 @@ def preprocess( if "max_size" in kwargs: logger.error( - "The `max_size` argument is deprecated, use" - " `size['longest_edge']` instead.", + "The `max_size` argument is deprecated, use" " `size['longest_edge']` instead.", ) do_resize = self.do_resize if do_resize is None else do_resize