[Trainer] Allow passing image processor#29896
Conversation
|
The docs for this PR live here. All of your documentation changes will be reflected on that endpoint. The docs are available until 30 days after the last update. |
| self.place_model_on_device = False | ||
|
|
||
| default_collator = default_data_collator if tokenizer is None else DataCollatorWithPadding(tokenizer) | ||
| default_collator = DataCollatorWithPadding(tokenizer) if tokenizer is not None else default_data_collator |
There was a problem hiding this comment.
might not be BC if people pass a ImageProcessor. Let's deprecate passing image processors checking the type
There was a problem hiding this comment.
If people currently pass an image processor as tokenizer, then they need to pass a data collator as otherwise they'll hit the issue mentioned at #29790 (as image processors typically don't have a pad method). So it doesn't break backwards
|
Can we add enabling passing a feature_extractor and processor too? |
|
@ArthurZucker feel free to approve the PR, @amyeroberts I would add those in a separate PR |
ArthurZucker
left a comment
There was a problem hiding this comment.
Okay, let's do a followup PR then for feature processor and else
|
cc @NielsRogge @tomaarsen the addition of the new param to |
|
self.callback_handler = CallbackHandler(callbacks, self.model, self.model.model_body.tokenizer, None, None, None)
useful, waiting... |
self.callback_handler = CallbackHandler(callbacks, self.model, self.model.model_body.tokenizer, None, None, None) |
|
@NielsRogge @ArthurZucker For Preprocessing classes. Suggest modifying the tokenizer parameter name instead of adding parameters. Consider changing tokenizer to processors. |
|
Yes @chenin-wang I was also considering this, rather than having various attributes for tokenizer, image processor, feature extractor and multimodal processor it probably makes more sense to just have a single argument called Will await opinion of Arthur and Amy |
You are right. Will change user habits. |
|
Reflecting more on this, I think the best way is to have a proper deprecation message. Basically now whenever people pass the => this way people can safely update their code without having breaking changes from the start. Will open a follow-up PR for this. |
|
@NielsRogge @amyeroberts The problem remains. #30102 (comment) |
|
Hi @chenin-wang could you clarify your issue? |
|
@NielsRogge tokenizer=image_processor is a confusing API (as highlighted by a few issues from users) and considering we have more and more multimodal, audio and vision models increasingly out-of-date,what amyeroberts saied #30102 (comment). |
|
Yes @chenin-wang I agree. So indeed we should continue with #30102. However I'm thinking about the term Not sure if people prefer Hence I'll ask the question to some HF members and see which term they prefer. Will then proceed. |
What does this PR do?
Fixes #29790. Also reported here: https://discuss.huggingface.co/t/vitimageprocessor-object-has-no-attribute-pad/32511.
Currently, passing an image processor to the Trainer is pretty hacky, as users need to do
tokenizer=image_processor. 🤔 yes, that's right.This PR adds the
image_processorargument to the Trainer, such that the default data collator is used by default in case an image processor is passed.To do: