import{S as So,i as qo,s as Ao,e as a,k as l,w as u,t as s,M as Lo,c as n,d as o,m,a as t,x as _,h as i,b as c,G as e,g,y as v,q as y,o as b,B as I,v as Ro,L as Xo}from"../../chunks/vendor-hf-doc-builder.js";import{D as k}from"../../chunks/Docstring-hf-doc-builder.js";import{C as Vo}from"../../chunks/CodeBlock-hf-doc-builder.js";import{I as sr}from"../../chunks/IconCopyLink-hf-doc-builder.js";import{E as Yo}from"../../chunks/ExampleCodeBlock-hf-doc-builder.js";function Go(Se){let h,J,$,f,P;return f=new Vo({props:{code:"JTIzJTIwV2UlMjBjYW4ndCUyMGluc3RhbnRpYXRlJTIwZGlyZWN0bHklMjB0aGUlMjBiYXNlJTIwY2xhc3MlMjAqSW1hZ2VQcm9jZXNzaW5nTWl4aW4qJTIwc28lMjBsZXQncyUyMHNob3clMjB0aGUlMjBleGFtcGxlcyUyMG9uJTIwYSUwQSUyMyUyMGRlcml2ZWQlMjBjbGFzcyUzQSUyMCpDTElQSW1hZ2VQcm9jZXNzb3IqJTBBaW1hZ2VfcHJvY2Vzc29yJTIwJTNEJTIwQ0xJUEltYWdlUHJvY2Vzc29yLmZyb21fcHJldHJhaW5lZCglMEElMjAlMjAlMjAlMjAlMjJvcGVuYWklMkZjbGlwLXZpdC1iYXNlLXBhdGNoMzIlMjIlMEEpJTIwJTIwJTIzJTIwRG93bmxvYWQlMjBpbWFnZV9wcm9jZXNzaW5nX2NvbmZpZyUyMGZyb20lMjBodWdnaW5nZmFjZS5jbyUyMGFuZCUyMGNhY2hlLiUwQWltYWdlX3Byb2Nlc3NvciUyMCUzRCUyMENMSVBJbWFnZVByb2Nlc3Nvci5mcm9tX3ByZXRyYWluZWQoJTBBJTIwJTIwJTIwJTIwJTIyLiUyRnRlc3QlMkZzYXZlZF9tb2RlbCUyRiUyMiUwQSklMjAlMjAlMjMlMjBFLmcuJTIwaW1hZ2UlMjBwcm9jZXNzb3IlMjAob3IlMjBtb2RlbCklMjB3YXMlMjBzYXZlZCUyMHVzaW5nJTIwKnNhdmVfcHJldHJhaW5lZCgnLiUyRnRlc3QlMkZzYXZlZF9tb2RlbCUyRicpKiUwQWltYWdlX3Byb2Nlc3NvciUyMCUzRCUyMENMSVBJbWFnZVByb2Nlc3Nvci5mcm9tX3ByZXRyYWluZWQoJTIyLiUyRnRlc3QlMkZzYXZlZF9tb2RlbCUyRnByZXByb2Nlc3Nvcl9jb25maWcuanNvbiUyMiklMEFpbWFnZV9wcm9jZXNzb3IlMjAlM0QlMjBDTElQSW1hZ2VQcm9jZXNzb3IuZnJvbV9wcmV0cmFpbmVkKCUwQSUyMCUyMCUyMCUyMCUyMm9wZW5haSUyRmNsaXAtdml0LWJhc2UtcGF0Y2gzMiUyMiUyQyUyMGRvX25vcm1hbGl6ZSUzREZhbHNlJTJDJTIwZm9vJTNERmFsc2UlMEEpJTBBYXNzZXJ0JTIwaW1hZ2VfcHJvY2Vzc29yLmRvX25vcm1hbGl6ZSUyMGlzJTIwRmFsc2UlMEFpbWFnZV9wcm9jZXNzb3IlMkMlMjB1bnVzZWRfa3dhcmdzJTIwJTNEJTIwQ0xJUEltYWdlUHJvY2Vzc29yLmZyb21fcHJldHJhaW5lZCglMEElMjAlMjAlMjAlMjAlMjJvcGVuYWklMkZjbGlwLXZpdC1iYXNlLXBhdGNoMzIlMjIlMkMlMjBkb19ub3JtYWxpemUlM0RGYWxzZSUyQyUyMGZvbyUzREZhbHNlJTJDJTIwcmV0dXJuX3VudXNlZF9rd2FyZ3MlM0RUcnVlJTBBKSUwQWFzc2VydCUyMGltYWdlX3Byb2Nlc3Nvci5kb19ub3JtYWxpemUlMjBpcyUyMEZhbHNlJTBBYXNzZXJ0JTIwdW51c2VkX2t3YXJncyUyMCUzRCUzRCUyMCU3QiUyMmZvbyUyMiUzQSUyMEZhbHNlJTdE",highlighted:`<span class="hljs-comment"># We can&#x27;t instantiate directly the base class *ImageProcessingMixin* so let&#x27;s show the examples on a</span>
<span class="hljs-comment"># derived class: *CLIPImageProcessor*</span>
image_processor = CLIPImageProcessor.from_pretrained(
    <span class="hljs-string">&quot;openai/clip-vit-base-patch32&quot;</span>
)  <span class="hljs-comment"># Download image_processing_config from huggingface.co and cache.</span>
image_processor = CLIPImageProcessor.from_pretrained(
    <span class="hljs-string">&quot;./test/saved_model/&quot;</span>
)  <span class="hljs-comment"># E.g. image processor (or model) was saved using *save_pretrained(&#x27;./test/saved_model/&#x27;)*</span>
image_processor = CLIPImageProcessor.from_pretrained(<span class="hljs-string">&quot;./test/saved_model/preprocessor_config.json&quot;</span>)
image_processor = CLIPImageProcessor.from_pretrained(
    <span class="hljs-string">&quot;openai/clip-vit-base-patch32&quot;</span>, do_normalize=<span class="hljs-literal">False</span>, foo=<span class="hljs-literal">False</span>
)
<span class="hljs-keyword">assert</span> image_processor.do_normalize <span class="hljs-keyword">is</span> <span class="hljs-literal">False</span>
image_processor, unused_kwargs = CLIPImageProcessor.from_pretrained(
    <span class="hljs-string">&quot;openai/clip-vit-base-patch32&quot;</span>, do_normalize=<span class="hljs-literal">False</span>, foo=<span class="hljs-literal">False</span>, return_unused_kwargs=<span class="hljs-literal">True</span>
)
<span class="hljs-keyword">assert</span> image_processor.do_normalize <span class="hljs-keyword">is</span> <span class="hljs-literal">False</span>
<span class="hljs-keyword">assert</span> unused_kwargs == {<span class="hljs-string">&quot;foo&quot;</span>: <span class="hljs-literal">False</span>}`}}),{c(){h=a("p"),J=s("Examples:"),$=l(),u(f.$$.fragment)},l(d){h=n(d,"P",{});var E=t(h);J=i(E,"Examples:"),E.forEach(o),$=m(d),_(f.$$.fragment,d)},m(d,E){g(d,h,E),e(h,J),g(d,$,E),v(f,d,E),P=!0},p:Xo,i(d){P||(y(f.$$.fragment,d),P=!0)},o(d){b(f.$$.fragment,d),P=!1},d(d){d&&o(h),d&&o($),I(f,d)}}}function Qo(Se){let h,J,$,f,P,d,E,Ie,ir,qe,ge,cr,Ae,C,W,we,O,lr,$e,mr,Le,M,K,dr,Me,pr,gr,B,ee,hr,re,fr,he,ur,_r,vr,S,yr,q,oe,br,j,Ir,xe,wr,$r,fe,Mr,xr,Re,z,A,Te,ae,Tr,Pe,Pr,Xe,w,ne,Er,Z,Br,ue,Ur,Nr,Ee,kr,Cr,jr,Be,zr,Zr,L,te,Dr,Ue,Fr,Jr,R,se,Wr,x,Sr,Ne,qr,Ar,ke,Lr,Rr,Ce,Xr,Vr,je,Yr,Gr,Ve,D,X,ze,ie,Qr,Ze,Hr,Ye,T,ce,Or,V,le,Kr,F,eo,De,ro,oo,Fe,ao,no,to,Y,me,so,Je,io,co,G,de,lo,We,mo,Ge;return d=new sr({}),O=new sr({}),K=new k({props:{name:"class transformers.ImageProcessingMixin",anchor:"transformers.ImageProcessingMixin",parameters:[{name:"**kwargs",val:""}],source:"https://github.com/huggingface/transformers/blob/v4.32.0/src/transformers/image_processing_utils.py#L68"}}),ee=new k({props:{name:"from_pretrained",anchor:"transformers.ImageProcessingMixin.from_pretrained",parameters:[{name:"pretrained_model_name_or_path",val:": typing.Union[str, os.PathLike]"},{name:"cache_dir",val:": typing.Union[str, os.PathLike, NoneType] = None"},{name:"force_download",val:": bool = False"},{name:"local_files_only",val:": bool = False"},{name:"token",val:": typing.Union[str, bool, NoneType] = None"},{name:"revision",val:": str = 'main'"},{name:"**kwargs",val:""}],parametersDescription:[{anchor:"transformers.ImageProcessingMixin.from_pretrained.pretrained_model_name_or_path",description:`<strong>pretrained_model_name_or_path</strong> (<code>str</code> or <code>os.PathLike</code>) &#x2014;
This can be either:</p>
<ul>
<li>a string, the <em>model id</em> of a pretrained image_processor hosted inside a model repo on
huggingface.co. Valid model ids can be located at the root-level, like <code>bert-base-uncased</code>, or
namespaced under a user or organization name, like <code>dbmdz/bert-base-german-cased</code>.</li>
<li>a path to a <em>directory</em> containing a image processor file saved using the
<a href="/docs/transformers/v4.32.0/en/internal/image_processing_utils#transformers.ImageProcessingMixin.save_pretrained">save_pretrained()</a> method, e.g.,
<code>./my_model_directory/</code>.</li>
<li>a path or url to a saved image processor JSON <em>file</em>, e.g.,
<code>./my_model_directory/preprocessor_config.json</code>.</li>
</ul>`,name:"pretrained_model_name_or_path"},{anchor:"transformers.ImageProcessingMixin.from_pretrained.cache_dir",description:`<strong>cache_dir</strong> (<code>str</code> or <code>os.PathLike</code>, <em>optional</em>) &#x2014;
Path to a directory in which a downloaded pretrained model image processor should be cached if the
standard cache should not be used.`,name:"cache_dir"},{anchor:"transformers.ImageProcessingMixin.from_pretrained.force_download",description:`<strong>force_download</strong> (<code>bool</code>, <em>optional</em>, defaults to <code>False</code>) &#x2014;
Whether or not to force to (re-)download the image processor files and override the cached versions if
they exist.`,name:"force_download"},{anchor:"transformers.ImageProcessingMixin.from_pretrained.resume_download",description:`<strong>resume_download</strong> (<code>bool</code>, <em>optional</em>, defaults to <code>False</code>) &#x2014;
Whether or not to delete incompletely received file. Attempts to resume the download if such a file
exists.`,name:"resume_download"},{anchor:"transformers.ImageProcessingMixin.from_pretrained.proxies",description:`<strong>proxies</strong> (<code>Dict[str, str]</code>, <em>optional</em>) &#x2014;
A dictionary of proxy servers to use by protocol or endpoint, e.g., <code>{&apos;http&apos;: &apos;foo.bar:3128&apos;, &apos;http://hostname&apos;: &apos;foo.bar:4012&apos;}.</code> The proxies are used on each request.`,name:"proxies"},{anchor:"transformers.ImageProcessingMixin.from_pretrained.token",description:`<strong>token</strong> (<code>str</code> or <code>bool</code>, <em>optional</em>) &#x2014;
The token to use as HTTP bearer authorization for remote files. If <code>True</code>, or not specified, will use
the token generated when running <code>huggingface-cli login</code> (stored in <code>~/.huggingface</code>).`,name:"token"},{anchor:"transformers.ImageProcessingMixin.from_pretrained.revision",description:`<strong>revision</strong> (<code>str</code>, <em>optional</em>, defaults to <code>&quot;main&quot;</code>) &#x2014;
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 <code>revision</code> can be any
identifier allowed by git.`,name:"revision"}],source:"https://github.com/huggingface/transformers/blob/v4.32.0/src/transformers/image_processing_utils.py#L92",returnDescription:`
<p>A image processor of type <a
  href="/docs/transformers/v4.32.0/en/internal/image_processing_utils#transformers.ImageProcessingMixin"
>ImageProcessingMixin</a>.</p>
`}}),S=new Yo({props:{anchor:"transformers.ImageProcessingMixin.from_pretrained.example",$$slots:{default:[Go]},$$scope:{ctx:Se}}}),oe=new k({props:{name:"save_pretrained",anchor:"transformers.ImageProcessingMixin.save_pretrained",parameters:[{name:"save_directory",val:": typing.Union[str, os.PathLike]"},{name:"push_to_hub",val:": bool = False"},{name:"**kwargs",val:""}],parametersDescription:[{anchor:"transformers.ImageProcessingMixin.save_pretrained.save_directory",description:`<strong>save_directory</strong> (<code>str</code> or <code>os.PathLike</code>) &#x2014;
Directory where the image processor JSON file will be saved (will be created if it does not exist).`,name:"save_directory"},{anchor:"transformers.ImageProcessingMixin.save_pretrained.push_to_hub",description:`<strong>push_to_hub</strong> (<code>bool</code>, <em>optional</em>, defaults to <code>False</code>) &#x2014;
Whether or not to push your model to the Hugging Face model hub after saving it. You can specify the
repository you want to push to with <code>repo_id</code> (will default to the name of <code>save_directory</code> in your
namespace).`,name:"push_to_hub"},{anchor:"transformers.ImageProcessingMixin.save_pretrained.kwargs",description:`<strong>kwargs</strong> (<code>Dict[str, Any]</code>, <em>optional</em>) &#x2014;
Additional key word arguments passed along to the <a href="/docs/transformers/v4.32.0/en/internal/tokenization_utils#transformers.PreTrainedTokenizerBase.push_to_hub">push_to_hub()</a> method.`,name:"kwargs"}],source:"https://github.com/huggingface/transformers/blob/v4.32.0/src/transformers/image_processing_utils.py#L206"}}),ae=new sr({}),ne=new k({props:{name:"class transformers.BatchFeature",anchor:"transformers.BatchFeature",parameters:[{name:"data",val:": typing.Union[typing.Dict[str, typing.Any], NoneType] = None"},{name:"tensor_type",val:": typing.Union[NoneType, str, transformers.utils.generic.TensorType] = None"}],parametersDescription:[{anchor:"transformers.BatchFeature.data",description:`<strong>data</strong> (<code>dict</code>) &#x2014;
Dictionary of lists/arrays/tensors returned by the <strong>call</strong>/pad methods (&#x2018;input_values&#x2019;, &#x2018;attention_mask&#x2019;,
etc.).`,name:"data"},{anchor:"transformers.BatchFeature.tensor_type",description:`<strong>tensor_type</strong> (<code>Union[None, str, TensorType]</code>, <em>optional</em>) &#x2014;
You can give a tensor_type here to convert the lists of integers in PyTorch/TensorFlow/Numpy Tensors at
initialization.`,name:"tensor_type"}],source:"https://github.com/huggingface/transformers/blob/v4.32.0/src/transformers/feature_extraction_utils.py#L61"}}),te=new k({props:{name:"convert_to_tensors",anchor:"transformers.BatchFeature.convert_to_tensors",parameters:[{name:"tensor_type",val:": typing.Union[str, transformers.utils.generic.TensorType, NoneType] = None"}],parametersDescription:[{anchor:"transformers.BatchFeature.convert_to_tensors.tensor_type",description:`<strong>tensor_type</strong> (<code>str</code> or <a href="/docs/transformers/v4.32.0/en/internal/file_utils#transformers.TensorType">TensorType</a>, <em>optional</em>) &#x2014;
The type of tensors to use. If <code>str</code>, should be one of the values of the enum <a href="/docs/transformers/v4.32.0/en/internal/file_utils#transformers.TensorType">TensorType</a>. If
<code>None</code>, no modification is done.`,name:"tensor_type"}],source:"https://github.com/huggingface/transformers/blob/v4.32.0/src/transformers/feature_extraction_utils.py#L115"}}),se=new k({props:{name:"to",anchor:"transformers.BatchFeature.to",parameters:[{name:"*args",val:""},{name:"**kwargs",val:""}],parametersDescription:[{anchor:"transformers.BatchFeature.to.args",description:`<strong>args</strong> (<code>Tuple</code>) &#x2014;
Will be passed to the <code>to(...)</code> function of the tensors.`,name:"args"},{anchor:"transformers.BatchFeature.to.kwargs",description:`<strong>kwargs</strong> (<code>Dict</code>, <em>optional</em>) &#x2014;
Will be passed to the <code>to(...)</code> function of the tensors.`,name:"kwargs"}],source:"https://github.com/huggingface/transformers/blob/v4.32.0/src/transformers/feature_extraction_utils.py#L188",returnDescription:`
<p>The same instance after modification.</p>
`,returnType:`
<p><a
  href="/docs/transformers/v4.32.0/en/main_classes/feature_extractor#transformers.BatchFeature"
>BatchFeature</a></p>
`}}),ie=new sr({}),ce=new k({props:{name:"class transformers.image_processing_utils.BaseImageProcessor",anchor:"transformers.image_processing_utils.BaseImageProcessor",parameters:[{name:"**kwargs",val:""}],source:"https://github.com/huggingface/transformers/blob/v4.32.0/src/transformers/image_processing_utils.py#L540"}}),le=new k({props:{name:"center_crop",anchor:"transformers.image_processing_utils.BaseImageProcessor.center_crop",parameters:[{name:"image",val:": ndarray"},{name:"size",val:": typing.Dict[str, int]"},{name:"data_format",val:": typing.Union[transformers.image_utils.ChannelDimension, str, NoneType] = None"},{name:"input_data_format",val:": typing.Union[transformers.image_utils.ChannelDimension, str, NoneType] = None"},{name:"**kwargs",val:""}],parametersDescription:[{anchor:"transformers.image_processing_utils.BaseImageProcessor.center_crop.image",description:`<strong>image</strong> (<code>np.ndarray</code>) &#x2014;
Image to center crop.`,name:"image"},{anchor:"transformers.image_processing_utils.BaseImageProcessor.center_crop.size",description:`<strong>size</strong> (<code>Dict[str, int]</code>) &#x2014;
Size of the output image.`,name:"size"},{anchor:"transformers.image_processing_utils.BaseImageProcessor.center_crop.data_format",description:`<strong>data_format</strong> (<code>str</code> or <code>ChannelDimension</code>, <em>optional</em>) &#x2014;
The channel dimension format for the output image. If unset, the channel dimension format of the input
image is used. Can be one of:<ul>
<li><code>&quot;channels_first&quot;</code> or <code>ChannelDimension.FIRST</code>: image in (num_channels, height, width) format.</li>
<li><code>&quot;channels_last&quot;</code> or <code>ChannelDimension.LAST</code>: image in (height, width, num_channels) format.</li>
</ul>`,name:"data_format"},{anchor:"transformers.image_processing_utils.BaseImageProcessor.center_crop.input_data_format",description:`<strong>input_data_format</strong> (<code>ChannelDimension</code> or <code>str</code>, <em>optional</em>) &#x2014;
The channel dimension format for the input image. If unset, the channel dimension format is inferred
from the input image. Can be one of:<ul>
<li><code>&quot;channels_first&quot;</code> or <code>ChannelDimension.FIRST</code>: image in (num_channels, height, width) format.</li>
<li><code>&quot;channels_last&quot;</code> or <code>ChannelDimension.LAST</code>: image in (height, width, num_channels) format.</li>
</ul>`,name:"input_data_format"}],source:"https://github.com/huggingface/transformers/blob/v4.32.0/src/transformers/image_processing_utils.py#L620"}}),me=new k({props:{name:"normalize",anchor:"transformers.image_processing_utils.BaseImageProcessor.normalize",parameters:[{name:"image",val:": ndarray"},{name:"mean",val:": typing.Union[float, typing.Iterable[float]]"},{name:"std",val:": typing.Union[float, typing.Iterable[float]]"},{name:"data_format",val:": typing.Union[transformers.image_utils.ChannelDimension, str, NoneType] = None"},{name:"input_data_format",val:": typing.Union[transformers.image_utils.ChannelDimension, str, NoneType] = None"},{name:"**kwargs",val:""}],parametersDescription:[{anchor:"transformers.image_processing_utils.BaseImageProcessor.normalize.image",description:`<strong>image</strong> (<code>np.ndarray</code>) &#x2014;
Image to normalize.`,name:"image"},{anchor:"transformers.image_processing_utils.BaseImageProcessor.normalize.mean",description:`<strong>mean</strong> (<code>float</code> or <code>Iterable[float]</code>) &#x2014;
Image mean to use for normalization.`,name:"mean"},{anchor:"transformers.image_processing_utils.BaseImageProcessor.normalize.std",description:`<strong>std</strong> (<code>float</code> or <code>Iterable[float]</code>) &#x2014;
Image standard deviation to use for normalization.`,name:"std"},{anchor:"transformers.image_processing_utils.BaseImageProcessor.normalize.data_format",description:`<strong>data_format</strong> (<code>str</code> or <code>ChannelDimension</code>, <em>optional</em>) &#x2014;
The channel dimension format for the output image. If unset, the channel dimension format of the input
image is used. Can be one of:<ul>
<li><code>&quot;channels_first&quot;</code> or <code>ChannelDimension.FIRST</code>: image in (num_channels, height, width) format.</li>
<li><code>&quot;channels_last&quot;</code> or <code>ChannelDimension.LAST</code>: image in (height, width, num_channels) format.</li>
</ul>`,name:"data_format"},{anchor:"transformers.image_processing_utils.BaseImageProcessor.normalize.input_data_format",description:`<strong>input_data_format</strong> (<code>ChannelDimension</code> or <code>str</code>, <em>optional</em>) &#x2014;
The channel dimension format for the input image. If unset, the channel dimension format is inferred
from the input image. Can be one of:<ul>
<li><code>&quot;channels_first&quot;</code> or <code>ChannelDimension.FIRST</code>: image in (num_channels, height, width) format.</li>
<li><code>&quot;channels_last&quot;</code> or <code>ChannelDimension.LAST</code>: image in (height, width, num_channels) format.</li>
</ul>`,name:"input_data_format"}],source:"https://github.com/huggingface/transformers/blob/v4.32.0/src/transformers/image_processing_utils.py#L583",returnDescription:`
<p>The normalized image.</p>
`,returnType:`
<p><code>np.ndarray</code></p>
`}}),de=new k({props:{name:"rescale",anchor:"transformers.image_processing_utils.BaseImageProcessor.rescale",parameters:[{name:"image",val:": ndarray"},{name:"scale",val:": float"},{name:"data_format",val:": typing.Union[transformers.image_utils.ChannelDimension, str, NoneType] = None"},{name:"input_data_format",val:": typing.Union[transformers.image_utils.ChannelDimension, str, NoneType] = None"},{name:"**kwargs",val:""}],parametersDescription:[{anchor:"transformers.image_processing_utils.BaseImageProcessor.rescale.image",description:`<strong>image</strong> (<code>np.ndarray</code>) &#x2014;
Image to rescale.`,name:"image"},{anchor:"transformers.image_processing_utils.BaseImageProcessor.rescale.scale",description:`<strong>scale</strong> (<code>float</code>) &#x2014;
The scaling factor to rescale pixel values by.`,name:"scale"},{anchor:"transformers.image_processing_utils.BaseImageProcessor.rescale.data_format",description:`<strong>data_format</strong> (<code>str</code> or <code>ChannelDimension</code>, <em>optional</em>) &#x2014;
The channel dimension format for the output image. If unset, the channel dimension format of the input
image is used. Can be one of:<ul>
<li><code>&quot;channels_first&quot;</code> or <code>ChannelDimension.FIRST</code>: image in (num_channels, height, width) format.</li>
<li><code>&quot;channels_last&quot;</code> or <code>ChannelDimension.LAST</code>: image in (height, width, num_channels) format.</li>
</ul>`,name:"data_format"},{anchor:"transformers.image_processing_utils.BaseImageProcessor.rescale.input_data_format",description:`<strong>input_data_format</strong> (<code>ChannelDimension</code> or <code>str</code>, <em>optional</em>) &#x2014;
The channel dimension format for the input image. If unset, the channel dimension format is inferred
from the input image. Can be one of:<ul>
<li><code>&quot;channels_first&quot;</code> or <code>ChannelDimension.FIRST</code>: image in (num_channels, height, width) format.</li>
<li><code>&quot;channels_last&quot;</code> or <code>ChannelDimension.LAST</code>: image in (height, width, num_channels) format.</li>
</ul>`,name:"input_data_format"}],source:"https://github.com/huggingface/transformers/blob/v4.32.0/src/transformers/image_processing_utils.py#L551",returnDescription:`
<p>The rescaled image.</p>
`,returnType:`
<p><code>np.ndarray</code></p>
`}}),{c(){h=a("meta"),J=l(),$=a("h1"),f=a("a"),P=a("span"),u(d.$$.fragment),E=l(),Ie=a("span"),ir=s("Image Processor"),qe=l(),ge=a("p"),cr=s("An image processor is in charge of preparing input features for vision models and post processing their outputs. This includes transformations such as resizing, normalization, and conversion to PyTorch, TensorFlow, Flax and Numpy tensors. It may also include model specific post-processing such as converting logits to segmentation masks."),Ae=l(),C=a("h2"),W=a("a"),we=a("span"),u(O.$$.fragment),lr=l(),$e=a("span"),mr=s("ImageProcessingMixin"),Le=l(),M=a("div"),u(K.$$.fragment),dr=l(),Me=a("p"),pr=s(`This is an image processor mixin used to provide saving/loading functionality for sequential and image feature
extractors.`),gr=l(),B=a("div"),u(ee.$$.fragment),hr=l(),re=a("p"),fr=s("Instantiate a type of "),he=a("a"),ur=s("ImageProcessingMixin"),_r=s(" from an image processor."),vr=l(),u(S.$$.fragment),yr=l(),q=a("div"),u(oe.$$.fragment),br=l(),j=a("p"),Ir=s("Save an image processor object to the directory "),xe=a("code"),wr=s("save_directory"),$r=s(`, so that it can be re-loaded using the
`),fe=a("a"),Mr=s("from_pretrained()"),xr=s(" class method."),Re=l(),z=a("h2"),A=a("a"),Te=a("span"),u(ae.$$.fragment),Tr=l(),Pe=a("span"),Pr=s("BatchFeature"),Xe=l(),w=a("div"),u(ne.$$.fragment),Er=l(),Z=a("p"),Br=s("Holds the output of the "),ue=a("a"),Ur=s("pad()"),Nr=s(" and feature extractor specific "),Ee=a("code"),kr=s("__call__"),Cr=s(" methods."),jr=l(),Be=a("p"),zr=s("This class is derived from a python dictionary and can be used as a dictionary."),Zr=l(),L=a("div"),u(te.$$.fragment),Dr=l(),Ue=a("p"),Fr=s("Convert the inner content to tensors."),Jr=l(),R=a("div"),u(se.$$.fragment),Wr=l(),x=a("p"),Sr=s("Send all values to device by calling "),Ne=a("code"),qr=s("v.to(*args, **kwargs)"),Ar=s(` (PyTorch only). This should support casting in
different `),ke=a("code"),Lr=s("dtypes"),Rr=s(" and sending the "),Ce=a("code"),Xr=s("BatchFeature"),Vr=s(" to a different "),je=a("code"),Yr=s("device"),Gr=s("."),Ve=l(),D=a("h2"),X=a("a"),ze=a("span"),u(ie.$$.fragment),Qr=l(),Ze=a("span"),Hr=s("BaseImageProcessor"),Ye=l(),T=a("div"),u(ce.$$.fragment),Or=l(),V=a("div"),u(le.$$.fragment),Kr=l(),F=a("p"),eo=s("Center crop an image to "),De=a("code"),ro=s('(size["height"], size["width"])'),oo=s(". If the input size is smaller than "),Fe=a("code"),ao=s("crop_size"),no=s(` along
any edge, the image is padded with 0\u2019s and then center cropped.`),to=l(),Y=a("div"),u(me.$$.fragment),so=l(),Je=a("p"),io=s("Normalize an image. image = (image - image_mean) / image_std."),co=l(),G=a("div"),u(de.$$.fragment),lo=l(),We=a("p"),mo=s("Rescale an image by a scale factor. image = image * scale."),this.h()},l(r){const p=Lo('[data-svelte="svelte-1phssyn"]',document.head);h=n(p,"META",{name:!0,content:!0}),p.forEach(o),J=m(r),$=n(r,"H1",{class:!0});var pe=t($);f=n(pe,"A",{id:!0,class:!0,href:!0});var po=t(f);P=n(po,"SPAN",{});var go=t(P);_(d.$$.fragment,go),go.forEach(o),po.forEach(o),E=m(pe),Ie=n(pe,"SPAN",{});var ho=t(Ie);ir=i(ho,"Image Processor"),ho.forEach(o),pe.forEach(o),qe=m(r),ge=n(r,"P",{});var fo=t(ge);cr=i(fo,"An image processor is in charge of preparing input features for vision models and post processing their outputs. This includes transformations such as resizing, normalization, and conversion to PyTorch, TensorFlow, Flax and Numpy tensors. It may also include model specific post-processing such as converting logits to segmentation masks."),fo.forEach(o),Ae=m(r),C=n(r,"H2",{class:!0});var Qe=t(C);W=n(Qe,"A",{id:!0,class:!0,href:!0});var uo=t(W);we=n(uo,"SPAN",{});var _o=t(we);_(O.$$.fragment,_o),_o.forEach(o),uo.forEach(o),lr=m(Qe),$e=n(Qe,"SPAN",{});var vo=t($e);mr=i(vo,"ImageProcessingMixin"),vo.forEach(o),Qe.forEach(o),Le=m(r),M=n(r,"DIV",{class:!0});var Q=t(M);_(K.$$.fragment,Q),dr=m(Q),Me=n(Q,"P",{});var yo=t(Me);pr=i(yo,`This is an image processor mixin used to provide saving/loading functionality for sequential and image feature
extractors.`),yo.forEach(o),gr=m(Q),B=n(Q,"DIV",{class:!0});var _e=t(B);_(ee.$$.fragment,_e),hr=m(_e),re=n(_e,"P",{});var He=t(re);fr=i(He,"Instantiate a type of "),he=n(He,"A",{href:!0});var bo=t(he);ur=i(bo,"ImageProcessingMixin"),bo.forEach(o),_r=i(He," from an image processor."),He.forEach(o),vr=m(_e),_(S.$$.fragment,_e),_e.forEach(o),yr=m(Q),q=n(Q,"DIV",{class:!0});var Oe=t(q);_(oe.$$.fragment,Oe),br=m(Oe),j=n(Oe,"P",{});var ve=t(j);Ir=i(ve,"Save an image processor object to the directory "),xe=n(ve,"CODE",{});var Io=t(xe);wr=i(Io,"save_directory"),Io.forEach(o),$r=i(ve,`, so that it can be re-loaded using the
`),fe=n(ve,"A",{href:!0});var wo=t(fe);Mr=i(wo,"from_pretrained()"),wo.forEach(o),xr=i(ve," class method."),ve.forEach(o),Oe.forEach(o),Q.forEach(o),Re=m(r),z=n(r,"H2",{class:!0});var Ke=t(z);A=n(Ke,"A",{id:!0,class:!0,href:!0});var $o=t(A);Te=n($o,"SPAN",{});var Mo=t(Te);_(ae.$$.fragment,Mo),Mo.forEach(o),$o.forEach(o),Tr=m(Ke),Pe=n(Ke,"SPAN",{});var xo=t(Pe);Pr=i(xo,"BatchFeature"),xo.forEach(o),Ke.forEach(o),Xe=m(r),w=n(r,"DIV",{class:!0});var U=t(w);_(ne.$$.fragment,U),Er=m(U),Z=n(U,"P",{});var ye=t(Z);Br=i(ye,"Holds the output of the "),ue=n(ye,"A",{href:!0});var To=t(ue);Ur=i(To,"pad()"),To.forEach(o),Nr=i(ye," and feature extractor specific "),Ee=n(ye,"CODE",{});var Po=t(Ee);kr=i(Po,"__call__"),Po.forEach(o),Cr=i(ye," methods."),ye.forEach(o),jr=m(U),Be=n(U,"P",{});var Eo=t(Be);zr=i(Eo,"This class is derived from a python dictionary and can be used as a dictionary."),Eo.forEach(o),Zr=m(U),L=n(U,"DIV",{class:!0});var er=t(L);_(te.$$.fragment,er),Dr=m(er),Ue=n(er,"P",{});var Bo=t(Ue);Fr=i(Bo,"Convert the inner content to tensors."),Bo.forEach(o),er.forEach(o),Jr=m(U),R=n(U,"DIV",{class:!0});var rr=t(R);_(se.$$.fragment,rr),Wr=m(rr),x=n(rr,"P",{});var N=t(x);Sr=i(N,"Send all values to device by calling "),Ne=n(N,"CODE",{});var Uo=t(Ne);qr=i(Uo,"v.to(*args, **kwargs)"),Uo.forEach(o),Ar=i(N,` (PyTorch only). This should support casting in
different `),ke=n(N,"CODE",{});var No=t(ke);Lr=i(No,"dtypes"),No.forEach(o),Rr=i(N," and sending the "),Ce=n(N,"CODE",{});var ko=t(Ce);Xr=i(ko,"BatchFeature"),ko.forEach(o),Vr=i(N," to a different "),je=n(N,"CODE",{});var Co=t(je);Yr=i(Co,"device"),Co.forEach(o),Gr=i(N,"."),N.forEach(o),rr.forEach(o),U.forEach(o),Ve=m(r),D=n(r,"H2",{class:!0});var or=t(D);X=n(or,"A",{id:!0,class:!0,href:!0});var jo=t(X);ze=n(jo,"SPAN",{});var zo=t(ze);_(ie.$$.fragment,zo),zo.forEach(o),jo.forEach(o),Qr=m(or),Ze=n(or,"SPAN",{});var Zo=t(Ze);Hr=i(Zo,"BaseImageProcessor"),Zo.forEach(o),or.forEach(o),Ye=m(r),T=n(r,"DIV",{class:!0});var H=t(T);_(ce.$$.fragment,H),Or=m(H),V=n(H,"DIV",{class:!0});var ar=t(V);_(le.$$.fragment,ar),Kr=m(ar),F=n(ar,"P",{});var be=t(F);eo=i(be,"Center crop an image to "),De=n(be,"CODE",{});var Do=t(De);ro=i(Do,'(size["height"], size["width"])'),Do.forEach(o),oo=i(be,". If the input size is smaller than "),Fe=n(be,"CODE",{});var Fo=t(Fe);ao=i(Fo,"crop_size"),Fo.forEach(o),no=i(be,` along
any edge, the image is padded with 0\u2019s and then center cropped.`),be.forEach(o),ar.forEach(o),to=m(H),Y=n(H,"DIV",{class:!0});var nr=t(Y);_(me.$$.fragment,nr),so=m(nr),Je=n(nr,"P",{});var Jo=t(Je);io=i(Jo,"Normalize an image. image = (image - image_mean) / image_std."),Jo.forEach(o),nr.forEach(o),co=m(H),G=n(H,"DIV",{class:!0});var tr=t(G);_(de.$$.fragment,tr),lo=m(tr),We=n(tr,"P",{});var Wo=t(We);mo=i(Wo,"Rescale an image by a scale factor. image = image * scale."),Wo.forEach(o),tr.forEach(o),H.forEach(o),this.h()},h(){c(h,"name","hf:doc:metadata"),c(h,"content",JSON.stringify(Ho)),c(f,"id","image-processor"),c(f,"class","header-link block pr-1.5 text-lg no-hover:hidden with-hover:absolute with-hover:p-1.5 with-hover:opacity-0 with-hover:group-hover:opacity-100 with-hover:right-full"),c(f,"href","#image-processor"),c($,"class","relative group"),c(W,"id","transformers.ImageProcessingMixin"),c(W,"class","header-link block pr-1.5 text-lg no-hover:hidden with-hover:absolute with-hover:p-1.5 with-hover:opacity-0 with-hover:group-hover:opacity-100 with-hover:right-full"),c(W,"href","#transformers.ImageProcessingMixin"),c(C,"class","relative group"),c(he,"href","/docs/transformers/v4.32.0/en/internal/image_processing_utils#transformers.ImageProcessingMixin"),c(B,"class","docstring border-l-2 border-t-2 pl-4 pt-3.5 border-gray-100 rounded-tl-xl mb-6 mt-8"),c(fe,"href","/docs/transformers/v4.32.0/en/internal/image_processing_utils#transformers.ImageProcessingMixin.from_pretrained"),c(q,"class","docstring border-l-2 border-t-2 pl-4 pt-3.5 border-gray-100 rounded-tl-xl mb-6 mt-8"),c(M,"class","docstring border-l-2 border-t-2 pl-4 pt-3.5 border-gray-100 rounded-tl-xl mb-6 mt-8"),c(A,"id","transformers.BatchFeature"),c(A,"class","header-link block pr-1.5 text-lg no-hover:hidden with-hover:absolute with-hover:p-1.5 with-hover:opacity-0 with-hover:group-hover:opacity-100 with-hover:right-full"),c(A,"href","#transformers.BatchFeature"),c(z,"class","relative group"),c(ue,"href","/docs/transformers/v4.32.0/en/main_classes/feature_extractor#transformers.SequenceFeatureExtractor.pad"),c(L,"class","docstring border-l-2 border-t-2 pl-4 pt-3.5 border-gray-100 rounded-tl-xl mb-6 mt-8"),c(R,"class","docstring border-l-2 border-t-2 pl-4 pt-3.5 border-gray-100 rounded-tl-xl mb-6 mt-8"),c(w,"class","docstring border-l-2 border-t-2 pl-4 pt-3.5 border-gray-100 rounded-tl-xl mb-6 mt-8"),c(X,"id","transformers.image_processing_utils.BaseImageProcessor"),c(X,"class","header-link block pr-1.5 text-lg no-hover:hidden with-hover:absolute with-hover:p-1.5 with-hover:opacity-0 with-hover:group-hover:opacity-100 with-hover:right-full"),c(X,"href","#transformers.image_processing_utils.BaseImageProcessor"),c(D,"class","relative group"),c(V,"class","docstring border-l-2 border-t-2 pl-4 pt-3.5 border-gray-100 rounded-tl-xl mb-6 mt-8"),c(Y,"class","docstring border-l-2 border-t-2 pl-4 pt-3.5 border-gray-100 rounded-tl-xl mb-6 mt-8"),c(G,"class","docstring border-l-2 border-t-2 pl-4 pt-3.5 border-gray-100 rounded-tl-xl mb-6 mt-8"),c(T,"class","docstring border-l-2 border-t-2 pl-4 pt-3.5 border-gray-100 rounded-tl-xl mb-6 mt-8")},m(r,p){e(document.head,h),g(r,J,p),g(r,$,p),e($,f),e(f,P),v(d,P,null),e($,E),e($,Ie),e(Ie,ir),g(r,qe,p),g(r,ge,p),e(ge,cr),g(r,Ae,p),g(r,C,p),e(C,W),e(W,we),v(O,we,null),e(C,lr),e(C,$e),e($e,mr),g(r,Le,p),g(r,M,p),v(K,M,null),e(M,dr),e(M,Me),e(Me,pr),e(M,gr),e(M,B),v(ee,B,null),e(B,hr),e(B,re),e(re,fr),e(re,he),e(he,ur),e(re,_r),e(B,vr),v(S,B,null),e(M,yr),e(M,q),v(oe,q,null),e(q,br),e(q,j),e(j,Ir),e(j,xe),e(xe,wr),e(j,$r),e(j,fe),e(fe,Mr),e(j,xr),g(r,Re,p),g(r,z,p),e(z,A),e(A,Te),v(ae,Te,null),e(z,Tr),e(z,Pe),e(Pe,Pr),g(r,Xe,p),g(r,w,p),v(ne,w,null),e(w,Er),e(w,Z),e(Z,Br),e(Z,ue),e(ue,Ur),e(Z,Nr),e(Z,Ee),e(Ee,kr),e(Z,Cr),e(w,jr),e(w,Be),e(Be,zr),e(w,Zr),e(w,L),v(te,L,null),e(L,Dr),e(L,Ue),e(Ue,Fr),e(w,Jr),e(w,R),v(se,R,null),e(R,Wr),e(R,x),e(x,Sr),e(x,Ne),e(Ne,qr),e(x,Ar),e(x,ke),e(ke,Lr),e(x,Rr),e(x,Ce),e(Ce,Xr),e(x,Vr),e(x,je),e(je,Yr),e(x,Gr),g(r,Ve,p),g(r,D,p),e(D,X),e(X,ze),v(ie,ze,null),e(D,Qr),e(D,Ze),e(Ze,Hr),g(r,Ye,p),g(r,T,p),v(ce,T,null),e(T,Or),e(T,V),v(le,V,null),e(V,Kr),e(V,F),e(F,eo),e(F,De),e(De,ro),e(F,oo),e(F,Fe),e(Fe,ao),e(F,no),e(T,to),e(T,Y),v(me,Y,null),e(Y,so),e(Y,Je),e(Je,io),e(T,co),e(T,G),v(de,G,null),e(G,lo),e(G,We),e(We,mo),Ge=!0},p(r,[p]){const pe={};p&2&&(pe.$$scope={dirty:p,ctx:r}),S.$set(pe)},i(r){Ge||(y(d.$$.fragment,r),y(O.$$.fragment,r),y(K.$$.fragment,r),y(ee.$$.fragment,r),y(S.$$.fragment,r),y(oe.$$.fragment,r),y(ae.$$.fragment,r),y(ne.$$.fragment,r),y(te.$$.fragment,r),y(se.$$.fragment,r),y(ie.$$.fragment,r),y(ce.$$.fragment,r),y(le.$$.fragment,r),y(me.$$.fragment,r),y(de.$$.fragment,r),Ge=!0)},o(r){b(d.$$.fragment,r),b(O.$$.fragment,r),b(K.$$.fragment,r),b(ee.$$.fragment,r),b(S.$$.fragment,r),b(oe.$$.fragment,r),b(ae.$$.fragment,r),b(ne.$$.fragment,r),b(te.$$.fragment,r),b(se.$$.fragment,r),b(ie.$$.fragment,r),b(ce.$$.fragment,r),b(le.$$.fragment,r),b(me.$$.fragment,r),b(de.$$.fragment,r),Ge=!1},d(r){o(h),r&&o(J),r&&o($),I(d),r&&o(qe),r&&o(ge),r&&o(Ae),r&&o(C),I(O),r&&o(Le),r&&o(M),I(K),I(ee),I(S),I(oe),r&&o(Re),r&&o(z),I(ae),r&&o(Xe),r&&o(w),I(ne),I(te),I(se),r&&o(Ve),r&&o(D),I(ie),r&&o(Ye),r&&o(T),I(ce),I(le),I(me),I(de)}}}const Ho={local:"image-processor",sections:[{local:"transformers.ImageProcessingMixin",title:"ImageProcessingMixin"},{local:"transformers.BatchFeature",title:"BatchFeature"},{local:"transformers.image_processing_utils.BaseImageProcessor",title:"BaseImageProcessor"}],title:"Image Processor"};function Oo(Se){return Ro(()=>{new URLSearchParams(window.location.search).get("fw")}),[]}class na extends So{constructor(h){super();qo(this,h,Oo,Qo,Ao,{})}}export{na as default,Ho as metadata};
