Error finding processor's image class. Loading based on pattern matching with feature extractor
Not sure where this warning is coming from or how to address it. Using the DONUT model. Full message belowCould 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.
2023-02-20T02:17:37Z
Same here, would love to know the answer
2023-02-21T10:21:36Z
I am using TrOCRProcessor and giving the same messageCould 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.
2023-02-26T11:43:03Z
Getting the same error using Swin Transformers
2023-03-27T07:42:41Z
Getting the same error while using facebook/detr-resnet-50.Was anyone able to solve it?
2023-03-27T11:22:08Z
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 fromtest. I guess you won’t see this line then.
2023-03-27T11:58:35Z
cc@amyeroberts
2023-04-03T07:31:28Z
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.
2023-04-05T10:18:08Z
Hi everyone, thanks for reporting about this.The 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.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 configurationspecifiesViTFeatureExtractor. 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 tologger.infomight be a suitable option. Please do share if you have alternative suggestions e.g. alternative warning message to make it clearer.
2023-04-05T17:37:28Z
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.
2023-08-19T05:44:11Z
As mentionedHEREusing a different version oftransformers==4.28.0helped for Swin Transformers,
2023-10-27T14:26:47Z
I don’t know if this helps you anymore bc. time has passed on. But - if you’d like to update custom model preprocessor_config.json - files to the latest expected image_processor - object notation, then you can simply replace the “feature_extractor_type” by “image_processor_type” in the respective config-file. For your example (DONUT), the new preprocessor_config.json would now read as: “image_processor_type”: “DonutImageProcessor” at the line previously filled with the “feature_extractor_type” – description.HTH!