# AutoImageProcessor

### AutoImageProcessor

#### class transformers.AutoImageProcessor

[\<source>](https://github.com/huggingface/transformers/blob/v4.34.1/src/transformers/models/auto/image_processing_auto.py#L243)

( )

This is a generic image processor class that will be instantiated as one of the image processor classes of the library when created with the [AutoImageProcessor.from\_pretrained()](https://huggingface.co/docs/transformers/v4.34.1/en/model_doc/auto#transformers.AutoImageProcessor.from_pretrained) class method.

This class cannot be instantiated directly using `__init__()` (throws an error).

**from\_pretrained**

[\<source>](https://github.com/huggingface/transformers/blob/v4.34.1/src/transformers/models/auto/image_processing_auto.py#L257)

( pretrained\_model\_name\_or\_path\*\*kwargs )

Parameters

* **pretrained\_model\_name\_or\_path** (`str` or `os.PathLike`) — This can be either:
  * a string, the *model id* of a pretrained image\_processor hosted inside a model repo on huggingface.co. Valid model ids can be located at the root-level, like `bert-base-uncased`, or namespaced under a user or organization name, like `dbmdz/bert-base-german-cased`.
  * a path to a *directory* containing a image processor file saved using the [save\_pretrained()](https://huggingface.co/docs/transformers/v4.34.1/en/main_classes/image_processor#transformers.ImageProcessingMixin.save_pretrained) method, e.g., `./my_model_directory/`.
  * a path or url to a saved image processor JSON *file*, e.g., `./my_model_directory/preprocessor_config.json`.
* **cache\_dir** (`str` or `os.PathLike`, *optional*) — Path to a directory in which a downloaded pretrained model image processor should be cached if the standard cache should not be used.
* **force\_download** (`bool`, *optional*, defaults to `False`) — Whether or not to force to (re-)download the image processor files and override the cached versions if they exist.
* **resume\_download** (`bool`, *optional*, defaults to `False`) — Whether or not to delete incompletely received file. Attempts to resume the download if such a file exists.
* **proxies** (`Dict[str, str]`, *optional*) — A dictionary of proxy servers to use by protocol or endpoint, e.g., `{'http': 'foo.bar:3128', 'http://hostname': 'foo.bar:4012'}.` The proxies are used on each request.
* **token** (`str` or *bool*, *optional*) — The token to use as HTTP bearer authorization for remote files. If `True`, will use the token generated when running `huggingface-cli login` (stored in `~/.huggingface`).
* **revision** (`str`, *optional*, defaults to `"main"`) — The specific model version to use. It can be a branch name, a tag name, or a commit id, since we use a git-based system for storing models and other artifacts on huggingface.co, so `revision` can be any identifier allowed by git.
* **return\_unused\_kwargs** (`bool`, *optional*, defaults to `False`) — If `False`, then this function returns just the final image processor object. If `True`, then this functions returns a `Tuple(image_processor, unused_kwargs)` where *unused\_kwargs* is a dictionary consisting of the key/value pairs whose keys are not image processor attributes: i.e., the part of `kwargs` which has not been used to update `image_processor` and is otherwise ignored.
* **trust\_remote\_code** (`bool`, *optional*, defaults to `False`) — Whether or not to allow for custom models defined on the Hub in their own modeling files. This option should only be set to `True` for repositories you trust and in which you have read the code, as it will execute code present on the Hub on your local machine.
* **kwargs** (`Dict[str, Any]`, *optional*) — The values in kwargs of any keys which are image processor attributes will be used to override the loaded values. Behavior concerning key/value pairs whose keys are *not* image processor attributes is controlled by the `return_unused_kwargs` keyword parameter.

Instantiate one of the image processor classes of the library from a pretrained model vocabulary.

The image processor class to instantiate is selected based on the `model_type` property of the config object (either passed as an argument or loaded from `pretrained_model_name_or_path` if possible), or when it’s missing, by falling back to using pattern matching on `pretrained_model_name_or_path`:

* **align** — [EfficientNetImageProcessor](https://huggingface.co/docs/transformers/v4.34.1/en/model_doc/efficientnet#transformers.EfficientNetImageProcessor) (ALIGN model)
* **beit** — [BeitImageProcessor](https://huggingface.co/docs/transformers/v4.34.1/en/model_doc/beit#transformers.BeitImageProcessor) (BEiT model)
* **bit** — [BitImageProcessor](https://huggingface.co/docs/transformers/v4.34.1/en/model_doc/bit#transformers.BitImageProcessor) (BiT model)
* **blip** — [BlipImageProcessor](https://huggingface.co/docs/transformers/v4.34.1/en/model_doc/blip#transformers.BlipImageProcessor) (BLIP model)
* **blip-2** — [BlipImageProcessor](https://huggingface.co/docs/transformers/v4.34.1/en/model_doc/blip#transformers.BlipImageProcessor) (BLIP-2 model)
* **bridgetower** — [BridgeTowerImageProcessor](https://huggingface.co/docs/transformers/v4.34.1/en/model_doc/bridgetower#transformers.BridgeTowerImageProcessor) (BridgeTower model)
* **chinese\_clip** — [ChineseCLIPImageProcessor](https://huggingface.co/docs/transformers/v4.34.1/en/model_doc/chinese_clip#transformers.ChineseCLIPImageProcessor) (Chinese-CLIP model)
* **clip** — [CLIPImageProcessor](https://huggingface.co/docs/transformers/v4.34.1/en/model_doc/clip#transformers.CLIPImageProcessor) (CLIP model)
* **clipseg** — [ViTImageProcessor](https://huggingface.co/docs/transformers/v4.34.1/en/model_doc/vit#transformers.ViTImageProcessor) (CLIPSeg model)
* **conditional\_detr** — [ConditionalDetrImageProcessor](https://huggingface.co/docs/transformers/v4.34.1/en/model_doc/conditional_detr#transformers.ConditionalDetrImageProcessor) (Conditional DETR model)
* **convnext** — [ConvNextImageProcessor](https://huggingface.co/docs/transformers/v4.34.1/en/model_doc/convnext#transformers.ConvNextImageProcessor) (ConvNeXT model)
* **convnextv2** — [ConvNextImageProcessor](https://huggingface.co/docs/transformers/v4.34.1/en/model_doc/convnext#transformers.ConvNextImageProcessor) (ConvNeXTV2 model)
* **cvt** — [ConvNextImageProcessor](https://huggingface.co/docs/transformers/v4.34.1/en/model_doc/convnext#transformers.ConvNextImageProcessor) (CvT model)
* **data2vec-vision** — [BeitImageProcessor](https://huggingface.co/docs/transformers/v4.34.1/en/model_doc/beit#transformers.BeitImageProcessor) (Data2VecVision model)
* **deformable\_detr** — [DeformableDetrImageProcessor](https://huggingface.co/docs/transformers/v4.34.1/en/model_doc/deformable_detr#transformers.DeformableDetrImageProcessor) (Deformable DETR model)
* **deit** — [DeiTImageProcessor](https://huggingface.co/docs/transformers/v4.34.1/en/model_doc/deit#transformers.DeiTImageProcessor) (DeiT model)
* **deta** — [DetaImageProcessor](https://huggingface.co/docs/transformers/v4.34.1/en/model_doc/deta#transformers.DetaImageProcessor) (DETA model)
* **detr** — [DetrImageProcessor](https://huggingface.co/docs/transformers/v4.34.1/en/model_doc/detr#transformers.DetrImageProcessor) (DETR model)
* **dinat** — [ViTImageProcessor](https://huggingface.co/docs/transformers/v4.34.1/en/model_doc/vit#transformers.ViTImageProcessor) (DiNAT model)
* **dinov2** — [BitImageProcessor](https://huggingface.co/docs/transformers/v4.34.1/en/model_doc/bit#transformers.BitImageProcessor) (DINOv2 model)
* **donut-swin** — [DonutImageProcessor](https://huggingface.co/docs/transformers/v4.34.1/en/model_doc/donut#transformers.DonutImageProcessor) (DonutSwin model)
* **dpt** — [DPTImageProcessor](https://huggingface.co/docs/transformers/v4.34.1/en/model_doc/dpt#transformers.DPTImageProcessor) (DPT model)
* **efficientformer** — [EfficientFormerImageProcessor](https://huggingface.co/docs/transformers/v4.34.1/en/model_doc/efficientformer#transformers.EfficientFormerImageProcessor) (EfficientFormer model)
* **efficientnet** — [EfficientNetImageProcessor](https://huggingface.co/docs/transformers/v4.34.1/en/model_doc/efficientnet#transformers.EfficientNetImageProcessor) (EfficientNet model)
* **flava** — [FlavaImageProcessor](https://huggingface.co/docs/transformers/v4.34.1/en/model_doc/flava#transformers.FlavaImageProcessor) (FLAVA model)
* **focalnet** — [BitImageProcessor](https://huggingface.co/docs/transformers/v4.34.1/en/model_doc/bit#transformers.BitImageProcessor) (FocalNet model)
* **git** — [CLIPImageProcessor](https://huggingface.co/docs/transformers/v4.34.1/en/model_doc/clip#transformers.CLIPImageProcessor) (GIT model)
* **glpn** — [GLPNImageProcessor](https://huggingface.co/docs/transformers/v4.34.1/en/model_doc/glpn#transformers.GLPNImageProcessor) (GLPN model)
* **groupvit** — [CLIPImageProcessor](https://huggingface.co/docs/transformers/v4.34.1/en/model_doc/clip#transformers.CLIPImageProcessor) (GroupViT model)
* **idefics** — [IdeficsImageProcessor](https://huggingface.co/docs/transformers/v4.34.1/en/model_doc/idefics#transformers.IdeficsImageProcessor) (IDEFICS model)
* **imagegpt** — [ImageGPTImageProcessor](https://huggingface.co/docs/transformers/v4.34.1/en/model_doc/imagegpt#transformers.ImageGPTImageProcessor) (ImageGPT model)
* **instructblip** — [BlipImageProcessor](https://huggingface.co/docs/transformers/v4.34.1/en/model_doc/blip#transformers.BlipImageProcessor) (InstructBLIP model)
* **layoutlmv2** — [LayoutLMv2ImageProcessor](https://huggingface.co/docs/transformers/v4.34.1/en/model_doc/layoutlmv2#transformers.LayoutLMv2ImageProcessor) (LayoutLMv2 model)
* **layoutlmv3** — [LayoutLMv3ImageProcessor](https://huggingface.co/docs/transformers/v4.34.1/en/model_doc/layoutlmv3#transformers.LayoutLMv3ImageProcessor) (LayoutLMv3 model)
* **levit** — [LevitImageProcessor](https://huggingface.co/docs/transformers/v4.34.1/en/model_doc/levit#transformers.LevitImageProcessor) (LeViT model)
* **mask2former** — [Mask2FormerImageProcessor](https://huggingface.co/docs/transformers/v4.34.1/en/model_doc/mask2former#transformers.Mask2FormerImageProcessor) (Mask2Former model)
* **maskformer** — [MaskFormerImageProcessor](https://huggingface.co/docs/transformers/v4.34.1/en/model_doc/maskformer#transformers.MaskFormerImageProcessor) (MaskFormer model)
* **mgp-str** — [ViTImageProcessor](https://huggingface.co/docs/transformers/v4.34.1/en/model_doc/vit#transformers.ViTImageProcessor) (MGP-STR model)
* **mobilenet\_v1** — [MobileNetV1ImageProcessor](https://huggingface.co/docs/transformers/v4.34.1/en/model_doc/mobilenet_v1#transformers.MobileNetV1ImageProcessor) (MobileNetV1 model)
* **mobilenet\_v2** — [MobileNetV2ImageProcessor](https://huggingface.co/docs/transformers/v4.34.1/en/model_doc/mobilenet_v2#transformers.MobileNetV2ImageProcessor) (MobileNetV2 model)
* **mobilevit** — [MobileViTImageProcessor](https://huggingface.co/docs/transformers/v4.34.1/en/model_doc/mobilevit#transformers.MobileViTImageProcessor) (MobileViT model)
* **mobilevitv2** — [MobileViTImageProcessor](https://huggingface.co/docs/transformers/v4.34.1/en/model_doc/mobilevit#transformers.MobileViTImageProcessor) (MobileViTV2 model)
* **nat** — [ViTImageProcessor](https://huggingface.co/docs/transformers/v4.34.1/en/model_doc/vit#transformers.ViTImageProcessor) (NAT model)
* **nougat** — [NougatImageProcessor](https://huggingface.co/docs/transformers/v4.34.1/en/model_doc/nougat#transformers.NougatImageProcessor) (Nougat model)
* **oneformer** — [OneFormerImageProcessor](https://huggingface.co/docs/transformers/v4.34.1/en/model_doc/oneformer#transformers.OneFormerImageProcessor) (OneFormer model)
* **owlvit** — [OwlViTImageProcessor](https://huggingface.co/docs/transformers/v4.34.1/en/model_doc/owlvit#transformers.OwlViTImageProcessor) (OWL-ViT model)
* **perceiver** — [PerceiverImageProcessor](https://huggingface.co/docs/transformers/v4.34.1/en/model_doc/perceiver#transformers.PerceiverImageProcessor) (Perceiver model)
* **pix2struct** — [Pix2StructImageProcessor](https://huggingface.co/docs/transformers/v4.34.1/en/model_doc/pix2struct#transformers.Pix2StructImageProcessor) (Pix2Struct model)
* **poolformer** — [PoolFormerImageProcessor](https://huggingface.co/docs/transformers/v4.34.1/en/model_doc/poolformer#transformers.PoolFormerImageProcessor) (PoolFormer model)
* **pvt** — [PvtImageProcessor](https://huggingface.co/docs/transformers/v4.34.1/en/model_doc/pvt#transformers.PvtImageProcessor) (PVT model)
* **regnet** — [ConvNextImageProcessor](https://huggingface.co/docs/transformers/v4.34.1/en/model_doc/convnext#transformers.ConvNextImageProcessor) (RegNet model)
* **resnet** — [ConvNextImageProcessor](https://huggingface.co/docs/transformers/v4.34.1/en/model_doc/convnext#transformers.ConvNextImageProcessor) (ResNet model)
* **sam** — [SamImageProcessor](https://huggingface.co/docs/transformers/v4.34.1/en/model_doc/sam#transformers.SamImageProcessor) (SAM model)
* **segformer** — [SegformerImageProcessor](https://huggingface.co/docs/transformers/v4.34.1/en/model_doc/segformer#transformers.SegformerImageProcessor) (SegFormer model)
* **swiftformer** — [ViTImageProcessor](https://huggingface.co/docs/transformers/v4.34.1/en/model_doc/vit#transformers.ViTImageProcessor) (SwiftFormer model)
* **swin** — [ViTImageProcessor](https://huggingface.co/docs/transformers/v4.34.1/en/model_doc/vit#transformers.ViTImageProcessor) (Swin Transformer model)
* **swin2sr** — [Swin2SRImageProcessor](https://huggingface.co/docs/transformers/v4.34.1/en/model_doc/swin2sr#transformers.Swin2SRImageProcessor) (Swin2SR model)
* **swinv2** — [ViTImageProcessor](https://huggingface.co/docs/transformers/v4.34.1/en/model_doc/vit#transformers.ViTImageProcessor) (Swin Transformer V2 model)
* **table-transformer** — [DetrImageProcessor](https://huggingface.co/docs/transformers/v4.34.1/en/model_doc/detr#transformers.DetrImageProcessor) (Table Transformer model)
* **timesformer** — [VideoMAEImageProcessor](https://huggingface.co/docs/transformers/v4.34.1/en/model_doc/videomae#transformers.VideoMAEImageProcessor) (TimeSformer model)
* **tvlt** — [TvltImageProcessor](https://huggingface.co/docs/transformers/v4.34.1/en/model_doc/tvlt#transformers.TvltImageProcessor) (TVLT model)
* **upernet** — [SegformerImageProcessor](https://huggingface.co/docs/transformers/v4.34.1/en/model_doc/segformer#transformers.SegformerImageProcessor) (UPerNet model)
* **van** — [ConvNextImageProcessor](https://huggingface.co/docs/transformers/v4.34.1/en/model_doc/convnext#transformers.ConvNextImageProcessor) (VAN model)
* **videomae** — [VideoMAEImageProcessor](https://huggingface.co/docs/transformers/v4.34.1/en/model_doc/videomae#transformers.VideoMAEImageProcessor) (VideoMAE model)
* **vilt** — [ViltImageProcessor](https://huggingface.co/docs/transformers/v4.34.1/en/model_doc/vilt#transformers.ViltImageProcessor) (ViLT model)
* **vit** — [ViTImageProcessor](https://huggingface.co/docs/transformers/v4.34.1/en/model_doc/vit#transformers.ViTImageProcessor) (ViT model)
* **vit\_hybrid** — [ViTHybridImageProcessor](https://huggingface.co/docs/transformers/v4.34.1/en/model_doc/vit_hybrid#transformers.ViTHybridImageProcessor) (ViT Hybrid model)
* **vit\_mae** — [ViTImageProcessor](https://huggingface.co/docs/transformers/v4.34.1/en/model_doc/vit#transformers.ViTImageProcessor) (ViTMAE model)
* **vit\_msn** — [ViTImageProcessor](https://huggingface.co/docs/transformers/v4.34.1/en/model_doc/vit#transformers.ViTImageProcessor) (ViTMSN model)
* **vitmatte** — [VitMatteImageProcessor](https://huggingface.co/docs/transformers/v4.34.1/en/model_doc/vitmatte#transformers.VitMatteImageProcessor) (ViTMatte model)
* **xclip** — [CLIPImageProcessor](https://huggingface.co/docs/transformers/v4.34.1/en/model_doc/clip#transformers.CLIPImageProcessor) (X-CLIP model)
* **yolos** — [YolosImageProcessor](https://huggingface.co/docs/transformers/v4.34.1/en/model_doc/yolos#transformers.YolosImageProcessor) (YOLOS model)

Passing `token=True` is required when you want to use a private model.

Examples:

Copied

```
>>> from transformers import AutoImageProcessor

>>> # Download image processor from huggingface.co and cache.
>>> image_processor = AutoImageProcessor.from_pretrained("google/vit-base-patch16-224-in21k")

>>> # If image processor files are in a directory (e.g. image processor was saved using *save_pretrained('./test/saved_model/')*)
>>> # image_processor = AutoImageProcessor.from_pretrained("./test/saved_model/")
```

**register**

[\<source>](https://github.com/huggingface/transformers/blob/v4.34.1/src/transformers/models/auto/image_processing_auto.py#L409)

( config\_classimage\_processor\_classexist\_ok = False )

Parameters

* **config\_class** ([PretrainedConfig](https://huggingface.co/docs/transformers/v4.34.1/en/main_classes/configuration#transformers.PretrainedConfig)) — The configuration corresponding to the model to register.
* **image\_processor\_class** ([ImageProcessingMixin](https://huggingface.co/docs/transformers/v4.34.1/en/main_classes/image_processor#transformers.ImageProcessingMixin)) — The image processor to register.

Register a new image processor for this class.


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://boinc-ai.gitbook.io/transformers/api/main-classes/auto-classes/autoimageprocessor.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
