Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Deprecation Warning for max_size in DetrImageProcessor.preprocess #34977

Open
2 of 4 tasks
HichTala opened this issue Nov 27, 2024 · 1 comment · May be fixed by #34998
Open
2 of 4 tasks

Deprecation Warning for max_size in DetrImageProcessor.preprocess #34977

HichTala opened this issue Nov 27, 2024 · 1 comment · May be fixed by #34998

Comments

@HichTala
Copy link

System Info

  • transformers version: 4.47.0.dev0
  • Platform: Linux-5.15.0-126-generic-x86_64-with-glibc2.31
  • Python version: 3.11.0
  • Huggingface_hub version: 0.24.5
  • Safetensors version: 0.4.4
  • Accelerate version: 1.1.1
  • Accelerate config: not found
  • PyTorch version (GPU?): 2.1.2+cu118 (True)
  • Tensorflow version (GPU?): not installed (NA)
  • Flax version (CPU?/GPU?/TPU?): not installed (NA)
  • Jax version: not installed
  • JaxLib version: not installed
  • Using distributed or parallel set-up in script?:
  • Using GPU in script?:
  • GPU type: NVIDIA GeForce RTX 3090

Who can help?

@amyeroberts, @qubvel
and I think @NielsRogge worked on it too ?

Information

  • The official example scripts
  • My own modified scripts

Tasks

  • An officially supported task in the examples folder (such as GLUE/SQuAD, ...)
  • My own task or dataset (give details below)

Reproduction

import logging

import numpy as np
from transformers.models.detr.image_processing_detr import DetrImageProcessor

logging.basicConfig(level=logging.WARNING)
logger = logging.getLogger(__name__)

images = [np.ones((512, 512, 3))]
annotations = [{'image_id': [], 'annotations': []}]
size = {'max_height': 600, 'max_width': 600}

image_processor = DetrImageProcessor()
images = image_processor.preprocess(images, do_resize=True, do_rescale=False, size=size, annotations=annotations, format='coco_detection')

Expected behavior

Hello!

I noticed that the preprocess method in the DetrImageProcessor class always passes max_size to the resize method,

resized_image = self.resize(
image, size=size, max_size=max_size, resample=resample, input_data_format=input_data_format
)

and that triggers a deprecation warning in resize method,

The `max_size` parameter is deprecated and will be removed in v4.26. Please specify in `size['longest_edge'] instead`.

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")

I propose removing the unused max_size argument from the preprocess method since it is always None,

Would it be okay if I work on this and submit a pull request? I can try to see if the problem also occurs in other models.

@HichTala HichTala added the bug label Nov 27, 2024
@qubvel
Copy link
Member

qubvel commented Nov 27, 2024

Hi @HichTala! Nice catch, would appreciate a PR!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants