# Error finding processor's image class. Loading based on pattern matching with feature extractor

**URL:** <https://discuss.huggingface.co/t/error-finding-processors-image-class-loading-based-on-pattern-matching-with-feature-extractor/31890>\
**Category:** 🤗Transformers\
**Created:** [February 17, 2023, 6:31am UTC](https://discuss.huggingface.co/t/error-finding-processors-image-class-loading-based-on-pattern-matching-with-feature-extractor/31890 "2023-02-17T06:31:47Z")\
**Posts on this page:** 12\
**Page:** 1

<div class="post-metadata">

**Author:** ![alecstash](https://sea2.discourse-cdn.com/hellohellohello/user_avatar/discuss.huggingface.co/alecstash/32/14195_2.png) [@alecstash](https://discuss.huggingface.co/u/alecstash)\
**Post date:** [February 17, 2023, 6:31am UTC](https://discuss.huggingface.co/t/error-finding-processors-image-class-loading-based-on-pattern-matching-with-feature-extractor/31890/1 "2023-02-17T06:31:47Z")

</div>

Not sure where this warning is coming from or how to address it. Using the DONUT model. Full message below

```auto
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.

```

---

<div class="post-metadata">

**Author:** ![reletreby90](https://avatars.discourse-cdn.com/v4/letter/r/41988e/32.png) [@reletreby90](https://discuss.huggingface.co/u/reletreby90)\
**Post date:** [February 20, 2023, 2:17am UTC](https://discuss.huggingface.co/t/error-finding-processors-image-class-loading-based-on-pattern-matching-with-feature-extractor/31890/2 "2023-02-20T02:17:37Z")

</div>

Same here, would love to know the answer

---

<div class="post-metadata">

**Author:** ![kchandanssm](https://avatars.discourse-cdn.com/v4/letter/k/439d5e/32.png) [@kchandanssm](https://discuss.huggingface.co/u/kchandanssm)\
**Post date:** [February 21, 2023, 10:21am UTC](https://discuss.huggingface.co/t/error-finding-processors-image-class-loading-based-on-pattern-matching-with-feature-extractor/31890/3 "2023-02-21T10:21:36Z")

</div>

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.`

---

<div class="post-metadata">

**Author:** ![Shuaf98](https://avatars.discourse-cdn.com/v4/letter/s/7c8e57/32.png) [@Shuaf98](https://discuss.huggingface.co/u/Shuaf98)\
**Post date:** [February 26, 2023, 11:43am UTC](https://discuss.huggingface.co/t/error-finding-processors-image-class-loading-based-on-pattern-matching-with-feature-extractor/31890/4 "2023-02-26T11:43:03Z")

</div>

Getting the same error using Swin Transformers

---

<div class="post-metadata">

**Author:** ![ujjawalchugh97](https://avatars.discourse-cdn.com/v4/letter/u/f4b2a3/32.png) [@ujjawalchugh97](https://discuss.huggingface.co/u/ujjawalchugh97)\
**Post date:** [March 27, 2023, 7:42am UTC](https://discuss.huggingface.co/t/error-finding-processors-image-class-loading-based-on-pattern-matching-with-feature-extractor/31890/5 "2023-03-27T07:42:41Z")

</div>

Getting the same error while using facebook/detr-resnet-50.  
Was anyone able to solve it?

---

<div class="post-metadata">

**Author:** ![tranquilkd](https://avatars.discourse-cdn.com/v4/letter/t/77aa72/32.png) [@tranquilkd](https://discuss.huggingface.co/u/tranquilkd)\
**Post date:** [March 27, 2023, 11:22am UTC](https://discuss.huggingface.co/t/error-finding-processors-image-class-loading-based-on-pattern-matching-with-feature-extractor/31890/6 "2023-03-27T11:22:08Z")

</div>

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:

```auto
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.

---

<div class="post-metadata">

**Author:** ![nielsr](https://sea2.discourse-cdn.com/hellohellohello/user_avatar/discuss.huggingface.co/nielsr/32/39617_2.png) [@nielsr](https://discuss.huggingface.co/u/nielsr)\
**Post date:** [March 27, 2023, 11:58am UTC](https://discuss.huggingface.co/t/error-finding-processors-image-class-loading-based-on-pattern-matching-with-feature-extractor/31890/7 "2023-03-27T11:58:35Z")

</div>

cc @amyeroberts

---

<div class="post-metadata">

**Author:** ![ujjawalchugh97](https://avatars.discourse-cdn.com/v4/letter/u/f4b2a3/32.png) [@ujjawalchugh97](https://discuss.huggingface.co/u/ujjawalchugh97)\
**Post date:** [April 3, 2023, 7:31am UTC](https://discuss.huggingface.co/t/error-finding-processors-image-class-loading-based-on-pattern-matching-with-feature-extractor/31890/8 "2023-04-03T07:31:28Z")

</div>

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.

---

<div class="post-metadata">

**Author:** ![amyeroberts](https://sea2.discourse-cdn.com/hellohellohello/user_avatar/discuss.huggingface.co/amyeroberts/32/22223_2.png) [@amyeroberts](https://discuss.huggingface.co/u/amyeroberts)\
**Post date:** [April 5, 2023, 10:18am UTC](https://discuss.huggingface.co/t/error-finding-processors-image-class-loading-based-on-pattern-matching-with-feature-extractor/31890/9 "2023-04-05T10:18:08Z")

</div>

Hi everyone, thanks for reporting about this.

The message:

```auto
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](https://huggingface.co/microsoft/swin-large-patch4-window12-384-in22k/blob/df0f89cc75d470a35ff4bb5d0e53fbdbbe377bb3/preprocessor_config.json#L4) 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.

---

<div class="post-metadata">

**Author:** ![alecstash](https://sea2.discourse-cdn.com/hellohellohello/user_avatar/discuss.huggingface.co/alecstash/32/14195_2.png) [@alecstash](https://discuss.huggingface.co/u/alecstash)\
**Post date:** [April 5, 2023, 5:37pm UTC](https://discuss.huggingface.co/t/error-finding-processors-image-class-loading-based-on-pattern-matching-with-feature-extractor/31890/10 "2023-04-05T17:37:28Z")

</div>

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.

---

<div class="post-metadata">

**Author:** ![ThankGod](https://sea2.discourse-cdn.com/hellohellohello/user_avatar/discuss.huggingface.co/thankgod/32/18683_2.png) [@ThankGod](https://discuss.huggingface.co/u/ThankGod)\
**Post date:** [August 19, 2023, 5:44am UTC](https://discuss.huggingface.co/t/error-finding-processors-image-class-loading-based-on-pattern-matching-with-feature-extractor/31890/11 "2023-08-19T05:44:11Z")

</div>

As mentioned [HERE](https://discuss.huggingface.co/t/trainingargument/39929/2) using a different version of `transformers==4.28.0` helped for Swin Transformers,

---

<div class="post-metadata">

**Author:** ![mxl417](https://avatars.discourse-cdn.com/v4/letter/m/2acd7d/32.png) [@mxl417](https://discuss.huggingface.co/u/mxl417)\
**Post date:** [October 27, 2023, 2:26pm UTC](https://discuss.huggingface.co/t/error-finding-processors-image-class-loading-based-on-pattern-matching-with-feature-extractor/31890/12 "2023-10-27T14:26:47Z")

</div>

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!
