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

Unused or unrecognized kwargs: padding, max_length, truncation. #30106

Closed
4 tasks
Excuses123 opened this issue Apr 8, 2024 · 7 comments · Fixed by #30193
Closed
4 tasks

Unused or unrecognized kwargs: padding, max_length, truncation. #30106

Excuses123 opened this issue Apr 8, 2024 · 7 comments · Fixed by #30193
Assignees

Comments

@Excuses123
Copy link

System Info

  • transformers version: 4.39.2
  • Platform: Linux-3.10.0-1160.99.1.el7.x86_64-x86_64-with-glibc2.31
  • Python version: 3.10.13
  • Huggingface_hub version: 0.22.2
  • Safetensors version: 0.4.2
  • Accelerate version: not installed
  • Accelerate config: not found
  • PyTorch version (GPU?): 2.0.1+cu117 (True)
  • Tensorflow version (GPU?): not installed (NA)
  • Flax version (CPU?/GPU?/TPU?): not installed (NA)
  • Jax version: not installed
  • JaxLib version: not installed
  • Using GPU in script?:
  • Using distributed or parallel set-up in script?:

Who can help?

No response

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

Fine-tuning the CLIP model. Previously, I passed both text and images to the processor and specified some parameters for the text: padding, max_length, truncation. Everything was working fine before upgrading to version 4.39. However, after the upgrade, I encountered a warning that affects the training process. How should I resolve this?
image

Expected behavior

Do I need to separate the text and images for processing and use processor.tokenizer and processor.image_processor separately?

@kuri54
Copy link

kuri54 commented Apr 8, 2024

Same problem is occurring.
Downgrading to 4.38.2 will solve the problem.

@hda-xian
Copy link

hda-xian commented Apr 8, 2024

Meet the same problem

@amyeroberts
Copy link
Collaborator

Hi @Excuses123, thanks for raising this issue!

Could you share a minimal reproducer?

@hda-xian
Copy link

hda-xian commented Apr 8, 2024 via email

@Excuses123
Copy link
Author

Hi @Excuses123, thanks for raising this issue!

Could you share a minimal reproducer?

Hello, here is a minimal reproducible example.

import torch
import requests
from PIL import Image
from transformers import AutoProcessor

processor = AutoProcessor.from_pretrained("openai/clip-vit-large-patch14-336")

url = "http://images.cocodataset.org/val2017/000000039769.jpg"
image = Image.open(requests.get(url, stream=True).raw)

processor(text="a photo of a cat",
images=image,
max_length=64,
padding='max_length',
truncation=True,
return_tensors='pt')

@amyeroberts
Copy link
Collaborator

Thanks for sharing @Excuses123. The warnings have started because of new input validation on the image processor. This is good as it shows tokenizer kwargs were being passed to the image processor when they shouldn't be! I've opened a PR to address this

@hda-xian
Copy link

just to Change code
for the /your paht**/transformers/models/clip/processing_clip.py
function : def call(self, text=None, images=None, return_tensors=None, **kwargs):
line: 104 image_features = self.image_processor(images, return_tensors=return_tensors, **kwargs)
the new code : -> image_features = self.image_processor(images, return_tensors=return_tensors) # delete the others kwargs

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.

4 participants