Not sure where this warning is coming from or how to address it. Using the DONUT model. Full message below
Could not find image processor class in the image processor config or the model config. Loading based on pattern matching with the model's feature extractor configuration.
/opt/miniconda3/envs/donut/lib/python3.10/site-packages/transformers/models/donut/processing_donut.py:186: FutureWarning: `feature_extractor` is deprecated and will be removed in v5. Use `image_processor` instead.
I am using TrOCRProcessor and giving the same message Could not find image processor class in the image processor config or the model config. Loading based on pattern matching with the model's feature extractor configuration.
I think this has something to do with processor. While saving the model weights you are supposed to save the config related files as well. so don’t forget to do this:
processor = TrOCRProcessor.from_pretrained("microsoft/trocr-base-printed")
model = VisionEncoderDecoderModel.from_pretrained("microsoft/trocr-base-printed")
# do some config changes...
# train or whatever
processor.save_pretrained('test')
model.save_pretrained('test')
and then load it from test. I guess you won’t see this line then.
Was able to suppress the warning using transformers.utils.logging.set_verbosity_error()
Not sure how to actually the solve the issue so that warning isn’t generated in the first place.
Could not find image processor class in the image processor config or the model config. Loading based on pattern matching with the model's feature extractor configuration.
is being shown, because the image processor to load is being inferred from a config which specifies a feature extractor. Feature extractors are now deprecated for vision models. For example, this swin configuration specifies ViTFeatureExtractor. The warning is there as there isn’t a guarantee the correct image processor class will be loaded.
The inference of the image processor from the feature extractor name is done, as this allows for a smooth deprecation cycle of the feature extractors, where older configs can be used without breaking changes.
We realise that the warning message can be both concerning and overly aggressive. Its visibility was in part to make explicit the deprecation and encourage the update of custom checkpoint configurations. We’re trying to find the right balance between warning now loudly vs. more silent but possibly unexpected behaviour later. For many public configs it’s not something an individual user would be able to update at the moment, and so downgrading to logger.info might be a suitable option. Please do share if you have alternative suggestions e.g. alternative warning message to make it clearer.
What is the recommendation to update the config.json file to avoid such a warning? I would tend to agree with your point that using public models takes away the user’s control subdue the warning. Info might be more appropriate.