import{s as Nt,f as zt,o as Lt,n as be}from"../chunks/scheduler.9bc65507.js";import{S as Pt,i as Ht,g as c,s as r,r as b,A as Rt,h as m,f as a,c as i,j as ue,u as y,x as f,k as ee,y as d,a as l,v,d as w,t as M,w as $}from"../chunks/index.707bf1b6.js";import{T as He}from"../chunks/Tip.c2ecdbf4.js";import{D as Me}from"../chunks/Docstring.17db21ae.js";import{C as De}from"../chunks/CodeBlock.54a9f38d.js";import{F as Bt,M as It}from"../chunks/Markdown.8ab98a13.js";import{E as Qe}from"../chunks/ExampleCodeBlock.4f515aa9.js";import{P as Gt}from"../chunks/PipelineTag.44585822.js";import{H as Pe}from"../chunks/Heading.342b1fa6.js";function Et(V){let e,p="Example:",t,s,u;return s=new De({props:{code:"ZnJvbSUyMHRyYW5zZm9ybWVycyUyMGltcG9ydCUyMFZpVENvbmZpZyUyQyUyMFZpVE1vZGVsJTBBJTBBJTIzJTIwSW5pdGlhbGl6aW5nJTIwYSUyMFZpVCUyMHZpdC1iYXNlLXBhdGNoMTYtMjI0JTIwc3R5bGUlMjBjb25maWd1cmF0aW9uJTBBY29uZmlndXJhdGlvbiUyMCUzRCUyMFZpVENvbmZpZygpJTBBJTBBJTIzJTIwSW5pdGlhbGl6aW5nJTIwYSUyMG1vZGVsJTIwKHdpdGglMjByYW5kb20lMjB3ZWlnaHRzKSUyMGZyb20lMjB0aGUlMjB2aXQtYmFzZS1wYXRjaDE2LTIyNCUyMHN0eWxlJTIwY29uZmlndXJhdGlvbiUwQW1vZGVsJTIwJTNEJTIwVmlUTW9kZWwoY29uZmlndXJhdGlvbiklMEElMEElMjMlMjBBY2Nlc3NpbmclMjB0aGUlMjBtb2RlbCUyMGNvbmZpZ3VyYXRpb24lMEFjb25maWd1cmF0aW9uJTIwJTNEJTIwbW9kZWwuY29uZmln",highlighted:`<span class="hljs-meta">&gt;&gt;&gt; </span><span class="hljs-keyword">from</span> transformers <span class="hljs-keyword">import</span> ViTConfig, ViTModel

<span class="hljs-meta">&gt;&gt;&gt; </span><span class="hljs-comment"># Initializing a ViT vit-base-patch16-224 style configuration</span>
<span class="hljs-meta">&gt;&gt;&gt; </span>configuration = ViTConfig()

<span class="hljs-meta">&gt;&gt;&gt; </span><span class="hljs-comment"># Initializing a model (with random weights) from the vit-base-patch16-224 style configuration</span>
<span class="hljs-meta">&gt;&gt;&gt; </span>model = ViTModel(configuration)

<span class="hljs-meta">&gt;&gt;&gt; </span><span class="hljs-comment"># Accessing the model configuration</span>
<span class="hljs-meta">&gt;&gt;&gt; </span>configuration = model.config`,wrap:!1}}),{c(){e=c("p"),e.textContent=p,t=r(),b(s.$$.fragment)},l(n){e=m(n,"P",{"data-svelte-h":!0}),f(e)!=="svelte-11lpom8"&&(e.textContent=p),t=i(n),y(s.$$.fragment,n)},m(n,x){l(n,e,x),l(n,t,x),v(s,n,x),u=!0},p:be,i(n){u||(w(s.$$.fragment,n),u=!0)},o(n){M(s.$$.fragment,n),u=!1},d(n){n&&(a(e),a(t)),$(s,n)}}}function qt(V){let e,p=`Although the recipe for forward pass needs to be defined within this function, one should call the <code>Module</code>
instance afterwards instead of this since the former takes care of running the pre and post processing steps while
the latter silently ignores them.`;return{c(){e=c("p"),e.innerHTML=p},l(t){e=m(t,"P",{"data-svelte-h":!0}),f(e)!=="svelte-fincs2"&&(e.innerHTML=p)},m(t,s){l(t,e,s)},p:be,d(t){t&&a(e)}}}function Xt(V){let e,p="Example:",t,s,u;return s=new De({props:{code:"ZnJvbSUyMHRyYW5zZm9ybWVycyUyMGltcG9ydCUyMEF1dG9JbWFnZVByb2Nlc3NvciUyQyUyMFZpVE1vZGVsJTBBaW1wb3J0JTIwdG9yY2glMEFmcm9tJTIwZGF0YXNldHMlMjBpbXBvcnQlMjBsb2FkX2RhdGFzZXQlMEElMEFkYXRhc2V0JTIwJTNEJTIwbG9hZF9kYXRhc2V0KCUyMmh1Z2dpbmdmYWNlJTJGY2F0cy1pbWFnZSUyMiklMEFpbWFnZSUyMCUzRCUyMGRhdGFzZXQlNUIlMjJ0ZXN0JTIyJTVEJTVCJTIyaW1hZ2UlMjIlNUQlNUIwJTVEJTBBJTBBaW1hZ2VfcHJvY2Vzc29yJTIwJTNEJTIwQXV0b0ltYWdlUHJvY2Vzc29yLmZyb21fcHJldHJhaW5lZCglMjJnb29nbGUlMkZ2aXQtYmFzZS1wYXRjaDE2LTIyNC1pbjIxayUyMiklMEFtb2RlbCUyMCUzRCUyMFZpVE1vZGVsLmZyb21fcHJldHJhaW5lZCglMjJnb29nbGUlMkZ2aXQtYmFzZS1wYXRjaDE2LTIyNC1pbjIxayUyMiklMEElMEFpbnB1dHMlMjAlM0QlMjBpbWFnZV9wcm9jZXNzb3IoaW1hZ2UlMkMlMjByZXR1cm5fdGVuc29ycyUzRCUyMnB0JTIyKSUwQSUwQXdpdGglMjB0b3JjaC5ub19ncmFkKCklM0ElMEElMjAlMjAlMjAlMjBvdXRwdXRzJTIwJTNEJTIwbW9kZWwoKippbnB1dHMpJTBBJTBBbGFzdF9oaWRkZW5fc3RhdGVzJTIwJTNEJTIwb3V0cHV0cy5sYXN0X2hpZGRlbl9zdGF0ZSUwQWxpc3QobGFzdF9oaWRkZW5fc3RhdGVzLnNoYXBlKQ==",highlighted:`<span class="hljs-meta">&gt;&gt;&gt; </span><span class="hljs-keyword">from</span> transformers <span class="hljs-keyword">import</span> AutoImageProcessor, ViTModel
<span class="hljs-meta">&gt;&gt;&gt; </span><span class="hljs-keyword">import</span> torch
<span class="hljs-meta">&gt;&gt;&gt; </span><span class="hljs-keyword">from</span> datasets <span class="hljs-keyword">import</span> load_dataset

<span class="hljs-meta">&gt;&gt;&gt; </span>dataset = load_dataset(<span class="hljs-string">&quot;huggingface/cats-image&quot;</span>)
<span class="hljs-meta">&gt;&gt;&gt; </span>image = dataset[<span class="hljs-string">&quot;test&quot;</span>][<span class="hljs-string">&quot;image&quot;</span>][<span class="hljs-number">0</span>]

<span class="hljs-meta">&gt;&gt;&gt; </span>image_processor = AutoImageProcessor.from_pretrained(<span class="hljs-string">&quot;google/vit-base-patch16-224-in21k&quot;</span>)
<span class="hljs-meta">&gt;&gt;&gt; </span>model = ViTModel.from_pretrained(<span class="hljs-string">&quot;google/vit-base-patch16-224-in21k&quot;</span>)

<span class="hljs-meta">&gt;&gt;&gt; </span>inputs = image_processor(image, return_tensors=<span class="hljs-string">&quot;pt&quot;</span>)

<span class="hljs-meta">&gt;&gt;&gt; </span><span class="hljs-keyword">with</span> torch.no_grad():
<span class="hljs-meta">... </span>    outputs = model(**inputs)

<span class="hljs-meta">&gt;&gt;&gt; </span>last_hidden_states = outputs.last_hidden_state
<span class="hljs-meta">&gt;&gt;&gt; </span><span class="hljs-built_in">list</span>(last_hidden_states.shape)
[<span class="hljs-number">1</span>, <span class="hljs-number">197</span>, <span class="hljs-number">768</span>]`,wrap:!1}}),{c(){e=c("p"),e.textContent=p,t=r(),b(s.$$.fragment)},l(n){e=m(n,"P",{"data-svelte-h":!0}),f(e)!=="svelte-11lpom8"&&(e.textContent=p),t=i(n),y(s.$$.fragment,n)},m(n,x){l(n,e,x),l(n,t,x),v(s,n,x),u=!0},p:be,i(n){u||(w(s.$$.fragment,n),u=!0)},o(n){M(s.$$.fragment,n),u=!1},d(n){n&&(a(e),a(t)),$(s,n)}}}function Yt(V){let e,p=`Note that we provide a script to pre-train this model on custom data in our <a href="https://github.com/huggingface/transformers/tree/main/examples/pytorch/image-pretraining" rel="nofollow">examples
directory</a>.`;return{c(){e=c("p"),e.innerHTML=p},l(t){e=m(t,"P",{"data-svelte-h":!0}),f(e)!=="svelte-7i3y9o"&&(e.innerHTML=p)},m(t,s){l(t,e,s)},p:be,d(t){t&&a(e)}}}function St(V){let e,p=`Although the recipe for forward pass needs to be defined within this function, one should call the <code>Module</code>
instance afterwards instead of this since the former takes care of running the pre and post processing steps while
the latter silently ignores them.`;return{c(){e=c("p"),e.innerHTML=p},l(t){e=m(t,"P",{"data-svelte-h":!0}),f(e)!=="svelte-fincs2"&&(e.innerHTML=p)},m(t,s){l(t,e,s)},p:be,d(t){t&&a(e)}}}function Qt(V){let e,p="Examples:",t,s,u;return s=new De({props:{code:"ZnJvbSUyMHRyYW5zZm9ybWVycyUyMGltcG9ydCUyMEF1dG9JbWFnZVByb2Nlc3NvciUyQyUyMFZpVEZvck1hc2tlZEltYWdlTW9kZWxpbmclMEFpbXBvcnQlMjB0b3JjaCUwQWZyb20lMjBQSUwlMjBpbXBvcnQlMjBJbWFnZSUwQWltcG9ydCUyMHJlcXVlc3RzJTBBJTBBdXJsJTIwJTNEJTIwJTIyaHR0cCUzQSUyRiUyRmltYWdlcy5jb2NvZGF0YXNldC5vcmclMkZ2YWwyMDE3JTJGMDAwMDAwMDM5NzY5LmpwZyUyMiUwQWltYWdlJTIwJTNEJTIwSW1hZ2Uub3BlbihyZXF1ZXN0cy5nZXQodXJsJTJDJTIwc3RyZWFtJTNEVHJ1ZSkucmF3KSUwQSUwQWltYWdlX3Byb2Nlc3NvciUyMCUzRCUyMEF1dG9JbWFnZVByb2Nlc3Nvci5mcm9tX3ByZXRyYWluZWQoJTIyZ29vZ2xlJTJGdml0LWJhc2UtcGF0Y2gxNi0yMjQtaW4yMWslMjIpJTBBbW9kZWwlMjAlM0QlMjBWaVRGb3JNYXNrZWRJbWFnZU1vZGVsaW5nLmZyb21fcHJldHJhaW5lZCglMjJnb29nbGUlMkZ2aXQtYmFzZS1wYXRjaDE2LTIyNC1pbjIxayUyMiklMEElMEFudW1fcGF0Y2hlcyUyMCUzRCUyMChtb2RlbC5jb25maWcuaW1hZ2Vfc2l6ZSUyMCUyRiUyRiUyMG1vZGVsLmNvbmZpZy5wYXRjaF9zaXplKSUyMCoqJTIwMiUwQXBpeGVsX3ZhbHVlcyUyMCUzRCUyMGltYWdlX3Byb2Nlc3NvcihpbWFnZXMlM0RpbWFnZSUyQyUyMHJldHVybl90ZW5zb3JzJTNEJTIycHQlMjIpLnBpeGVsX3ZhbHVlcyUwQSUyMyUyMGNyZWF0ZSUyMHJhbmRvbSUyMGJvb2xlYW4lMjBtYXNrJTIwb2YlMjBzaGFwZSUyMChiYXRjaF9zaXplJTJDJTIwbnVtX3BhdGNoZXMpJTBBYm9vbF9tYXNrZWRfcG9zJTIwJTNEJTIwdG9yY2gucmFuZGludChsb3clM0QwJTJDJTIwaGlnaCUzRDIlMkMlMjBzaXplJTNEKDElMkMlMjBudW1fcGF0Y2hlcykpLmJvb2woKSUwQSUwQW91dHB1dHMlMjAlM0QlMjBtb2RlbChwaXhlbF92YWx1ZXMlMkMlMjBib29sX21hc2tlZF9wb3MlM0Rib29sX21hc2tlZF9wb3MpJTBBbG9zcyUyQyUyMHJlY29uc3RydWN0ZWRfcGl4ZWxfdmFsdWVzJTIwJTNEJTIwb3V0cHV0cy5sb3NzJTJDJTIwb3V0cHV0cy5yZWNvbnN0cnVjdGlvbiUwQWxpc3QocmVjb25zdHJ1Y3RlZF9waXhlbF92YWx1ZXMuc2hhcGUp",highlighted:`<span class="hljs-meta">&gt;&gt;&gt; </span><span class="hljs-keyword">from</span> transformers <span class="hljs-keyword">import</span> AutoImageProcessor, ViTForMaskedImageModeling
<span class="hljs-meta">&gt;&gt;&gt; </span><span class="hljs-keyword">import</span> torch
<span class="hljs-meta">&gt;&gt;&gt; </span><span class="hljs-keyword">from</span> PIL <span class="hljs-keyword">import</span> Image
<span class="hljs-meta">&gt;&gt;&gt; </span><span class="hljs-keyword">import</span> requests

<span class="hljs-meta">&gt;&gt;&gt; </span>url = <span class="hljs-string">&quot;http://images.cocodataset.org/val2017/000000039769.jpg&quot;</span>
<span class="hljs-meta">&gt;&gt;&gt; </span>image = Image.<span class="hljs-built_in">open</span>(requests.get(url, stream=<span class="hljs-literal">True</span>).raw)

<span class="hljs-meta">&gt;&gt;&gt; </span>image_processor = AutoImageProcessor.from_pretrained(<span class="hljs-string">&quot;google/vit-base-patch16-224-in21k&quot;</span>)
<span class="hljs-meta">&gt;&gt;&gt; </span>model = ViTForMaskedImageModeling.from_pretrained(<span class="hljs-string">&quot;google/vit-base-patch16-224-in21k&quot;</span>)

<span class="hljs-meta">&gt;&gt;&gt; </span>num_patches = (model.config.image_size // model.config.patch_size) ** <span class="hljs-number">2</span>
<span class="hljs-meta">&gt;&gt;&gt; </span>pixel_values = image_processor(images=image, return_tensors=<span class="hljs-string">&quot;pt&quot;</span>).pixel_values
<span class="hljs-meta">&gt;&gt;&gt; </span><span class="hljs-comment"># create random boolean mask of shape (batch_size, num_patches)</span>
<span class="hljs-meta">&gt;&gt;&gt; </span>bool_masked_pos = torch.randint(low=<span class="hljs-number">0</span>, high=<span class="hljs-number">2</span>, size=(<span class="hljs-number">1</span>, num_patches)).<span class="hljs-built_in">bool</span>()

<span class="hljs-meta">&gt;&gt;&gt; </span>outputs = model(pixel_values, bool_masked_pos=bool_masked_pos)
<span class="hljs-meta">&gt;&gt;&gt; </span>loss, reconstructed_pixel_values = outputs.loss, outputs.reconstruction
<span class="hljs-meta">&gt;&gt;&gt; </span><span class="hljs-built_in">list</span>(reconstructed_pixel_values.shape)
[<span class="hljs-number">1</span>, <span class="hljs-number">3</span>, <span class="hljs-number">224</span>, <span class="hljs-number">224</span>]`,wrap:!1}}),{c(){e=c("p"),e.textContent=p,t=r(),b(s.$$.fragment)},l(n){e=m(n,"P",{"data-svelte-h":!0}),f(e)!=="svelte-kvfsh7"&&(e.textContent=p),t=i(n),y(s.$$.fragment,n)},m(n,x){l(n,e,x),l(n,t,x),v(s,n,x),u=!0},p:be,i(n){u||(w(s.$$.fragment,n),u=!0)},o(n){M(s.$$.fragment,n),u=!1},d(n){n&&(a(e),a(t)),$(s,n)}}}function Dt(V){let e,p=`Note that it’s possible to fine-tune ViT on higher resolution images than the ones it has been trained on, by
setting <code>interpolate_pos_encoding</code> to <code>True</code> in the forward of the model. This will interpolate the pre-trained
position embeddings to the higher resolution.`;return{c(){e=c("p"),e.innerHTML=p},l(t){e=m(t,"P",{"data-svelte-h":!0}),f(e)!=="svelte-111lhr1"&&(e.innerHTML=p)},m(t,s){l(t,e,s)},p:be,d(t){t&&a(e)}}}function At(V){let e,p=`Although the recipe for forward pass needs to be defined within this function, one should call the <code>Module</code>
instance afterwards instead of this since the former takes care of running the pre and post processing steps while
the latter silently ignores them.`;return{c(){e=c("p"),e.innerHTML=p},l(t){e=m(t,"P",{"data-svelte-h":!0}),f(e)!=="svelte-fincs2"&&(e.innerHTML=p)},m(t,s){l(t,e,s)},p:be,d(t){t&&a(e)}}}function Ot(V){let e,p="Example:",t,s,u;return s=new De({props:{code:"ZnJvbSUyMHRyYW5zZm9ybWVycyUyMGltcG9ydCUyMEF1dG9JbWFnZVByb2Nlc3NvciUyQyUyMFZpVEZvckltYWdlQ2xhc3NpZmljYXRpb24lMEFpbXBvcnQlMjB0b3JjaCUwQWZyb20lMjBkYXRhc2V0cyUyMGltcG9ydCUyMGxvYWRfZGF0YXNldCUwQSUwQWRhdGFzZXQlMjAlM0QlMjBsb2FkX2RhdGFzZXQoJTIyaHVnZ2luZ2ZhY2UlMkZjYXRzLWltYWdlJTIyKSUwQWltYWdlJTIwJTNEJTIwZGF0YXNldCU1QiUyMnRlc3QlMjIlNUQlNUIlMjJpbWFnZSUyMiU1RCU1QjAlNUQlMEElMEFpbWFnZV9wcm9jZXNzb3IlMjAlM0QlMjBBdXRvSW1hZ2VQcm9jZXNzb3IuZnJvbV9wcmV0cmFpbmVkKCUyMmdvb2dsZSUyRnZpdC1iYXNlLXBhdGNoMTYtMjI0JTIyKSUwQW1vZGVsJTIwJTNEJTIwVmlURm9ySW1hZ2VDbGFzc2lmaWNhdGlvbi5mcm9tX3ByZXRyYWluZWQoJTIyZ29vZ2xlJTJGdml0LWJhc2UtcGF0Y2gxNi0yMjQlMjIpJTBBJTBBaW5wdXRzJTIwJTNEJTIwaW1hZ2VfcHJvY2Vzc29yKGltYWdlJTJDJTIwcmV0dXJuX3RlbnNvcnMlM0QlMjJwdCUyMiklMEElMEF3aXRoJTIwdG9yY2gubm9fZ3JhZCgpJTNBJTBBJTIwJTIwJTIwJTIwbG9naXRzJTIwJTNEJTIwbW9kZWwoKippbnB1dHMpLmxvZ2l0cyUwQSUwQSUyMyUyMG1vZGVsJTIwcHJlZGljdHMlMjBvbmUlMjBvZiUyMHRoZSUyMDEwMDAlMjBJbWFnZU5ldCUyMGNsYXNzZXMlMEFwcmVkaWN0ZWRfbGFiZWwlMjAlM0QlMjBsb2dpdHMuYXJnbWF4KC0xKS5pdGVtKCklMEFwcmludChtb2RlbC5jb25maWcuaWQybGFiZWwlNUJwcmVkaWN0ZWRfbGFiZWwlNUQp",highlighted:`<span class="hljs-meta">&gt;&gt;&gt; </span><span class="hljs-keyword">from</span> transformers <span class="hljs-keyword">import</span> AutoImageProcessor, ViTForImageClassification
<span class="hljs-meta">&gt;&gt;&gt; </span><span class="hljs-keyword">import</span> torch
<span class="hljs-meta">&gt;&gt;&gt; </span><span class="hljs-keyword">from</span> datasets <span class="hljs-keyword">import</span> load_dataset

<span class="hljs-meta">&gt;&gt;&gt; </span>dataset = load_dataset(<span class="hljs-string">&quot;huggingface/cats-image&quot;</span>)
<span class="hljs-meta">&gt;&gt;&gt; </span>image = dataset[<span class="hljs-string">&quot;test&quot;</span>][<span class="hljs-string">&quot;image&quot;</span>][<span class="hljs-number">0</span>]

<span class="hljs-meta">&gt;&gt;&gt; </span>image_processor = AutoImageProcessor.from_pretrained(<span class="hljs-string">&quot;google/vit-base-patch16-224&quot;</span>)
<span class="hljs-meta">&gt;&gt;&gt; </span>model = ViTForImageClassification.from_pretrained(<span class="hljs-string">&quot;google/vit-base-patch16-224&quot;</span>)

<span class="hljs-meta">&gt;&gt;&gt; </span>inputs = image_processor(image, return_tensors=<span class="hljs-string">&quot;pt&quot;</span>)

<span class="hljs-meta">&gt;&gt;&gt; </span><span class="hljs-keyword">with</span> torch.no_grad():
<span class="hljs-meta">... </span>    logits = model(**inputs).logits

<span class="hljs-meta">&gt;&gt;&gt; </span><span class="hljs-comment"># model predicts one of the 1000 ImageNet classes</span>
<span class="hljs-meta">&gt;&gt;&gt; </span>predicted_label = logits.argmax(-<span class="hljs-number">1</span>).item()
<span class="hljs-meta">&gt;&gt;&gt; </span><span class="hljs-built_in">print</span>(model.config.id2label[predicted_label])
Egyptian cat`,wrap:!1}}),{c(){e=c("p"),e.textContent=p,t=r(),b(s.$$.fragment)},l(n){e=m(n,"P",{"data-svelte-h":!0}),f(e)!=="svelte-11lpom8"&&(e.textContent=p),t=i(n),y(s.$$.fragment,n)},m(n,x){l(n,e,x),l(n,t,x),v(s,n,x),u=!0},p:be,i(n){u||(w(s.$$.fragment,n),u=!0)},o(n){M(s.$$.fragment,n),u=!1},d(n){n&&(a(e),a(t)),$(s,n)}}}function Kt(V){let e,p,t,s,u,n,x=`The bare ViT Model transformer outputting raw hidden-states without any specific head on top.
This model is a PyTorch <a href="https://pytorch.org/docs/stable/nn.html#torch.nn.Module" rel="nofollow">torch.nn.Module</a> subclass. Use it
as a regular PyTorch Module and refer to the PyTorch documentation for all matter related to general usage and
behavior.`,re,I,P,ie,W,S='The <a href="/docs/transformers/main/en/model_doc/vit#transformers.ViTModel">ViTModel</a> forward method, overrides the <code>__call__</code> special method.',le,g,N,E,X,Ce,_e,J,de,me,D,je='ViT Model with a decoder on top for masked image modeling, as proposed in <a href="https://arxiv.org/abs/2111.09886" rel="nofollow">SimMIM</a>.',Ie,z,ze,U,te=`This model is a PyTorch <a href="https://pytorch.org/docs/stable/nn.html#torch.nn.Module" rel="nofollow">torch.nn.Module</a> subclass. Use it
as a regular PyTorch Module and refer to the PyTorch documentation for all matter related to general usage and
behavior.`,$e,q,Z,xe,O,pe='The <a href="/docs/transformers/main/en/model_doc/vit#transformers.ViTForMaskedImageModeling">ViTForMaskedImageModeling</a> forward method, overrides the <code>__call__</code> special method.',Fe,oe,ke,ne,ye,se,K,Q,H,ce,Ue,he=`ViT Model transformer with an image classification head on top (a linear layer on top of the final hidden state of
the [CLS] token) e.g. for ImageNet.`,Je,fe,L,ge,Te=`This model is a PyTorch <a href="https://pytorch.org/docs/stable/nn.html#torch.nn.Module" rel="nofollow">torch.nn.Module</a> subclass. Use it
as a regular PyTorch Module and refer to the PyTorch documentation for all matter related to general usage and
behavior.`,ae,_,C,R,B,Y='The <a href="/docs/transformers/main/en/model_doc/vit#transformers.ViTForImageClassification">ViTForImageClassification</a> forward method, overrides the <code>__call__</code> special method.',ve,F,k,G,A;return e=new Pe({props:{title:"ViTModel",local:"transformers.ViTModel",headingTag:"h2"}}),s=new Me({props:{name:"class transformers.ViTModel",anchor:"transformers.ViTModel",parameters:[{name:"config",val:": ViTConfig"},{name:"add_pooling_layer",val:": bool = True"},{name:"use_mask_token",val:": bool = False"}],parametersDescription:[{anchor:"transformers.ViTModel.config",description:`<strong>config</strong> (<a href="/docs/transformers/main/en/model_doc/vit#transformers.ViTConfig">ViTConfig</a>) &#x2014; Model configuration class with all the parameters of the model.
Initializing with a config file does not load the weights associated with the model, only the
configuration. Check out the <a href="/docs/transformers/main/en/main_classes/model#transformers.PreTrainedModel.from_pretrained">from_pretrained()</a> method to load the model weights.`,name:"config"}],source:"https://github.com/huggingface/transformers/blob/main/src/transformers/models/vit/modeling_vit.py#L505"}}),P=new Me({props:{name:"forward",anchor:"transformers.ViTModel.forward",parameters:[{name:"pixel_values",val:": typing.Optional[torch.Tensor] = None"},{name:"bool_masked_pos",val:": typing.Optional[torch.BoolTensor] = None"},{name:"head_mask",val:": typing.Optional[torch.Tensor] = None"},{name:"output_attentions",val:": typing.Optional[bool] = None"},{name:"output_hidden_states",val:": typing.Optional[bool] = None"},{name:"interpolate_pos_encoding",val:": typing.Optional[bool] = None"},{name:"return_dict",val:": typing.Optional[bool] = None"}],parametersDescription:[{anchor:"transformers.ViTModel.forward.pixel_values",description:`<strong>pixel_values</strong> (<code>torch.FloatTensor</code> of shape <code>(batch_size, num_channels, height, width)</code>) &#x2014;
Pixel values. Pixel values can be obtained using <a href="/docs/transformers/main/en/model_doc/auto#transformers.AutoImageProcessor">AutoImageProcessor</a>. See <a href="/docs/transformers/main/en/model_doc/dpt#transformers.DPTFeatureExtractor.__call__">ViTImageProcessor.<strong>call</strong>()</a>
for details.`,name:"pixel_values"},{anchor:"transformers.ViTModel.forward.head_mask",description:`<strong>head_mask</strong> (<code>torch.FloatTensor</code> of shape <code>(num_heads,)</code> or <code>(num_layers, num_heads)</code>, <em>optional</em>) &#x2014;
Mask to nullify selected heads of the self-attention modules. Mask values selected in <code>[0, 1]</code>:</p>
<ul>
<li>1 indicates the head is <strong>not masked</strong>,</li>
<li>0 indicates the head is <strong>masked</strong>.</li>
</ul>`,name:"head_mask"},{anchor:"transformers.ViTModel.forward.output_attentions",description:`<strong>output_attentions</strong> (<code>bool</code>, <em>optional</em>) &#x2014;
Whether or not to return the attentions tensors of all attention layers. See <code>attentions</code> under returned
tensors for more detail.`,name:"output_attentions"},{anchor:"transformers.ViTModel.forward.output_hidden_states",description:`<strong>output_hidden_states</strong> (<code>bool</code>, <em>optional</em>) &#x2014;
Whether or not to return the hidden states of all layers. See <code>hidden_states</code> under returned tensors for
more detail.`,name:"output_hidden_states"},{anchor:"transformers.ViTModel.forward.interpolate_pos_encoding",description:`<strong>interpolate_pos_encoding</strong> (<code>bool</code>, <em>optional</em>) &#x2014;
Whether to interpolate the pre-trained position encodings.`,name:"interpolate_pos_encoding"},{anchor:"transformers.ViTModel.forward.return_dict",description:`<strong>return_dict</strong> (<code>bool</code>, <em>optional</em>) &#x2014;
Whether or not to return a <a href="/docs/transformers/main/en/main_classes/output#transformers.utils.ModelOutput">ModelOutput</a> instead of a plain tuple.`,name:"return_dict"},{anchor:"transformers.ViTModel.forward.bool_masked_pos",description:`<strong>bool_masked_pos</strong> (<code>torch.BoolTensor</code> of shape <code>(batch_size, num_patches)</code>, <em>optional</em>) &#x2014;
Boolean masked positions. Indicates which patches are masked (1) and which aren&#x2019;t (0).`,name:"bool_masked_pos"}],source:"https://github.com/huggingface/transformers/blob/main/src/transformers/models/vit/modeling_vit.py#L530",returnDescription:`<script context="module">export const metadata = 'undefined';<\/script>


<p>A <a
  href="/docs/transformers/main/en/main_classes/output#transformers.modeling_outputs.BaseModelOutputWithPooling"
>transformers.modeling_outputs.BaseModelOutputWithPooling</a> or a tuple of
<code>torch.FloatTensor</code> (if <code>return_dict=False</code> is passed or when <code>config.return_dict=False</code>) comprising various
elements depending on the configuration (<a
  href="/docs/transformers/main/en/model_doc/vit#transformers.ViTConfig"
>ViTConfig</a>) and inputs.</p>
<ul>
<li>
<p><strong>last_hidden_state</strong> (<code>torch.FloatTensor</code> of shape <code>(batch_size, sequence_length, hidden_size)</code>) — Sequence of hidden-states at the output of the last layer of the model.</p>
</li>
<li>
<p><strong>pooler_output</strong> (<code>torch.FloatTensor</code> of shape <code>(batch_size, hidden_size)</code>) — Last layer hidden-state of the first token of the sequence (classification token) after further processing
through the layers used for the auxiliary pretraining task. E.g. for BERT-family of models, this returns
the classification token after processing through a linear layer and a tanh activation function. The linear
layer weights are trained from the next sentence prediction (classification) objective during pretraining.</p>
</li>
<li>
<p><strong>hidden_states</strong> (<code>tuple(torch.FloatTensor)</code>, <em>optional</em>, returned when <code>output_hidden_states=True</code> is passed or when <code>config.output_hidden_states=True</code>) — Tuple of <code>torch.FloatTensor</code> (one for the output of the embeddings, if the model has an embedding layer, +
one for the output of each layer) of shape <code>(batch_size, sequence_length, hidden_size)</code>.</p>
<p>Hidden-states of the model at the output of each layer plus the optional initial embedding outputs.</p>
</li>
<li>
<p><strong>attentions</strong> (<code>tuple(torch.FloatTensor)</code>, <em>optional</em>, returned when <code>output_attentions=True</code> is passed or when <code>config.output_attentions=True</code>) — Tuple of <code>torch.FloatTensor</code> (one for each layer) of shape <code>(batch_size, num_heads, sequence_length, sequence_length)</code>.</p>
<p>Attentions weights after the attention softmax, used to compute the weighted average in the self-attention
heads.</p>
</li>
</ul>
`,returnType:`<script context="module">export const metadata = 'undefined';<\/script>


<p><a
  href="/docs/transformers/main/en/main_classes/output#transformers.modeling_outputs.BaseModelOutputWithPooling"
>transformers.modeling_outputs.BaseModelOutputWithPooling</a> or <code>tuple(torch.FloatTensor)</code></p>
`}}),g=new He({props:{$$slots:{default:[qt]},$$scope:{ctx:V}}}),E=new Qe({props:{anchor:"transformers.ViTModel.forward.example",$$slots:{default:[Xt]},$$scope:{ctx:V}}}),Ce=new Pe({props:{title:"ViTForMaskedImageModeling",local:"transformers.ViTForMaskedImageModeling",headingTag:"h2"}}),de=new Me({props:{name:"class transformers.ViTForMaskedImageModeling",anchor:"transformers.ViTForMaskedImageModeling",parameters:[{name:"config",val:": ViTConfig"}],parametersDescription:[{anchor:"transformers.ViTForMaskedImageModeling.config",description:`<strong>config</strong> (<a href="/docs/transformers/main/en/model_doc/vit#transformers.ViTConfig">ViTConfig</a>) &#x2014; Model configuration class with all the parameters of the model.
Initializing with a config file does not load the weights associated with the model, only the
configuration. Check out the <a href="/docs/transformers/main/en/main_classes/model#transformers.PreTrainedModel.from_pretrained">from_pretrained()</a> method to load the model weights.`,name:"config"}],source:"https://github.com/huggingface/transformers/blob/main/src/transformers/models/vit/modeling_vit.py#L627"}}),z=new He({props:{$$slots:{default:[Yt]},$$scope:{ctx:V}}}),Z=new Me({props:{name:"forward",anchor:"transformers.ViTForMaskedImageModeling.forward",parameters:[{name:"pixel_values",val:": typing.Optional[torch.Tensor] = None"},{name:"bool_masked_pos",val:": typing.Optional[torch.BoolTensor] = None"},{name:"head_mask",val:": typing.Optional[torch.Tensor] = None"},{name:"output_attentions",val:": typing.Optional[bool] = None"},{name:"output_hidden_states",val:": typing.Optional[bool] = None"},{name:"interpolate_pos_encoding",val:": typing.Optional[bool] = None"},{name:"return_dict",val:": typing.Optional[bool] = None"}],parametersDescription:[{anchor:"transformers.ViTForMaskedImageModeling.forward.pixel_values",description:`<strong>pixel_values</strong> (<code>torch.FloatTensor</code> of shape <code>(batch_size, num_channels, height, width)</code>) &#x2014;
Pixel values. Pixel values can be obtained using <a href="/docs/transformers/main/en/model_doc/auto#transformers.AutoImageProcessor">AutoImageProcessor</a>. See <a href="/docs/transformers/main/en/model_doc/dpt#transformers.DPTFeatureExtractor.__call__">ViTImageProcessor.<strong>call</strong>()</a>
for details.`,name:"pixel_values"},{anchor:"transformers.ViTForMaskedImageModeling.forward.head_mask",description:`<strong>head_mask</strong> (<code>torch.FloatTensor</code> of shape <code>(num_heads,)</code> or <code>(num_layers, num_heads)</code>, <em>optional</em>) &#x2014;
Mask to nullify selected heads of the self-attention modules. Mask values selected in <code>[0, 1]</code>:</p>
<ul>
<li>1 indicates the head is <strong>not masked</strong>,</li>
<li>0 indicates the head is <strong>masked</strong>.</li>
</ul>`,name:"head_mask"},{anchor:"transformers.ViTForMaskedImageModeling.forward.output_attentions",description:`<strong>output_attentions</strong> (<code>bool</code>, <em>optional</em>) &#x2014;
Whether or not to return the attentions tensors of all attention layers. See <code>attentions</code> under returned
tensors for more detail.`,name:"output_attentions"},{anchor:"transformers.ViTForMaskedImageModeling.forward.output_hidden_states",description:`<strong>output_hidden_states</strong> (<code>bool</code>, <em>optional</em>) &#x2014;
Whether or not to return the hidden states of all layers. See <code>hidden_states</code> under returned tensors for
more detail.`,name:"output_hidden_states"},{anchor:"transformers.ViTForMaskedImageModeling.forward.interpolate_pos_encoding",description:`<strong>interpolate_pos_encoding</strong> (<code>bool</code>, <em>optional</em>) &#x2014;
Whether to interpolate the pre-trained position encodings.`,name:"interpolate_pos_encoding"},{anchor:"transformers.ViTForMaskedImageModeling.forward.return_dict",description:`<strong>return_dict</strong> (<code>bool</code>, <em>optional</em>) &#x2014;
Whether or not to return a <a href="/docs/transformers/main/en/main_classes/output#transformers.utils.ModelOutput">ModelOutput</a> instead of a plain tuple.`,name:"return_dict"},{anchor:"transformers.ViTForMaskedImageModeling.forward.bool_masked_pos",description:`<strong>bool_masked_pos</strong> (<code>torch.BoolTensor</code> of shape <code>(batch_size, num_patches)</code>) &#x2014;
Boolean masked positions. Indicates which patches are masked (1) and which aren&#x2019;t (0).`,name:"bool_masked_pos"}],source:"https://github.com/huggingface/transformers/blob/main/src/transformers/models/vit/modeling_vit.py#L645",returnDescription:`<script context="module">export const metadata = 'undefined';<\/script>


<p>A <code>transformers.modeling_outputs.MaskedImageModelingOutput</code> or a tuple of
<code>torch.FloatTensor</code> (if <code>return_dict=False</code> is passed or when <code>config.return_dict=False</code>) comprising various
elements depending on the configuration (<a
  href="/docs/transformers/main/en/model_doc/vit#transformers.ViTConfig"
>ViTConfig</a>) and inputs.</p>
<ul>
<li><strong>loss</strong> (<code>torch.FloatTensor</code> of shape <code>(1,)</code>, <em>optional</em>, returned when <code>bool_masked_pos</code> is provided) — Reconstruction loss.</li>
<li><strong>reconstruction</strong> (<code>torch.FloatTensor</code> of shape <code>(batch_size, num_channels, height, width)</code>) — Reconstructed / completed images.</li>
<li><strong>hidden_states</strong> (<code>tuple(torch.FloatTensor)</code>, <em>optional</em>, returned when <code>output_hidden_states=True</code> is passed or</li>
<li><strong>when</strong> <code>config.output_hidden_states=True</code>) — Tuple of <code>torch.FloatTensor</code> (one for the output of the embeddings, if the model has an embedding layer, +
one for the output of each stage) of shape <code>(batch_size, sequence_length, hidden_size)</code>. Hidden-states
(also called feature maps) of the model at the output of each stage.</li>
<li><strong>attentions</strong> (<code>tuple(torch.FloatTensor)</code>, <em>optional</em>, returned when <code>output_attentions=True</code> is passed or when</li>
<li><strong><code>config.output_attentions=True</code>):</strong>
Tuple of <code>torch.FloatTensor</code> (one for each layer) of shape <code>(batch_size, num_heads, patch_size, sequence_length)</code>. Attentions weights after the attention softmax, used to compute the weighted average in
the self-attention heads.</li>
</ul>
`,returnType:`<script context="module">export const metadata = 'undefined';<\/script>


<p><code>transformers.modeling_outputs.MaskedImageModelingOutput</code> or <code>tuple(torch.FloatTensor)</code></p>
`}}),oe=new He({props:{$$slots:{default:[St]},$$scope:{ctx:V}}}),ne=new Qe({props:{anchor:"transformers.ViTForMaskedImageModeling.forward.example",$$slots:{default:[Qt]},$$scope:{ctx:V}}}),se=new Pe({props:{title:"ViTForImageClassification",local:"transformers.ViTForImageClassification",headingTag:"h2"}}),H=new Me({props:{name:"class transformers.ViTForImageClassification",anchor:"transformers.ViTForImageClassification",parameters:[{name:"config",val:": ViTConfig"}],parametersDescription:[{anchor:"transformers.ViTForImageClassification.config",description:`<strong>config</strong> (<a href="/docs/transformers/main/en/model_doc/vit#transformers.ViTConfig">ViTConfig</a>) &#x2014; Model configuration class with all the parameters of the model.
Initializing with a config file does not load the weights associated with the model, only the
configuration. Check out the <a href="/docs/transformers/main/en/main_classes/model#transformers.PreTrainedModel.from_pretrained">from_pretrained()</a> method to load the model weights.`,name:"config"}],source:"https://github.com/huggingface/transformers/blob/main/src/transformers/models/vit/modeling_vit.py#L756"}}),fe=new He({props:{$$slots:{default:[Dt]},$$scope:{ctx:V}}}),C=new Me({props:{name:"forward",anchor:"transformers.ViTForImageClassification.forward",parameters:[{name:"pixel_values",val:": typing.Optional[torch.Tensor] = None"},{name:"head_mask",val:": typing.Optional[torch.Tensor] = None"},{name:"labels",val:": typing.Optional[torch.Tensor] = None"},{name:"output_attentions",val:": typing.Optional[bool] = None"},{name:"output_hidden_states",val:": typing.Optional[bool] = None"},{name:"interpolate_pos_encoding",val:": typing.Optional[bool] = None"},{name:"return_dict",val:": typing.Optional[bool] = None"}],parametersDescription:[{anchor:"transformers.ViTForImageClassification.forward.pixel_values",description:`<strong>pixel_values</strong> (<code>torch.FloatTensor</code> of shape <code>(batch_size, num_channels, height, width)</code>) &#x2014;
Pixel values. Pixel values can be obtained using <a href="/docs/transformers/main/en/model_doc/auto#transformers.AutoImageProcessor">AutoImageProcessor</a>. See <a href="/docs/transformers/main/en/model_doc/dpt#transformers.DPTFeatureExtractor.__call__">ViTImageProcessor.<strong>call</strong>()</a>
for details.`,name:"pixel_values"},{anchor:"transformers.ViTForImageClassification.forward.head_mask",description:`<strong>head_mask</strong> (<code>torch.FloatTensor</code> of shape <code>(num_heads,)</code> or <code>(num_layers, num_heads)</code>, <em>optional</em>) &#x2014;
Mask to nullify selected heads of the self-attention modules. Mask values selected in <code>[0, 1]</code>:</p>
<ul>
<li>1 indicates the head is <strong>not masked</strong>,</li>
<li>0 indicates the head is <strong>masked</strong>.</li>
</ul>`,name:"head_mask"},{anchor:"transformers.ViTForImageClassification.forward.output_attentions",description:`<strong>output_attentions</strong> (<code>bool</code>, <em>optional</em>) &#x2014;
Whether or not to return the attentions tensors of all attention layers. See <code>attentions</code> under returned
tensors for more detail.`,name:"output_attentions"},{anchor:"transformers.ViTForImageClassification.forward.output_hidden_states",description:`<strong>output_hidden_states</strong> (<code>bool</code>, <em>optional</em>) &#x2014;
Whether or not to return the hidden states of all layers. See <code>hidden_states</code> under returned tensors for
more detail.`,name:"output_hidden_states"},{anchor:"transformers.ViTForImageClassification.forward.interpolate_pos_encoding",description:`<strong>interpolate_pos_encoding</strong> (<code>bool</code>, <em>optional</em>) &#x2014;
Whether to interpolate the pre-trained position encodings.`,name:"interpolate_pos_encoding"},{anchor:"transformers.ViTForImageClassification.forward.return_dict",description:`<strong>return_dict</strong> (<code>bool</code>, <em>optional</em>) &#x2014;
Whether or not to return a <a href="/docs/transformers/main/en/main_classes/output#transformers.utils.ModelOutput">ModelOutput</a> instead of a plain tuple.`,name:"return_dict"},{anchor:"transformers.ViTForImageClassification.forward.labels",description:`<strong>labels</strong> (<code>torch.LongTensor</code> of shape <code>(batch_size,)</code>, <em>optional</em>) &#x2014;
Labels for computing the image classification/regression loss. Indices should be in <code>[0, ..., config.num_labels - 1]</code>. If <code>config.num_labels == 1</code> a regression loss is computed (Mean-Square loss), If
<code>config.num_labels &gt; 1</code> a classification loss is computed (Cross-Entropy).`,name:"labels"}],source:"https://github.com/huggingface/transformers/blob/main/src/transformers/models/vit/modeling_vit.py#L769",returnDescription:`<script context="module">export const metadata = 'undefined';<\/script>


<p>A <a
  href="/docs/transformers/main/en/main_classes/output#transformers.modeling_outputs.ImageClassifierOutput"
>transformers.modeling_outputs.ImageClassifierOutput</a> or a tuple of
<code>torch.FloatTensor</code> (if <code>return_dict=False</code> is passed or when <code>config.return_dict=False</code>) comprising various
elements depending on the configuration (<a
  href="/docs/transformers/main/en/model_doc/vit#transformers.ViTConfig"
>ViTConfig</a>) and inputs.</p>
<ul>
<li>
<p><strong>loss</strong> (<code>torch.FloatTensor</code> of shape <code>(1,)</code>, <em>optional</em>, returned when <code>labels</code> is provided) — Classification (or regression if config.num_labels==1) loss.</p>
</li>
<li>
<p><strong>logits</strong> (<code>torch.FloatTensor</code> of shape <code>(batch_size, config.num_labels)</code>) — Classification (or regression if config.num_labels==1) scores (before SoftMax).</p>
</li>
<li>
<p><strong>hidden_states</strong> (<code>tuple(torch.FloatTensor)</code>, <em>optional</em>, returned when <code>output_hidden_states=True</code> is passed or when <code>config.output_hidden_states=True</code>) — Tuple of <code>torch.FloatTensor</code> (one for the output of the embeddings, if the model has an embedding layer, +
one for the output of each stage) of shape <code>(batch_size, sequence_length, hidden_size)</code>. Hidden-states
(also called feature maps) of the model at the output of each stage.</p>
</li>
<li>
<p><strong>attentions</strong> (<code>tuple(torch.FloatTensor)</code>, <em>optional</em>, returned when <code>output_attentions=True</code> is passed or when <code>config.output_attentions=True</code>) — Tuple of <code>torch.FloatTensor</code> (one for each layer) of shape <code>(batch_size, num_heads, patch_size, sequence_length)</code>.</p>
<p>Attentions weights after the attention softmax, used to compute the weighted average in the self-attention
heads.</p>
</li>
</ul>
`,returnType:`<script context="module">export const metadata = 'undefined';<\/script>


<p><a
  href="/docs/transformers/main/en/main_classes/output#transformers.modeling_outputs.ImageClassifierOutput"
>transformers.modeling_outputs.ImageClassifierOutput</a> or <code>tuple(torch.FloatTensor)</code></p>
`}}),F=new He({props:{$$slots:{default:[At]},$$scope:{ctx:V}}}),G=new Qe({props:{anchor:"transformers.ViTForImageClassification.forward.example",$$slots:{default:[Ot]},$$scope:{ctx:V}}}),{c(){b(e.$$.fragment),p=r(),t=c("div"),b(s.$$.fragment),u=r(),n=c("p"),n.innerHTML=x,re=r(),I=c("div"),b(P.$$.fragment),ie=r(),W=c("p"),W.innerHTML=S,le=r(),b(g.$$.fragment),N=r(),b(E.$$.fragment),X=r(),b(Ce.$$.fragment),_e=r(),J=c("div"),b(de.$$.fragment),me=r(),D=c("p"),D.innerHTML=je,Ie=r(),b(z.$$.fragment),ze=r(),U=c("p"),U.innerHTML=te,$e=r(),q=c("div"),b(Z.$$.fragment),xe=r(),O=c("p"),O.innerHTML=pe,Fe=r(),b(oe.$$.fragment),ke=r(),b(ne.$$.fragment),ye=r(),b(se.$$.fragment),K=r(),Q=c("div"),b(H.$$.fragment),ce=r(),Ue=c("p"),Ue.textContent=he,Je=r(),b(fe.$$.fragment),L=r(),ge=c("p"),ge.innerHTML=Te,ae=r(),_=c("div"),b(C.$$.fragment),R=r(),B=c("p"),B.innerHTML=Y,ve=r(),b(F.$$.fragment),k=r(),b(G.$$.fragment),this.h()},l(h){y(e.$$.fragment,h),p=i(h),t=m(h,"DIV",{class:!0});var j=ue(t);y(s.$$.fragment,j),u=i(j),n=m(j,"P",{"data-svelte-h":!0}),f(n)!=="svelte-ulamh0"&&(n.innerHTML=x),re=i(j),I=m(j,"DIV",{class:!0});var Le=ue(I);y(P.$$.fragment,Le),ie=i(Le),W=m(Le,"P",{"data-svelte-h":!0}),f(W)!=="svelte-1ubaew4"&&(W.innerHTML=S),le=i(Le),y(g.$$.fragment,Le),N=i(Le),y(E.$$.fragment,Le),Le.forEach(a),j.forEach(a),X=i(h),y(Ce.$$.fragment,h),_e=i(h),J=m(h,"DIV",{class:!0});var Ve=ue(J);y(de.$$.fragment,Ve),me=i(Ve),D=m(Ve,"P",{"data-svelte-h":!0}),f(D)!=="svelte-hwvz1m"&&(D.innerHTML=je),Ie=i(Ve),y(z.$$.fragment,Ve),ze=i(Ve),U=m(Ve,"P",{"data-svelte-h":!0}),f(U)!=="svelte-1gjh92c"&&(U.innerHTML=te),$e=i(Ve),q=m(Ve,"DIV",{class:!0});var we=ue(q);y(Z.$$.fragment,we),xe=i(we),O=m(we,"P",{"data-svelte-h":!0}),f(O)!=="svelte-1xeok0o"&&(O.innerHTML=pe),Fe=i(we),y(oe.$$.fragment,we),ke=i(we),y(ne.$$.fragment,we),we.forEach(a),Ve.forEach(a),ye=i(h),y(se.$$.fragment,h),K=i(h),Q=m(h,"DIV",{class:!0});var We=ue(Q);y(H.$$.fragment,We),ce=i(We),Ue=m(We,"P",{"data-svelte-h":!0}),f(Ue)!=="svelte-ju5wm2"&&(Ue.textContent=he),Je=i(We),y(fe.$$.fragment,We),L=i(We),ge=m(We,"P",{"data-svelte-h":!0}),f(ge)!=="svelte-1gjh92c"&&(ge.innerHTML=Te),ae=i(We),_=m(We,"DIV",{class:!0});var Ze=ue(_);y(C.$$.fragment,Ze),R=i(Ze),B=m(Ze,"P",{"data-svelte-h":!0}),f(B)!=="svelte-1nzehrg"&&(B.innerHTML=Y),ve=i(Ze),y(F.$$.fragment,Ze),k=i(Ze),y(G.$$.fragment,Ze),Ze.forEach(a),We.forEach(a),this.h()},h(){ee(I,"class","docstring border-l-2 border-t-2 pl-4 pt-3.5 border-gray-100 rounded-tl-xl mb-6 mt-8"),ee(t,"class","docstring border-l-2 border-t-2 pl-4 pt-3.5 border-gray-100 rounded-tl-xl mb-6 mt-8"),ee(q,"class","docstring border-l-2 border-t-2 pl-4 pt-3.5 border-gray-100 rounded-tl-xl mb-6 mt-8"),ee(J,"class","docstring border-l-2 border-t-2 pl-4 pt-3.5 border-gray-100 rounded-tl-xl mb-6 mt-8"),ee(_,"class","docstring border-l-2 border-t-2 pl-4 pt-3.5 border-gray-100 rounded-tl-xl mb-6 mt-8"),ee(Q,"class","docstring border-l-2 border-t-2 pl-4 pt-3.5 border-gray-100 rounded-tl-xl mb-6 mt-8")},m(h,j){v(e,h,j),l(h,p,j),l(h,t,j),v(s,t,null),d(t,u),d(t,n),d(t,re),d(t,I),v(P,I,null),d(I,ie),d(I,W),d(I,le),v(g,I,null),d(I,N),v(E,I,null),l(h,X,j),v(Ce,h,j),l(h,_e,j),l(h,J,j),v(de,J,null),d(J,me),d(J,D),d(J,Ie),v(z,J,null),d(J,ze),d(J,U),d(J,$e),d(J,q),v(Z,q,null),d(q,xe),d(q,O),d(q,Fe),v(oe,q,null),d(q,ke),v(ne,q,null),l(h,ye,j),v(se,h,j),l(h,K,j),l(h,Q,j),v(H,Q,null),d(Q,ce),d(Q,Ue),d(Q,Je),v(fe,Q,null),d(Q,L),d(Q,ge),d(Q,ae),d(Q,_),v(C,_,null),d(_,R),d(_,B),d(_,ve),v(F,_,null),d(_,k),v(G,_,null),A=!0},p(h,j){const Le={};j&2&&(Le.$$scope={dirty:j,ctx:h}),g.$set(Le);const Ve={};j&2&&(Ve.$$scope={dirty:j,ctx:h}),E.$set(Ve);const we={};j&2&&(we.$$scope={dirty:j,ctx:h}),z.$set(we);const We={};j&2&&(We.$$scope={dirty:j,ctx:h}),oe.$set(We);const Ze={};j&2&&(Ze.$$scope={dirty:j,ctx:h}),ne.$set(Ze);const Ge={};j&2&&(Ge.$$scope={dirty:j,ctx:h}),fe.$set(Ge);const Ae={};j&2&&(Ae.$$scope={dirty:j,ctx:h}),F.$set(Ae);const Ne={};j&2&&(Ne.$$scope={dirty:j,ctx:h}),G.$set(Ne)},i(h){A||(w(e.$$.fragment,h),w(s.$$.fragment,h),w(P.$$.fragment,h),w(g.$$.fragment,h),w(E.$$.fragment,h),w(Ce.$$.fragment,h),w(de.$$.fragment,h),w(z.$$.fragment,h),w(Z.$$.fragment,h),w(oe.$$.fragment,h),w(ne.$$.fragment,h),w(se.$$.fragment,h),w(H.$$.fragment,h),w(fe.$$.fragment,h),w(C.$$.fragment,h),w(F.$$.fragment,h),w(G.$$.fragment,h),A=!0)},o(h){M(e.$$.fragment,h),M(s.$$.fragment,h),M(P.$$.fragment,h),M(g.$$.fragment,h),M(E.$$.fragment,h),M(Ce.$$.fragment,h),M(de.$$.fragment,h),M(z.$$.fragment,h),M(Z.$$.fragment,h),M(oe.$$.fragment,h),M(ne.$$.fragment,h),M(se.$$.fragment,h),M(H.$$.fragment,h),M(fe.$$.fragment,h),M(C.$$.fragment,h),M(F.$$.fragment,h),M(G.$$.fragment,h),A=!1},d(h){h&&(a(p),a(t),a(X),a(_e),a(J),a(ye),a(K),a(Q)),$(e,h),$(s),$(P),$(g),$(E),$(Ce,h),$(de),$(z),$(Z),$(oe),$(ne),$(se,h),$(H),$(fe),$(C),$(F),$(G)}}}function eo(V){let e,p;return e=new It({props:{$$slots:{default:[Kt]},$$scope:{ctx:V}}}),{c(){b(e.$$.fragment)},l(t){y(e.$$.fragment,t)},m(t,s){v(e,t,s),p=!0},p(t,s){const u={};s&2&&(u.$$scope={dirty:s,ctx:t}),e.$set(u)},i(t){p||(w(e.$$.fragment,t),p=!0)},o(t){M(e.$$.fragment,t),p=!1},d(t){$(e,t)}}}function to(V){let e,p="TensorFlow models and layers in <code>transformers</code> accept two formats as input:",t,s,u="<li>having all inputs as keyword arguments (like PyTorch models), or</li> <li>having all inputs as a list, tuple or dict in the first positional argument.</li>",n,x,re=`The reason the second format is supported is that Keras methods prefer this format when passing inputs to models
and layers. Because of this support, when using methods like <code>model.fit()</code> things should “just work” for you - just
pass your inputs and labels in any format that <code>model.fit()</code> supports! If, however, you want to use the second
format outside of Keras methods like <code>fit()</code> and <code>predict()</code>, such as when creating your own layers or models with
the Keras <code>Functional</code> API, there are three possibilities you can use to gather all the input Tensors in the first
positional argument:`,I,P,ie=`<li>a single Tensor with <code>pixel_values</code> only and nothing else: <code>model(pixel_values)</code></li> <li>a list of varying length with one or several input Tensors IN THE ORDER given in the docstring:
<code>model([pixel_values, attention_mask])</code> or <code>model([pixel_values, attention_mask, token_type_ids])</code></li> <li>a dictionary with one or several input Tensors associated to the input names given in the docstring:
<code>model({&quot;pixel_values&quot;: pixel_values, &quot;token_type_ids&quot;: token_type_ids})</code></li>`,W,S,le=`Note that when creating models and layers with
<a href="https://keras.io/guides/making_new_layers_and_models_via_subclassing/" rel="nofollow">subclassing</a> then you don’t need to worry
about any of this, as you can just pass inputs like you would to any other Python function!`;return{c(){e=c("p"),e.innerHTML=p,t=r(),s=c("ul"),s.innerHTML=u,n=r(),x=c("p"),x.innerHTML=re,I=r(),P=c("ul"),P.innerHTML=ie,W=r(),S=c("p"),S.innerHTML=le},l(g){e=m(g,"P",{"data-svelte-h":!0}),f(e)!=="svelte-1ajbfxg"&&(e.innerHTML=p),t=i(g),s=m(g,"UL",{"data-svelte-h":!0}),f(s)!=="svelte-qm1t26"&&(s.innerHTML=u),n=i(g),x=m(g,"P",{"data-svelte-h":!0}),f(x)!=="svelte-1v9qsc5"&&(x.innerHTML=re),I=i(g),P=m(g,"UL",{"data-svelte-h":!0}),f(P)!=="svelte-99h8aq"&&(P.innerHTML=ie),W=i(g),S=m(g,"P",{"data-svelte-h":!0}),f(S)!=="svelte-1an3odd"&&(S.innerHTML=le)},m(g,N){l(g,e,N),l(g,t,N),l(g,s,N),l(g,n,N),l(g,x,N),l(g,I,N),l(g,P,N),l(g,W,N),l(g,S,N)},p:be,d(g){g&&(a(e),a(t),a(s),a(n),a(x),a(I),a(P),a(W),a(S))}}}function oo(V){let e,p=`Although the recipe for forward pass needs to be defined within this function, one should call the <code>Module</code>
instance afterwards instead of this since the former takes care of running the pre and post processing steps while
the latter silently ignores them.`;return{c(){e=c("p"),e.innerHTML=p},l(t){e=m(t,"P",{"data-svelte-h":!0}),f(e)!=="svelte-fincs2"&&(e.innerHTML=p)},m(t,s){l(t,e,s)},p:be,d(t){t&&a(e)}}}function no(V){let e,p="Example:",t,s,u;return s=new De({props:{code:"ZnJvbSUyMHRyYW5zZm9ybWVycyUyMGltcG9ydCUyMEF1dG9JbWFnZVByb2Nlc3NvciUyQyUyMFRGVmlUTW9kZWwlMEFmcm9tJTIwZGF0YXNldHMlMjBpbXBvcnQlMjBsb2FkX2RhdGFzZXQlMEElMEFkYXRhc2V0JTIwJTNEJTIwbG9hZF9kYXRhc2V0KCUyMmh1Z2dpbmdmYWNlJTJGY2F0cy1pbWFnZSUyMiklMEFpbWFnZSUyMCUzRCUyMGRhdGFzZXQlNUIlMjJ0ZXN0JTIyJTVEJTVCJTIyaW1hZ2UlMjIlNUQlNUIwJTVEJTBBJTBBaW1hZ2VfcHJvY2Vzc29yJTIwJTNEJTIwQXV0b0ltYWdlUHJvY2Vzc29yLmZyb21fcHJldHJhaW5lZCglMjJnb29nbGUlMkZ2aXQtYmFzZS1wYXRjaDE2LTIyNC1pbjIxayUyMiklMEFtb2RlbCUyMCUzRCUyMFRGVmlUTW9kZWwuZnJvbV9wcmV0cmFpbmVkKCUyMmdvb2dsZSUyRnZpdC1iYXNlLXBhdGNoMTYtMjI0LWluMjFrJTIyKSUwQSUwQWlucHV0cyUyMCUzRCUyMGltYWdlX3Byb2Nlc3NvcihpbWFnZSUyQyUyMHJldHVybl90ZW5zb3JzJTNEJTIydGYlMjIpJTBBb3V0cHV0cyUyMCUzRCUyMG1vZGVsKCoqaW5wdXRzKSUwQSUwQWxhc3RfaGlkZGVuX3N0YXRlcyUyMCUzRCUyMG91dHB1dHMubGFzdF9oaWRkZW5fc3RhdGUlMEFsaXN0KGxhc3RfaGlkZGVuX3N0YXRlcy5zaGFwZSk=",highlighted:`<span class="hljs-meta">&gt;&gt;&gt; </span><span class="hljs-keyword">from</span> transformers <span class="hljs-keyword">import</span> AutoImageProcessor, TFViTModel
<span class="hljs-meta">&gt;&gt;&gt; </span><span class="hljs-keyword">from</span> datasets <span class="hljs-keyword">import</span> load_dataset

<span class="hljs-meta">&gt;&gt;&gt; </span>dataset = load_dataset(<span class="hljs-string">&quot;huggingface/cats-image&quot;</span>)
<span class="hljs-meta">&gt;&gt;&gt; </span>image = dataset[<span class="hljs-string">&quot;test&quot;</span>][<span class="hljs-string">&quot;image&quot;</span>][<span class="hljs-number">0</span>]

<span class="hljs-meta">&gt;&gt;&gt; </span>image_processor = AutoImageProcessor.from_pretrained(<span class="hljs-string">&quot;google/vit-base-patch16-224-in21k&quot;</span>)
<span class="hljs-meta">&gt;&gt;&gt; </span>model = TFViTModel.from_pretrained(<span class="hljs-string">&quot;google/vit-base-patch16-224-in21k&quot;</span>)

<span class="hljs-meta">&gt;&gt;&gt; </span>inputs = image_processor(image, return_tensors=<span class="hljs-string">&quot;tf&quot;</span>)
<span class="hljs-meta">&gt;&gt;&gt; </span>outputs = model(**inputs)

<span class="hljs-meta">&gt;&gt;&gt; </span>last_hidden_states = outputs.last_hidden_state
<span class="hljs-meta">&gt;&gt;&gt; </span><span class="hljs-built_in">list</span>(last_hidden_states.shape)
[<span class="hljs-number">1</span>, <span class="hljs-number">197</span>, <span class="hljs-number">768</span>]`,wrap:!1}}),{c(){e=c("p"),e.textContent=p,t=r(),b(s.$$.fragment)},l(n){e=m(n,"P",{"data-svelte-h":!0}),f(e)!=="svelte-11lpom8"&&(e.textContent=p),t=i(n),y(s.$$.fragment,n)},m(n,x){l(n,e,x),l(n,t,x),v(s,n,x),u=!0},p:be,i(n){u||(w(s.$$.fragment,n),u=!0)},o(n){M(s.$$.fragment,n),u=!1},d(n){n&&(a(e),a(t)),$(s,n)}}}function so(V){let e,p=`Note that it’s possible to fine-tune ViT on higher resolution images than the ones it has been trained on, by
setting <code>interpolate_pos_encoding</code> to <code>True</code> in the forward of the model. This will interpolate the pre-trained
position embeddings to the higher resolution.`;return{c(){e=c("p"),e.innerHTML=p},l(t){e=m(t,"P",{"data-svelte-h":!0}),f(e)!=="svelte-111lhr1"&&(e.innerHTML=p)},m(t,s){l(t,e,s)},p:be,d(t){t&&a(e)}}}function ao(V){let e,p="TensorFlow models and layers in <code>transformers</code> accept two formats as input:",t,s,u="<li>having all inputs as keyword arguments (like PyTorch models), or</li> <li>having all inputs as a list, tuple or dict in the first positional argument.</li>",n,x,re=`The reason the second format is supported is that Keras methods prefer this format when passing inputs to models
and layers. Because of this support, when using methods like <code>model.fit()</code> things should “just work” for you - just
pass your inputs and labels in any format that <code>model.fit()</code> supports! If, however, you want to use the second
format outside of Keras methods like <code>fit()</code> and <code>predict()</code>, such as when creating your own layers or models with
the Keras <code>Functional</code> API, there are three possibilities you can use to gather all the input Tensors in the first
positional argument:`,I,P,ie=`<li>a single Tensor with <code>pixel_values</code> only and nothing else: <code>model(pixel_values)</code></li> <li>a list of varying length with one or several input Tensors IN THE ORDER given in the docstring:
<code>model([pixel_values, attention_mask])</code> or <code>model([pixel_values, attention_mask, token_type_ids])</code></li> <li>a dictionary with one or several input Tensors associated to the input names given in the docstring:
<code>model({&quot;pixel_values&quot;: pixel_values, &quot;token_type_ids&quot;: token_type_ids})</code></li>`,W,S,le=`Note that when creating models and layers with
<a href="https://keras.io/guides/making_new_layers_and_models_via_subclassing/" rel="nofollow">subclassing</a> then you don’t need to worry
about any of this, as you can just pass inputs like you would to any other Python function!`;return{c(){e=c("p"),e.innerHTML=p,t=r(),s=c("ul"),s.innerHTML=u,n=r(),x=c("p"),x.innerHTML=re,I=r(),P=c("ul"),P.innerHTML=ie,W=r(),S=c("p"),S.innerHTML=le},l(g){e=m(g,"P",{"data-svelte-h":!0}),f(e)!=="svelte-1ajbfxg"&&(e.innerHTML=p),t=i(g),s=m(g,"UL",{"data-svelte-h":!0}),f(s)!=="svelte-qm1t26"&&(s.innerHTML=u),n=i(g),x=m(g,"P",{"data-svelte-h":!0}),f(x)!=="svelte-1v9qsc5"&&(x.innerHTML=re),I=i(g),P=m(g,"UL",{"data-svelte-h":!0}),f(P)!=="svelte-99h8aq"&&(P.innerHTML=ie),W=i(g),S=m(g,"P",{"data-svelte-h":!0}),f(S)!=="svelte-1an3odd"&&(S.innerHTML=le)},m(g,N){l(g,e,N),l(g,t,N),l(g,s,N),l(g,n,N),l(g,x,N),l(g,I,N),l(g,P,N),l(g,W,N),l(g,S,N)},p:be,d(g){g&&(a(e),a(t),a(s),a(n),a(x),a(I),a(P),a(W),a(S))}}}function ro(V){let e,p=`Although the recipe for forward pass needs to be defined within this function, one should call the <code>Module</code>
instance afterwards instead of this since the former takes care of running the pre and post processing steps while
the latter silently ignores them.`;return{c(){e=c("p"),e.innerHTML=p},l(t){e=m(t,"P",{"data-svelte-h":!0}),f(e)!=="svelte-fincs2"&&(e.innerHTML=p)},m(t,s){l(t,e,s)},p:be,d(t){t&&a(e)}}}function io(V){let e,p="Example:",t,s,u;return s=new De({props:{code:"ZnJvbSUyMHRyYW5zZm9ybWVycyUyMGltcG9ydCUyMEF1dG9JbWFnZVByb2Nlc3NvciUyQyUyMFRGVmlURm9ySW1hZ2VDbGFzc2lmaWNhdGlvbiUwQWltcG9ydCUyMHRlbnNvcmZsb3clMjBhcyUyMHRmJTBBZnJvbSUyMGRhdGFzZXRzJTIwaW1wb3J0JTIwbG9hZF9kYXRhc2V0JTBBJTBBZGF0YXNldCUyMCUzRCUyMGxvYWRfZGF0YXNldCglMjJodWdnaW5nZmFjZSUyRmNhdHMtaW1hZ2UlMjIpJTBBaW1hZ2UlMjAlM0QlMjBkYXRhc2V0JTVCJTIydGVzdCUyMiU1RCU1QiUyMmltYWdlJTIyJTVEJTVCMCU1RCUwQSUwQWltYWdlX3Byb2Nlc3NvciUyMCUzRCUyMEF1dG9JbWFnZVByb2Nlc3Nvci5mcm9tX3ByZXRyYWluZWQoJTIyZ29vZ2xlJTJGdml0LWJhc2UtcGF0Y2gxNi0yMjQlMjIpJTBBbW9kZWwlMjAlM0QlMjBURlZpVEZvckltYWdlQ2xhc3NpZmljYXRpb24uZnJvbV9wcmV0cmFpbmVkKCUyMmdvb2dsZSUyRnZpdC1iYXNlLXBhdGNoMTYtMjI0JTIyKSUwQSUwQWlucHV0cyUyMCUzRCUyMGltYWdlX3Byb2Nlc3NvcihpbWFnZSUyQyUyMHJldHVybl90ZW5zb3JzJTNEJTIydGYlMjIpJTBBbG9naXRzJTIwJTNEJTIwbW9kZWwoKippbnB1dHMpLmxvZ2l0cyUwQSUwQSUyMyUyMG1vZGVsJTIwcHJlZGljdHMlMjBvbmUlMjBvZiUyMHRoZSUyMDEwMDAlMjBJbWFnZU5ldCUyMGNsYXNzZXMlMEFwcmVkaWN0ZWRfbGFiZWwlMjAlM0QlMjBpbnQodGYubWF0aC5hcmdtYXgobG9naXRzJTJDJTIwYXhpcyUzRC0xKSklMEFwcmludChtb2RlbC5jb25maWcuaWQybGFiZWwlNUJwcmVkaWN0ZWRfbGFiZWwlNUQp",highlighted:`<span class="hljs-meta">&gt;&gt;&gt; </span><span class="hljs-keyword">from</span> transformers <span class="hljs-keyword">import</span> AutoImageProcessor, TFViTForImageClassification
<span class="hljs-meta">&gt;&gt;&gt; </span><span class="hljs-keyword">import</span> tensorflow <span class="hljs-keyword">as</span> tf
<span class="hljs-meta">&gt;&gt;&gt; </span><span class="hljs-keyword">from</span> datasets <span class="hljs-keyword">import</span> load_dataset

<span class="hljs-meta">&gt;&gt;&gt; </span>dataset = load_dataset(<span class="hljs-string">&quot;huggingface/cats-image&quot;</span>)
<span class="hljs-meta">&gt;&gt;&gt; </span>image = dataset[<span class="hljs-string">&quot;test&quot;</span>][<span class="hljs-string">&quot;image&quot;</span>][<span class="hljs-number">0</span>]

<span class="hljs-meta">&gt;&gt;&gt; </span>image_processor = AutoImageProcessor.from_pretrained(<span class="hljs-string">&quot;google/vit-base-patch16-224&quot;</span>)
<span class="hljs-meta">&gt;&gt;&gt; </span>model = TFViTForImageClassification.from_pretrained(<span class="hljs-string">&quot;google/vit-base-patch16-224&quot;</span>)

<span class="hljs-meta">&gt;&gt;&gt; </span>inputs = image_processor(image, return_tensors=<span class="hljs-string">&quot;tf&quot;</span>)
<span class="hljs-meta">&gt;&gt;&gt; </span>logits = model(**inputs).logits

<span class="hljs-meta">&gt;&gt;&gt; </span><span class="hljs-comment"># model predicts one of the 1000 ImageNet classes</span>
<span class="hljs-meta">&gt;&gt;&gt; </span>predicted_label = <span class="hljs-built_in">int</span>(tf.math.argmax(logits, axis=-<span class="hljs-number">1</span>))
<span class="hljs-meta">&gt;&gt;&gt; </span><span class="hljs-built_in">print</span>(model.config.id2label[predicted_label])
Egyptian cat`,wrap:!1}}),{c(){e=c("p"),e.textContent=p,t=r(),b(s.$$.fragment)},l(n){e=m(n,"P",{"data-svelte-h":!0}),f(e)!=="svelte-11lpom8"&&(e.textContent=p),t=i(n),y(s.$$.fragment,n)},m(n,x){l(n,e,x),l(n,t,x),v(s,n,x),u=!0},p:be,i(n){u||(w(s.$$.fragment,n),u=!0)},o(n){M(s.$$.fragment,n),u=!1},d(n){n&&(a(e),a(t)),$(s,n)}}}function lo(V){let e,p,t,s,u,n,x="The bare ViT Model transformer outputting raw hidden-states without any specific head on top.",re,I,P=`This model inherits from <a href="/docs/transformers/main/en/main_classes/model#transformers.TFPreTrainedModel">TFPreTrainedModel</a>. Check the superclass documentation for the generic methods the
library implements for all its model (such as downloading or saving, resizing the input embeddings, pruning heads
etc.)`,ie,W,S=`This model is also a <a href="https://www.tensorflow.org/api_docs/python/tf/keras/Model" rel="nofollow">tf.keras.Model</a> subclass. Use it
as a regular TF 2.0 Keras Model and refer to the TF 2.0 documentation for all matter related to general usage and
behavior.`,le,g,N,E,X,Ce,_e,J='The <a href="/docs/transformers/main/en/model_doc/vit#transformers.TFViTModel">TFViTModel</a> forward method, overrides the <code>__call__</code> special method.',de,me,D,je,Ie,z,ze,U,te,$e,q,Z=`ViT Model transformer with an image classification head on top (a linear layer on top of the final hidden state of
the [CLS] token) e.g. for ImageNet.`,xe,O,pe,Fe,oe=`This model inherits from <a href="/docs/transformers/main/en/main_classes/model#transformers.TFPreTrainedModel">TFPreTrainedModel</a>. Check the superclass documentation for the generic methods the
library implements for all its model (such as downloading or saving, resizing the input embeddings, pruning heads
etc.)`,ke,ne,ye=`This model is also a <a href="https://www.tensorflow.org/api_docs/python/tf/keras/Model" rel="nofollow">tf.keras.Model</a> subclass. Use it
as a regular TF 2.0 Keras Model and refer to the TF 2.0 documentation for all matter related to general usage and
behavior.`,se,K,Q,H,ce,Ue,he,Je='The <a href="/docs/transformers/main/en/model_doc/vit#transformers.TFViTForImageClassification">TFViTForImageClassification</a> forward method, overrides the <code>__call__</code> special method.',fe,L,ge,Te,ae;return e=new Pe({props:{title:"TFViTModel",local:"transformers.TFViTModel",headingTag:"h2"}}),s=new Me({props:{name:"class transformers.TFViTModel",anchor:"transformers.TFViTModel",parameters:[{name:"*args",val:""},{name:"**kwargs",val:""}],parametersDescription:[{anchor:"transformers.TFViTModel.config",description:`<strong>config</strong> (<a href="/docs/transformers/main/en/model_doc/vit#transformers.ViTConfig">ViTConfig</a>) &#x2014; Model configuration class with all the parameters of the model.
Initializing with a config file does not load the weights associated with the model, only the
configuration. Check out the <a href="/docs/transformers/main/en/main_classes/model#transformers.TFPreTrainedModel.from_pretrained">from_pretrained()</a> method to load the model weights.`,name:"config"}],source:"https://github.com/huggingface/transformers/blob/main/src/transformers/models/vit/modeling_tf_vit.py#L631"}}),g=new He({props:{$$slots:{default:[to]},$$scope:{ctx:V}}}),X=new Me({props:{name:"call",anchor:"transformers.TFViTModel.call",parameters:[{name:"pixel_values",val:": TFModelInputType | None = None"},{name:"head_mask",val:": np.ndarray | tf.Tensor | None = None"},{name:"output_attentions",val:": Optional[bool] = None"},{name:"output_hidden_states",val:": Optional[bool] = None"},{name:"interpolate_pos_encoding",val:": Optional[bool] = None"},{name:"return_dict",val:": Optional[bool] = None"},{name:"training",val:": bool = False"}],parametersDescription:[{anchor:"transformers.TFViTModel.call.pixel_values",description:`<strong>pixel_values</strong> (<code>np.ndarray</code>, <code>tf.Tensor</code>, <code>List[tf.Tensor]</code> \`<code>Dict[str, tf.Tensor]</code> or <code>Dict[str, np.ndarray]</code> and each example must have the shape <code>(batch_size, num_channels, height, width)</code>) &#x2014;
Pixel values. Pixel values can be obtained using <a href="/docs/transformers/main/en/model_doc/auto#transformers.AutoImageProcessor">AutoImageProcessor</a>. See <a href="/docs/transformers/main/en/model_doc/dpt#transformers.DPTFeatureExtractor.__call__">ViTImageProcessor.<strong>call</strong>()</a>
for details.`,name:"pixel_values"},{anchor:"transformers.TFViTModel.call.head_mask",description:`<strong>head_mask</strong> (<code>np.ndarray</code> or <code>tf.Tensor</code> of shape <code>(num_heads,)</code> or <code>(num_layers, num_heads)</code>, <em>optional</em>) &#x2014;
Mask to nullify selected heads of the self-attention modules. Mask values selected in <code>[0, 1]</code>:</p>
<ul>
<li>1 indicates the head is <strong>not masked</strong>,</li>
<li>0 indicates the head is <strong>masked</strong>.</li>
</ul>`,name:"head_mask"},{anchor:"transformers.TFViTModel.call.output_attentions",description:`<strong>output_attentions</strong> (<code>bool</code>, <em>optional</em>) &#x2014;
Whether or not to return the attentions tensors of all attention layers. See <code>attentions</code> under returned
tensors for more detail. This argument can be used only in eager mode, in graph mode the value in the
config will be used instead.`,name:"output_attentions"},{anchor:"transformers.TFViTModel.call.output_hidden_states",description:`<strong>output_hidden_states</strong> (<code>bool</code>, <em>optional</em>) &#x2014;
Whether or not to return the hidden states of all layers. See <code>hidden_states</code> under returned tensors for
more detail. This argument can be used only in eager mode, in graph mode the value in the config will be
used instead.`,name:"output_hidden_states"},{anchor:"transformers.TFViTModel.call.interpolate_pos_encoding",description:`<strong>interpolate_pos_encoding</strong> (<code>bool</code>, <em>optional</em>) &#x2014;
Whether to interpolate the pre-trained position encodings.`,name:"interpolate_pos_encoding"},{anchor:"transformers.TFViTModel.call.return_dict",description:`<strong>return_dict</strong> (<code>bool</code>, <em>optional</em>) &#x2014;
Whether or not to return a <a href="/docs/transformers/main/en/main_classes/output#transformers.utils.ModelOutput">ModelOutput</a> instead of a plain tuple. This argument can be used in
eager mode, in graph mode the value will always be set to True.`,name:"return_dict"},{anchor:"transformers.TFViTModel.call.training",description:`<strong>training</strong> (<code>bool</code>, <em>optional</em>, defaults to \`False&#x201C;) &#x2014;
Whether or not to use the model in training mode (some modules like dropout modules have different
behaviors between training and evaluation).`,name:"training"}],source:"https://github.com/huggingface/transformers/blob/main/src/transformers/models/vit/modeling_tf_vit.py#L637",returnDescription:`<script context="module">export const metadata = 'undefined';<\/script>


<p>A <a
  href="/docs/transformers/main/en/main_classes/output#transformers.modeling_tf_outputs.TFBaseModelOutputWithPooling"
>transformers.modeling_tf_outputs.TFBaseModelOutputWithPooling</a> or a tuple of <code>tf.Tensor</code> (if
<code>return_dict=False</code> is passed or when <code>config.return_dict=False</code>) comprising various elements depending on the
configuration (<a
  href="/docs/transformers/main/en/model_doc/vit#transformers.ViTConfig"
>ViTConfig</a>) and inputs.</p>
<ul>
<li>
<p><strong>last_hidden_state</strong> (<code>tf.Tensor</code> of shape <code>(batch_size, sequence_length, hidden_size)</code>) — Sequence of hidden-states at the output of the last layer of the model.</p>
</li>
<li>
<p><strong>pooler_output</strong> (<code>tf.Tensor</code> of shape <code>(batch_size, hidden_size)</code>) — Last layer hidden-state of the first token of the sequence (classification token) further processed by a
Linear layer and a Tanh activation function. The Linear layer weights are trained from the next sentence
prediction (classification) objective during pretraining.</p>
<p>This output is usually <em>not</em> a good summary of the semantic content of the input, you’re often better with
averaging or pooling the sequence of hidden-states for the whole input sequence.</p>
</li>
<li>
<p><strong>hidden_states</strong> (<code>tuple(tf.Tensor)</code>, <em>optional</em>, returned when <code>output_hidden_states=True</code> is passed or when <code>config.output_hidden_states=True</code>) — Tuple of <code>tf.Tensor</code> (one for the output of the embeddings + one for the output of each layer) of shape
<code>(batch_size, sequence_length, hidden_size)</code>.</p>
<p>Hidden-states of the model at the output of each layer plus the initial embedding outputs.</p>
</li>
<li>
<p><strong>attentions</strong> (<code>tuple(tf.Tensor)</code>, <em>optional</em>, returned when <code>output_attentions=True</code> is passed or when <code>config.output_attentions=True</code>) — Tuple of <code>tf.Tensor</code> (one for each layer) of shape <code>(batch_size, num_heads, sequence_length, sequence_length)</code>.</p>
<p>Attentions weights after the attention softmax, used to compute the weighted average in the self-attention
heads.</p>
</li>
</ul>
`,returnType:`<script context="module">export const metadata = 'undefined';<\/script>


<p><a
  href="/docs/transformers/main/en/main_classes/output#transformers.modeling_tf_outputs.TFBaseModelOutputWithPooling"
>transformers.modeling_tf_outputs.TFBaseModelOutputWithPooling</a> or <code>tuple(tf.Tensor)</code></p>
`}}),me=new He({props:{$$slots:{default:[oo]},$$scope:{ctx:V}}}),je=new Qe({props:{anchor:"transformers.TFViTModel.call.example",$$slots:{default:[no]},$$scope:{ctx:V}}}),z=new Pe({props:{title:"TFViTForImageClassification",local:"transformers.TFViTForImageClassification",headingTag:"h2"}}),te=new Me({props:{name:"class transformers.TFViTForImageClassification",anchor:"transformers.TFViTForImageClassification",parameters:[{name:"*args",val:""},{name:"**kwargs",val:""}],parametersDescription:[{anchor:"transformers.TFViTForImageClassification.config",description:`<strong>config</strong> (<a href="/docs/transformers/main/en/model_doc/vit#transformers.ViTConfig">ViTConfig</a>) &#x2014; Model configuration class with all the parameters of the model.
Initializing with a config file does not load the weights associated with the model, only the
configuration. Check out the <a href="/docs/transformers/main/en/main_classes/model#transformers.TFPreTrainedModel.from_pretrained">from_pretrained()</a> method to load the model weights.`,name:"config"}],source:"https://github.com/huggingface/transformers/blob/main/src/transformers/models/vit/modeling_tf_vit.py#L704"}}),O=new He({props:{$$slots:{default:[so]},$$scope:{ctx:V}}}),K=new He({props:{$$slots:{default:[ao]},$$scope:{ctx:V}}}),ce=new Me({props:{name:"call",anchor:"transformers.TFViTForImageClassification.call",parameters:[{name:"pixel_values",val:": TFModelInputType | None = None"},{name:"head_mask",val:": np.ndarray | tf.Tensor | None = None"},{name:"output_attentions",val:": Optional[bool] = None"},{name:"output_hidden_states",val:": Optional[bool] = None"},{name:"interpolate_pos_encoding",val:": Optional[bool] = None"},{name:"return_dict",val:": Optional[bool] = None"},{name:"labels",val:": np.ndarray | tf.Tensor | None = None"},{name:"training",val:": Optional[bool] = False"}],parametersDescription:[{anchor:"transformers.TFViTForImageClassification.call.pixel_values",description:`<strong>pixel_values</strong> (<code>np.ndarray</code>, <code>tf.Tensor</code>, <code>List[tf.Tensor]</code> \`<code>Dict[str, tf.Tensor]</code> or <code>Dict[str, np.ndarray]</code> and each example must have the shape <code>(batch_size, num_channels, height, width)</code>) &#x2014;
Pixel values. Pixel values can be obtained using <a href="/docs/transformers/main/en/model_doc/auto#transformers.AutoImageProcessor">AutoImageProcessor</a>. See <a href="/docs/transformers/main/en/model_doc/dpt#transformers.DPTFeatureExtractor.__call__">ViTImageProcessor.<strong>call</strong>()</a>
for details.`,name:"pixel_values"},{anchor:"transformers.TFViTForImageClassification.call.head_mask",description:`<strong>head_mask</strong> (<code>np.ndarray</code> or <code>tf.Tensor</code> of shape <code>(num_heads,)</code> or <code>(num_layers, num_heads)</code>, <em>optional</em>) &#x2014;
Mask to nullify selected heads of the self-attention modules. Mask values selected in <code>[0, 1]</code>:</p>
<ul>
<li>1 indicates the head is <strong>not masked</strong>,</li>
<li>0 indicates the head is <strong>masked</strong>.</li>
</ul>`,name:"head_mask"},{anchor:"transformers.TFViTForImageClassification.call.output_attentions",description:`<strong>output_attentions</strong> (<code>bool</code>, <em>optional</em>) &#x2014;
Whether or not to return the attentions tensors of all attention layers. See <code>attentions</code> under returned
tensors for more detail. This argument can be used only in eager mode, in graph mode the value in the
config will be used instead.`,name:"output_attentions"},{anchor:"transformers.TFViTForImageClassification.call.output_hidden_states",description:`<strong>output_hidden_states</strong> (<code>bool</code>, <em>optional</em>) &#x2014;
Whether or not to return the hidden states of all layers. See <code>hidden_states</code> under returned tensors for
more detail. This argument can be used only in eager mode, in graph mode the value in the config will be
used instead.`,name:"output_hidden_states"},{anchor:"transformers.TFViTForImageClassification.call.interpolate_pos_encoding",description:`<strong>interpolate_pos_encoding</strong> (<code>bool</code>, <em>optional</em>) &#x2014;
Whether to interpolate the pre-trained position encodings.`,name:"interpolate_pos_encoding"},{anchor:"transformers.TFViTForImageClassification.call.return_dict",description:`<strong>return_dict</strong> (<code>bool</code>, <em>optional</em>) &#x2014;
Whether or not to return a <a href="/docs/transformers/main/en/main_classes/output#transformers.utils.ModelOutput">ModelOutput</a> instead of a plain tuple. This argument can be used in
eager mode, in graph mode the value will always be set to True.`,name:"return_dict"},{anchor:"transformers.TFViTForImageClassification.call.training",description:`<strong>training</strong> (<code>bool</code>, <em>optional</em>, defaults to \`False&#x201C;) &#x2014;
Whether or not to use the model in training mode (some modules like dropout modules have different
behaviors between training and evaluation).`,name:"training"},{anchor:"transformers.TFViTForImageClassification.call.labels",description:`<strong>labels</strong> (<code>tf.Tensor</code> or <code>np.ndarray</code> of shape <code>(batch_size,)</code>, <em>optional</em>) &#x2014;
Labels for computing the image classification/regression loss. Indices should be in <code>[0, ..., config.num_labels - 1]</code>. If <code>config.num_labels == 1</code> a regression loss is computed (Mean-Square loss), If
<code>config.num_labels &gt; 1</code> a classification loss is computed (Cross-Entropy).`,name:"labels"}],source:"https://github.com/huggingface/transformers/blob/main/src/transformers/models/vit/modeling_tf_vit.py#L718",returnDescription:`<script context="module">export const metadata = 'undefined';<\/script>


<p>A <a
  href="/docs/transformers/main/en/main_classes/output#transformers.modeling_tf_outputs.TFSequenceClassifierOutput"
>transformers.modeling_tf_outputs.TFSequenceClassifierOutput</a> or a tuple of <code>tf.Tensor</code> (if
<code>return_dict=False</code> is passed or when <code>config.return_dict=False</code>) comprising various elements depending on the
configuration (<a
  href="/docs/transformers/main/en/model_doc/vit#transformers.ViTConfig"
>ViTConfig</a>) and inputs.</p>
<ul>
<li>
<p><strong>loss</strong> (<code>tf.Tensor</code> of shape <code>(batch_size, )</code>, <em>optional</em>, returned when <code>labels</code> is provided) — Classification (or regression if config.num_labels==1) loss.</p>
</li>
<li>
<p><strong>logits</strong> (<code>tf.Tensor</code> of shape <code>(batch_size, config.num_labels)</code>) — Classification (or regression if config.num_labels==1) scores (before SoftMax).</p>
</li>
<li>
<p><strong>hidden_states</strong> (<code>tuple(tf.Tensor)</code>, <em>optional</em>, returned when <code>output_hidden_states=True</code> is passed or when <code>config.output_hidden_states=True</code>) — Tuple of <code>tf.Tensor</code> (one for the output of the embeddings + one for the output of each layer) of shape
<code>(batch_size, sequence_length, hidden_size)</code>.</p>
<p>Hidden-states of the model at the output of each layer plus the initial embedding outputs.</p>
</li>
<li>
<p><strong>attentions</strong> (<code>tuple(tf.Tensor)</code>, <em>optional</em>, returned when <code>output_attentions=True</code> is passed or when <code>config.output_attentions=True</code>) — Tuple of <code>tf.Tensor</code> (one for each layer) of shape <code>(batch_size, num_heads, sequence_length, sequence_length)</code>.</p>
<p>Attentions weights after the attention softmax, used to compute the weighted average in the self-attention
heads.</p>
</li>
</ul>
`,returnType:`<script context="module">export const metadata = 'undefined';<\/script>


<p><a
  href="/docs/transformers/main/en/main_classes/output#transformers.modeling_tf_outputs.TFSequenceClassifierOutput"
>transformers.modeling_tf_outputs.TFSequenceClassifierOutput</a> or <code>tuple(tf.Tensor)</code></p>
`}}),L=new He({props:{$$slots:{default:[ro]},$$scope:{ctx:V}}}),Te=new Qe({props:{anchor:"transformers.TFViTForImageClassification.call.example",$$slots:{default:[io]},$$scope:{ctx:V}}}),{c(){b(e.$$.fragment),p=r(),t=c("div"),b(s.$$.fragment),u=r(),n=c("p"),n.textContent=x,re=r(),I=c("p"),I.innerHTML=P,ie=r(),W=c("p"),W.innerHTML=S,le=r(),b(g.$$.fragment),N=r(),E=c("div"),b(X.$$.fragment),Ce=r(),_e=c("p"),_e.innerHTML=J,de=r(),b(me.$$.fragment),D=r(),b(je.$$.fragment),Ie=r(),b(z.$$.fragment),ze=r(),U=c("div"),b(te.$$.fragment),$e=r(),q=c("p"),q.textContent=Z,xe=r(),b(O.$$.fragment),pe=r(),Fe=c("p"),Fe.innerHTML=oe,ke=r(),ne=c("p"),ne.innerHTML=ye,se=r(),b(K.$$.fragment),Q=r(),H=c("div"),b(ce.$$.fragment),Ue=r(),he=c("p"),he.innerHTML=Je,fe=r(),b(L.$$.fragment),ge=r(),b(Te.$$.fragment),this.h()},l(_){y(e.$$.fragment,_),p=i(_),t=m(_,"DIV",{class:!0});var C=ue(t);y(s.$$.fragment,C),u=i(C),n=m(C,"P",{"data-svelte-h":!0}),f(n)!=="svelte-1vbye9a"&&(n.textContent=x),re=i(C),I=m(C,"P",{"data-svelte-h":!0}),f(I)!=="svelte-1qaxm70"&&(I.innerHTML=P),ie=i(C),W=m(C,"P",{"data-svelte-h":!0}),f(W)!=="svelte-1ivrf8m"&&(W.innerHTML=S),le=i(C),y(g.$$.fragment,C),N=i(C),E=m(C,"DIV",{class:!0});var R=ue(E);y(X.$$.fragment,R),Ce=i(R),_e=m(R,"P",{"data-svelte-h":!0}),f(_e)!=="svelte-3rd5ic"&&(_e.innerHTML=J),de=i(R),y(me.$$.fragment,R),D=i(R),y(je.$$.fragment,R),R.forEach(a),C.forEach(a),Ie=i(_),y(z.$$.fragment,_),ze=i(_),U=m(_,"DIV",{class:!0});var B=ue(U);y(te.$$.fragment,B),$e=i(B),q=m(B,"P",{"data-svelte-h":!0}),f(q)!=="svelte-ju5wm2"&&(q.textContent=Z),xe=i(B),y(O.$$.fragment,B),pe=i(B),Fe=m(B,"P",{"data-svelte-h":!0}),f(Fe)!=="svelte-1qaxm70"&&(Fe.innerHTML=oe),ke=i(B),ne=m(B,"P",{"data-svelte-h":!0}),f(ne)!=="svelte-1ivrf8m"&&(ne.innerHTML=ye),se=i(B),y(K.$$.fragment,B),Q=i(B),H=m(B,"DIV",{class:!0});var Y=ue(H);y(ce.$$.fragment,Y),Ue=i(Y),he=m(Y,"P",{"data-svelte-h":!0}),f(he)!=="svelte-11z8z4w"&&(he.innerHTML=Je),fe=i(Y),y(L.$$.fragment,Y),ge=i(Y),y(Te.$$.fragment,Y),Y.forEach(a),B.forEach(a),this.h()},h(){ee(E,"class","docstring border-l-2 border-t-2 pl-4 pt-3.5 border-gray-100 rounded-tl-xl mb-6 mt-8"),ee(t,"class","docstring border-l-2 border-t-2 pl-4 pt-3.5 border-gray-100 rounded-tl-xl mb-6 mt-8"),ee(H,"class","docstring border-l-2 border-t-2 pl-4 pt-3.5 border-gray-100 rounded-tl-xl mb-6 mt-8"),ee(U,"class","docstring border-l-2 border-t-2 pl-4 pt-3.5 border-gray-100 rounded-tl-xl mb-6 mt-8")},m(_,C){v(e,_,C),l(_,p,C),l(_,t,C),v(s,t,null),d(t,u),d(t,n),d(t,re),d(t,I),d(t,ie),d(t,W),d(t,le),v(g,t,null),d(t,N),d(t,E),v(X,E,null),d(E,Ce),d(E,_e),d(E,de),v(me,E,null),d(E,D),v(je,E,null),l(_,Ie,C),v(z,_,C),l(_,ze,C),l(_,U,C),v(te,U,null),d(U,$e),d(U,q),d(U,xe),v(O,U,null),d(U,pe),d(U,Fe),d(U,ke),d(U,ne),d(U,se),v(K,U,null),d(U,Q),d(U,H),v(ce,H,null),d(H,Ue),d(H,he),d(H,fe),v(L,H,null),d(H,ge),v(Te,H,null),ae=!0},p(_,C){const R={};C&2&&(R.$$scope={dirty:C,ctx:_}),g.$set(R);const B={};C&2&&(B.$$scope={dirty:C,ctx:_}),me.$set(B);const Y={};C&2&&(Y.$$scope={dirty:C,ctx:_}),je.$set(Y);const ve={};C&2&&(ve.$$scope={dirty:C,ctx:_}),O.$set(ve);const F={};C&2&&(F.$$scope={dirty:C,ctx:_}),K.$set(F);const k={};C&2&&(k.$$scope={dirty:C,ctx:_}),L.$set(k);const G={};C&2&&(G.$$scope={dirty:C,ctx:_}),Te.$set(G)},i(_){ae||(w(e.$$.fragment,_),w(s.$$.fragment,_),w(g.$$.fragment,_),w(X.$$.fragment,_),w(me.$$.fragment,_),w(je.$$.fragment,_),w(z.$$.fragment,_),w(te.$$.fragment,_),w(O.$$.fragment,_),w(K.$$.fragment,_),w(ce.$$.fragment,_),w(L.$$.fragment,_),w(Te.$$.fragment,_),ae=!0)},o(_){M(e.$$.fragment,_),M(s.$$.fragment,_),M(g.$$.fragment,_),M(X.$$.fragment,_),M(me.$$.fragment,_),M(je.$$.fragment,_),M(z.$$.fragment,_),M(te.$$.fragment,_),M(O.$$.fragment,_),M(K.$$.fragment,_),M(ce.$$.fragment,_),M(L.$$.fragment,_),M(Te.$$.fragment,_),ae=!1},d(_){_&&(a(p),a(t),a(Ie),a(ze),a(U)),$(e,_),$(s),$(g),$(X),$(me),$(je),$(z,_),$(te),$(O),$(K),$(ce),$(L),$(Te)}}}function co(V){let e,p;return e=new It({props:{$$slots:{default:[lo]},$$scope:{ctx:V}}}),{c(){b(e.$$.fragment)},l(t){y(e.$$.fragment,t)},m(t,s){v(e,t,s),p=!0},p(t,s){const u={};s&2&&(u.$$scope={dirty:s,ctx:t}),e.$set(u)},i(t){p||(w(e.$$.fragment,t),p=!0)},o(t){M(e.$$.fragment,t),p=!1},d(t){$(e,t)}}}function mo(V){let e,p=`Although the recipe for forward pass needs to be defined within this function, one should call the <code>Module</code>
instance afterwards instead of this since the former takes care of running the pre and post processing steps while
the latter silently ignores them.`;return{c(){e=c("p"),e.innerHTML=p},l(t){e=m(t,"P",{"data-svelte-h":!0}),f(e)!=="svelte-fincs2"&&(e.innerHTML=p)},m(t,s){l(t,e,s)},p:be,d(t){t&&a(e)}}}function po(V){let e,p="Examples:",t,s,u;return s=new De({props:{code:"ZnJvbSUyMHRyYW5zZm9ybWVycyUyMGltcG9ydCUyMEF1dG9JbWFnZVByb2Nlc3NvciUyQyUyMEZsYXhWaVRNb2RlbCUwQWZyb20lMjBQSUwlMjBpbXBvcnQlMjBJbWFnZSUwQWltcG9ydCUyMHJlcXVlc3RzJTBBJTBBdXJsJTIwJTNEJTIwJTIyaHR0cCUzQSUyRiUyRmltYWdlcy5jb2NvZGF0YXNldC5vcmclMkZ2YWwyMDE3JTJGMDAwMDAwMDM5NzY5LmpwZyUyMiUwQWltYWdlJTIwJTNEJTIwSW1hZ2Uub3BlbihyZXF1ZXN0cy5nZXQodXJsJTJDJTIwc3RyZWFtJTNEVHJ1ZSkucmF3KSUwQSUwQWltYWdlX3Byb2Nlc3NvciUyMCUzRCUyMEF1dG9JbWFnZVByb2Nlc3Nvci5mcm9tX3ByZXRyYWluZWQoJTIyZ29vZ2xlJTJGdml0LWJhc2UtcGF0Y2gxNi0yMjQtaW4yMWslMjIpJTBBbW9kZWwlMjAlM0QlMjBGbGF4VmlUTW9kZWwuZnJvbV9wcmV0cmFpbmVkKCUyMmdvb2dsZSUyRnZpdC1iYXNlLXBhdGNoMTYtMjI0LWluMjFrJTIyKSUwQSUwQWlucHV0cyUyMCUzRCUyMGltYWdlX3Byb2Nlc3NvcihpbWFnZXMlM0RpbWFnZSUyQyUyMHJldHVybl90ZW5zb3JzJTNEJTIybnAlMjIpJTBBb3V0cHV0cyUyMCUzRCUyMG1vZGVsKCoqaW5wdXRzKSUwQWxhc3RfaGlkZGVuX3N0YXRlcyUyMCUzRCUyMG91dHB1dHMubGFzdF9oaWRkZW5fc3RhdGU=",highlighted:`<span class="hljs-meta">&gt;&gt;&gt; </span><span class="hljs-keyword">from</span> transformers <span class="hljs-keyword">import</span> AutoImageProcessor, FlaxViTModel
<span class="hljs-meta">&gt;&gt;&gt; </span><span class="hljs-keyword">from</span> PIL <span class="hljs-keyword">import</span> Image
<span class="hljs-meta">&gt;&gt;&gt; </span><span class="hljs-keyword">import</span> requests

<span class="hljs-meta">&gt;&gt;&gt; </span>url = <span class="hljs-string">&quot;http://images.cocodataset.org/val2017/000000039769.jpg&quot;</span>
<span class="hljs-meta">&gt;&gt;&gt; </span>image = Image.<span class="hljs-built_in">open</span>(requests.get(url, stream=<span class="hljs-literal">True</span>).raw)

<span class="hljs-meta">&gt;&gt;&gt; </span>image_processor = AutoImageProcessor.from_pretrained(<span class="hljs-string">&quot;google/vit-base-patch16-224-in21k&quot;</span>)
<span class="hljs-meta">&gt;&gt;&gt; </span>model = FlaxViTModel.from_pretrained(<span class="hljs-string">&quot;google/vit-base-patch16-224-in21k&quot;</span>)

<span class="hljs-meta">&gt;&gt;&gt; </span>inputs = image_processor(images=image, return_tensors=<span class="hljs-string">&quot;np&quot;</span>)
<span class="hljs-meta">&gt;&gt;&gt; </span>outputs = model(**inputs)
<span class="hljs-meta">&gt;&gt;&gt; </span>last_hidden_states = outputs.last_hidden_state`,wrap:!1}}),{c(){e=c("p"),e.textContent=p,t=r(),b(s.$$.fragment)},l(n){e=m(n,"P",{"data-svelte-h":!0}),f(e)!=="svelte-kvfsh7"&&(e.textContent=p),t=i(n),y(s.$$.fragment,n)},m(n,x){l(n,e,x),l(n,t,x),v(s,n,x),u=!0},p:be,i(n){u||(w(s.$$.fragment,n),u=!0)},o(n){M(s.$$.fragment,n),u=!1},d(n){n&&(a(e),a(t)),$(s,n)}}}function ho(V){let e,p=`Although the recipe for forward pass needs to be defined within this function, one should call the <code>Module</code>
instance afterwards instead of this since the former takes care of running the pre and post processing steps while
the latter silently ignores them.`;return{c(){e=c("p"),e.innerHTML=p},l(t){e=m(t,"P",{"data-svelte-h":!0}),f(e)!=="svelte-fincs2"&&(e.innerHTML=p)},m(t,s){l(t,e,s)},p:be,d(t){t&&a(e)}}}function fo(V){let e,p="Example:",t,s,u;return s=new De({props:{code:"ZnJvbSUyMHRyYW5zZm9ybWVycyUyMGltcG9ydCUyMEF1dG9JbWFnZVByb2Nlc3NvciUyQyUyMEZsYXhWaVRGb3JJbWFnZUNsYXNzaWZpY2F0aW9uJTBBZnJvbSUyMFBJTCUyMGltcG9ydCUyMEltYWdlJTBBaW1wb3J0JTIwamF4JTBBaW1wb3J0JTIwcmVxdWVzdHMlMEElMEF1cmwlMjAlM0QlMjAlMjJodHRwJTNBJTJGJTJGaW1hZ2VzLmNvY29kYXRhc2V0Lm9yZyUyRnZhbDIwMTclMkYwMDAwMDAwMzk3NjkuanBnJTIyJTBBaW1hZ2UlMjAlM0QlMjBJbWFnZS5vcGVuKHJlcXVlc3RzLmdldCh1cmwlMkMlMjBzdHJlYW0lM0RUcnVlKS5yYXcpJTBBJTBBaW1hZ2VfcHJvY2Vzc29yJTIwJTNEJTIwQXV0b0ltYWdlUHJvY2Vzc29yLmZyb21fcHJldHJhaW5lZCglMjJnb29nbGUlMkZ2aXQtYmFzZS1wYXRjaDE2LTIyNCUyMiklMEFtb2RlbCUyMCUzRCUyMEZsYXhWaVRGb3JJbWFnZUNsYXNzaWZpY2F0aW9uLmZyb21fcHJldHJhaW5lZCglMjJnb29nbGUlMkZ2aXQtYmFzZS1wYXRjaDE2LTIyNCUyMiklMEElMEFpbnB1dHMlMjAlM0QlMjBpbWFnZV9wcm9jZXNzb3IoaW1hZ2VzJTNEaW1hZ2UlMkMlMjByZXR1cm5fdGVuc29ycyUzRCUyMm5wJTIyKSUwQW91dHB1dHMlMjAlM0QlMjBtb2RlbCgqKmlucHV0cyklMEFsb2dpdHMlMjAlM0QlMjBvdXRwdXRzLmxvZ2l0cyUwQSUwQSUyMyUyMG1vZGVsJTIwcHJlZGljdHMlMjBvbmUlMjBvZiUyMHRoZSUyMDEwMDAlMjBJbWFnZU5ldCUyMGNsYXNzZXMlMEFwcmVkaWN0ZWRfY2xhc3NfaWR4JTIwJTNEJTIwamF4Lm51bXB5LmFyZ21heChsb2dpdHMlMkMlMjBheGlzJTNELTEpJTBBcHJpbnQoJTIyUHJlZGljdGVkJTIwY2xhc3MlM0ElMjIlMkMlMjBtb2RlbC5jb25maWcuaWQybGFiZWwlNUJwcmVkaWN0ZWRfY2xhc3NfaWR4Lml0ZW0oKSU1RCk=",highlighted:`<span class="hljs-meta">&gt;&gt;&gt; </span><span class="hljs-keyword">from</span> transformers <span class="hljs-keyword">import</span> AutoImageProcessor, FlaxViTForImageClassification
<span class="hljs-meta">&gt;&gt;&gt; </span><span class="hljs-keyword">from</span> PIL <span class="hljs-keyword">import</span> Image
<span class="hljs-meta">&gt;&gt;&gt; </span><span class="hljs-keyword">import</span> jax
<span class="hljs-meta">&gt;&gt;&gt; </span><span class="hljs-keyword">import</span> requests

<span class="hljs-meta">&gt;&gt;&gt; </span>url = <span class="hljs-string">&quot;http://images.cocodataset.org/val2017/000000039769.jpg&quot;</span>
<span class="hljs-meta">&gt;&gt;&gt; </span>image = Image.<span class="hljs-built_in">open</span>(requests.get(url, stream=<span class="hljs-literal">True</span>).raw)

<span class="hljs-meta">&gt;&gt;&gt; </span>image_processor = AutoImageProcessor.from_pretrained(<span class="hljs-string">&quot;google/vit-base-patch16-224&quot;</span>)
<span class="hljs-meta">&gt;&gt;&gt; </span>model = FlaxViTForImageClassification.from_pretrained(<span class="hljs-string">&quot;google/vit-base-patch16-224&quot;</span>)

<span class="hljs-meta">&gt;&gt;&gt; </span>inputs = image_processor(images=image, return_tensors=<span class="hljs-string">&quot;np&quot;</span>)
<span class="hljs-meta">&gt;&gt;&gt; </span>outputs = model(**inputs)
<span class="hljs-meta">&gt;&gt;&gt; </span>logits = outputs.logits

<span class="hljs-meta">&gt;&gt;&gt; </span><span class="hljs-comment"># model predicts one of the 1000 ImageNet classes</span>
<span class="hljs-meta">&gt;&gt;&gt; </span>predicted_class_idx = jax.numpy.argmax(logits, axis=-<span class="hljs-number">1</span>)
<span class="hljs-meta">&gt;&gt;&gt; </span><span class="hljs-built_in">print</span>(<span class="hljs-string">&quot;Predicted class:&quot;</span>, model.config.id2label[predicted_class_idx.item()])`,wrap:!1}}),{c(){e=c("p"),e.textContent=p,t=r(),b(s.$$.fragment)},l(n){e=m(n,"P",{"data-svelte-h":!0}),f(e)!=="svelte-11lpom8"&&(e.textContent=p),t=i(n),y(s.$$.fragment,n)},m(n,x){l(n,e,x),l(n,t,x),v(s,n,x),u=!0},p:be,i(n){u||(w(s.$$.fragment,n),u=!0)},o(n){M(s.$$.fragment,n),u=!1},d(n){n&&(a(e),a(t)),$(s,n)}}}function go(V){let e,p,t,s,u,n,x="The bare ViT Model transformer outputting raw hidden-states without any specific head on top.",re,I,P=`This model inherits from <a href="/docs/transformers/main/en/main_classes/model#transformers.FlaxPreTrainedModel">FlaxPreTrainedModel</a>. Check the superclass documentation for the generic methods the
library implements for all its model (such as downloading, saving and converting weights from PyTorch models)`,ie,W,S=`This model is also a
<a href="https://flax.readthedocs.io/en/latest/api_reference/flax.linen/module.html" rel="nofollow">flax.linen.Module</a> subclass. Use it as
a regular Flax linen Module and refer to the Flax documentation for all matter related to general usage and
behavior.`,le,g,N="Finally, this model supports inherent JAX features such as:",E,X,Ce='<li><a href="https://jax.readthedocs.io/en/latest/jax.html#just-in-time-compilation-jit" rel="nofollow">Just-In-Time (JIT) compilation</a></li> <li><a href="https://jax.readthedocs.io/en/latest/jax.html#automatic-differentiation" rel="nofollow">Automatic Differentiation</a></li> <li><a href="https://jax.readthedocs.io/en/latest/jax.html#vectorization-vmap" rel="nofollow">Vectorization</a></li> <li><a href="https://jax.readthedocs.io/en/latest/jax.html#parallelization-pmap" rel="nofollow">Parallelization</a></li>',_e,J,de,me,D,je="The <code>FlaxViTPreTrainedModel</code> forward method, overrides the <code>__call__</code> special method.",Ie,z,ze,U,te,$e,q,Z,xe,O,pe,Fe=`ViT Model transformer with an image classification head on top (a linear layer on top of the final hidden state of
the [CLS] token) e.g. for ImageNet.`,oe,ke,ne=`This model inherits from <a href="/docs/transformers/main/en/main_classes/model#transformers.FlaxPreTrainedModel">FlaxPreTrainedModel</a>. Check the superclass documentation for the generic methods the
library implements for all its model (such as downloading, saving and converting weights from PyTorch models)`,ye,se,K=`This model is also a
<a href="https://flax.readthedocs.io/en/latest/api_reference/flax.linen/module.html" rel="nofollow">flax.linen.Module</a> subclass. Use it as
a regular Flax linen Module and refer to the Flax documentation for all matter related to general usage and
behavior.`,Q,H,ce="Finally, this model supports inherent JAX features such as:",Ue,he,Je='<li><a href="https://jax.readthedocs.io/en/latest/jax.html#just-in-time-compilation-jit" rel="nofollow">Just-In-Time (JIT) compilation</a></li> <li><a href="https://jax.readthedocs.io/en/latest/jax.html#automatic-differentiation" rel="nofollow">Automatic Differentiation</a></li> <li><a href="https://jax.readthedocs.io/en/latest/jax.html#vectorization-vmap" rel="nofollow">Vectorization</a></li> <li><a href="https://jax.readthedocs.io/en/latest/jax.html#parallelization-pmap" rel="nofollow">Parallelization</a></li>',fe,L,ge,Te,ae,_="The <code>FlaxViTPreTrainedModel</code> forward method, overrides the <code>__call__</code> special method.",C,R,B,Y,ve;return e=new Pe({props:{title:"FlaxVitModel",local:"transformers.FlaxViTModel",headingTag:"h2"}}),s=new Me({props:{name:"class transformers.FlaxViTModel",anchor:"transformers.FlaxViTModel",parameters:[{name:"config",val:": ViTConfig"},{name:"input_shape",val:" = None"},{name:"seed",val:": int = 0"},{name:"dtype",val:": dtype = <class 'jax.numpy.float32'>"},{name:"_do_init",val:": bool = True"},{name:"**kwargs",val:""}],parametersDescription:[{anchor:"transformers.FlaxViTModel.config",description:`<strong>config</strong> (<a href="/docs/transformers/main/en/model_doc/vit#transformers.ViTConfig">ViTConfig</a>) &#x2014; Model configuration class with all the parameters of the model.
Initializing with a config file does not load the weights associated with the model, only the
configuration. Check out the <a href="/docs/transformers/main/en/main_classes/model#transformers.FlaxPreTrainedModel.from_pretrained">from_pretrained()</a> method to load the model weights.`,name:"config"},{anchor:"transformers.FlaxViTModel.dtype",description:`<strong>dtype</strong> (<code>jax.numpy.dtype</code>, <em>optional</em>, defaults to <code>jax.numpy.float32</code>) &#x2014;
The data type of the computation. Can be one of <code>jax.numpy.float32</code>, <code>jax.numpy.float16</code> (on GPUs) and
<code>jax.numpy.bfloat16</code> (on TPUs).</p>
<p>This can be used to enable mixed-precision training or half-precision inference on GPUs or TPUs. If
specified all the computation will be performed with the given <code>dtype</code>.</p>
<p><strong>Note that this only specifies the dtype of the computation and does not influence the dtype of model
parameters.</strong></p>
<p>If you wish to change the dtype of the model parameters, see <a href="/docs/transformers/main/en/main_classes/model#transformers.FlaxPreTrainedModel.to_fp16">to_fp16()</a> and
<a href="/docs/transformers/main/en/main_classes/model#transformers.FlaxPreTrainedModel.to_bf16">to_bf16()</a>.`,name:"dtype"}],source:"https://github.com/huggingface/transformers/blob/main/src/transformers/models/vit/modeling_flax_vit.py#L556"}}),de=new Me({props:{name:"__call__",anchor:"transformers.FlaxViTModel.__call__",parameters:[{name:"pixel_values",val:""},{name:"params",val:": dict = None"},{name:"dropout_rng",val:": PRNGKey = None"},{name:"train",val:": bool = False"},{name:"output_attentions",val:": typing.Optional[bool] = None"},{name:"output_hidden_states",val:": typing.Optional[bool] = None"},{name:"return_dict",val:": typing.Optional[bool] = None"}],source:"https://github.com/huggingface/transformers/blob/main/src/transformers/models/vit/modeling_flax_vit.py#L472",returnDescription:`<script context="module">export const metadata = 'undefined';<\/script>


<p>A <a
  href="/docs/transformers/main/en/main_classes/output#transformers.modeling_flax_outputs.FlaxBaseModelOutputWithPooling"
>transformers.modeling_flax_outputs.FlaxBaseModelOutputWithPooling</a> or a tuple of
<code>torch.FloatTensor</code> (if <code>return_dict=False</code> is passed or when <code>config.return_dict=False</code>) comprising various
elements depending on the configuration (<code>&lt;class 'transformers.models.vit.configuration_vit.ViTConfig'&gt;</code>) and inputs.</p>
<ul>
<li>
<p><strong>last_hidden_state</strong> (<code>jnp.ndarray</code> of shape <code>(batch_size, sequence_length, hidden_size)</code>) — Sequence of hidden-states at the output of the last layer of the model.</p>
</li>
<li>
<p><strong>pooler_output</strong> (<code>jnp.ndarray</code> of shape <code>(batch_size, hidden_size)</code>) — Last layer hidden-state of the first token of the sequence (classification token) further processed by a
Linear layer and a Tanh activation function. The Linear layer weights are trained from the next sentence
prediction (classification) objective during pretraining.</p>
</li>
<li>
<p><strong>hidden_states</strong> (<code>tuple(jnp.ndarray)</code>, <em>optional</em>, returned when <code>output_hidden_states=True</code> is passed or when <code>config.output_hidden_states=True</code>) — Tuple of <code>jnp.ndarray</code> (one for the output of the embeddings + one for the output of each layer) of shape
<code>(batch_size, sequence_length, hidden_size)</code>.</p>
<p>Hidden-states of the model at the output of each layer plus the initial embedding outputs.</p>
</li>
<li>
<p><strong>attentions</strong> (<code>tuple(jnp.ndarray)</code>, <em>optional</em>, returned when <code>output_attentions=True</code> is passed or when <code>config.output_attentions=True</code>) — Tuple of <code>jnp.ndarray</code> (one for each layer) of shape <code>(batch_size, num_heads, sequence_length, sequence_length)</code>.</p>
<p>Attentions weights after the attention softmax, used to compute the weighted average in the self-attention
heads.</p>
</li>
</ul>
`,returnType:`<script context="module">export const metadata = 'undefined';<\/script>


<p><a
  href="/docs/transformers/main/en/main_classes/output#transformers.modeling_flax_outputs.FlaxBaseModelOutputWithPooling"
>transformers.modeling_flax_outputs.FlaxBaseModelOutputWithPooling</a> or <code>tuple(torch.FloatTensor)</code></p>
`}}),z=new He({props:{$$slots:{default:[mo]},$$scope:{ctx:V}}}),U=new Qe({props:{anchor:"transformers.FlaxViTModel.__call__.example",$$slots:{default:[po]},$$scope:{ctx:V}}}),$e=new Pe({props:{title:"FlaxViTForImageClassification",local:"transformers.FlaxViTForImageClassification",headingTag:"h2"}}),xe=new Me({props:{name:"class transformers.FlaxViTForImageClassification",anchor:"transformers.FlaxViTForImageClassification",parameters:[{name:"config",val:": ViTConfig"},{name:"input_shape",val:" = None"},{name:"seed",val:": int = 0"},{name:"dtype",val:": dtype = <class 'jax.numpy.float32'>"},{name:"_do_init",val:": bool = True"},{name:"**kwargs",val:""}],parametersDescription:[{anchor:"transformers.FlaxViTForImageClassification.config",description:`<strong>config</strong> (<a href="/docs/transformers/main/en/model_doc/vit#transformers.ViTConfig">ViTConfig</a>) &#x2014; Model configuration class with all the parameters of the model.
Initializing with a config file does not load the weights associated with the model, only the
configuration. Check out the <a href="/docs/transformers/main/en/main_classes/model#transformers.FlaxPreTrainedModel.from_pretrained">from_pretrained()</a> method to load the model weights.`,name:"config"},{anchor:"transformers.FlaxViTForImageClassification.dtype",description:`<strong>dtype</strong> (<code>jax.numpy.dtype</code>, <em>optional</em>, defaults to <code>jax.numpy.float32</code>) &#x2014;
The data type of the computation. Can be one of <code>jax.numpy.float32</code>, <code>jax.numpy.float16</code> (on GPUs) and
<code>jax.numpy.bfloat16</code> (on TPUs).</p>
<p>This can be used to enable mixed-precision training or half-precision inference on GPUs or TPUs. If
specified all the computation will be performed with the given <code>dtype</code>.</p>
<p><strong>Note that this only specifies the dtype of the computation and does not influence the dtype of model
parameters.</strong></p>
<p>If you wish to change the dtype of the model parameters, see <a href="/docs/transformers/main/en/main_classes/model#transformers.FlaxPreTrainedModel.to_fp16">to_fp16()</a> and
<a href="/docs/transformers/main/en/main_classes/model#transformers.FlaxPreTrainedModel.to_bf16">to_bf16()</a>.`,name:"dtype"}],source:"https://github.com/huggingface/transformers/blob/main/src/transformers/models/vit/modeling_flax_vit.py#L639"}}),ge=new Me({props:{name:"__call__",anchor:"transformers.FlaxViTForImageClassification.__call__",parameters:[{name:"pixel_values",val:""},{name:"params",val:": dict = None"},{name:"dropout_rng",val:": PRNGKey = None"},{name:"train",val:": bool = False"},{name:"output_attentions",val:": typing.Optional[bool] = None"},{name:"output_hidden_states",val:": typing.Optional[bool] = None"},{name:"return_dict",val:": typing.Optional[bool] = None"}],source:"https://github.com/huggingface/transformers/blob/main/src/transformers/models/vit/modeling_flax_vit.py#L472",returnDescription:`<script context="module">export const metadata = 'undefined';<\/script>


<p>A <a
  href="/docs/transformers/main/en/main_classes/output#transformers.modeling_flax_outputs.FlaxSequenceClassifierOutput"
>transformers.modeling_flax_outputs.FlaxSequenceClassifierOutput</a> or a tuple of
<code>torch.FloatTensor</code> (if <code>return_dict=False</code> is passed or when <code>config.return_dict=False</code>) comprising various
elements depending on the configuration (<code>&lt;class 'transformers.models.vit.configuration_vit.ViTConfig'&gt;</code>) and inputs.</p>
<ul>
<li>
<p><strong>logits</strong> (<code>jnp.ndarray</code> of shape <code>(batch_size, config.num_labels)</code>) — Classification (or regression if config.num_labels==1) scores (before SoftMax).</p>
</li>
<li>
<p><strong>hidden_states</strong> (<code>tuple(jnp.ndarray)</code>, <em>optional</em>, returned when <code>output_hidden_states=True</code> is passed or when <code>config.output_hidden_states=True</code>) — Tuple of <code>jnp.ndarray</code> (one for the output of the embeddings + one for the output of each layer) of shape
<code>(batch_size, sequence_length, hidden_size)</code>.</p>
<p>Hidden-states of the model at the output of each layer plus the initial embedding outputs.</p>
</li>
<li>
<p><strong>attentions</strong> (<code>tuple(jnp.ndarray)</code>, <em>optional</em>, returned when <code>output_attentions=True</code> is passed or when <code>config.output_attentions=True</code>) — Tuple of <code>jnp.ndarray</code> (one for each layer) of shape <code>(batch_size, num_heads, sequence_length, sequence_length)</code>.</p>
<p>Attentions weights after the attention softmax, used to compute the weighted average in the self-attention
heads.</p>
</li>
</ul>
`,returnType:`<script context="module">export const metadata = 'undefined';<\/script>


<p><a
  href="/docs/transformers/main/en/main_classes/output#transformers.modeling_flax_outputs.FlaxSequenceClassifierOutput"
>transformers.modeling_flax_outputs.FlaxSequenceClassifierOutput</a> or <code>tuple(torch.FloatTensor)</code></p>
`}}),R=new He({props:{$$slots:{default:[ho]},$$scope:{ctx:V}}}),Y=new Qe({props:{anchor:"transformers.FlaxViTForImageClassification.__call__.example",$$slots:{default:[fo]},$$scope:{ctx:V}}}),{c(){b(e.$$.fragment),p=r(),t=c("div"),b(s.$$.fragment),u=r(),n=c("p"),n.textContent=x,re=r(),I=c("p"),I.innerHTML=P,ie=r(),W=c("p"),W.innerHTML=S,le=r(),g=c("p"),g.textContent=N,E=r(),X=c("ul"),X.innerHTML=Ce,_e=r(),J=c("div"),b(de.$$.fragment),me=r(),D=c("p"),D.innerHTML=je,Ie=r(),b(z.$$.fragment),ze=r(),b(U.$$.fragment),te=r(),b($e.$$.fragment),q=r(),Z=c("div"),b(xe.$$.fragment),O=r(),pe=c("p"),pe.textContent=Fe,oe=r(),ke=c("p"),ke.innerHTML=ne,ye=r(),se=c("p"),se.innerHTML=K,Q=r(),H=c("p"),H.textContent=ce,Ue=r(),he=c("ul"),he.innerHTML=Je,fe=r(),L=c("div"),b(ge.$$.fragment),Te=r(),ae=c("p"),ae.innerHTML=_,C=r(),b(R.$$.fragment),B=r(),b(Y.$$.fragment),this.h()},l(F){y(e.$$.fragment,F),p=i(F),t=m(F,"DIV",{class:!0});var k=ue(t);y(s.$$.fragment,k),u=i(k),n=m(k,"P",{"data-svelte-h":!0}),f(n)!=="svelte-1vbye9a"&&(n.textContent=x),re=i(k),I=m(k,"P",{"data-svelte-h":!0}),f(I)!=="svelte-3daxed"&&(I.innerHTML=P),ie=i(k),W=m(k,"P",{"data-svelte-h":!0}),f(W)!=="svelte-10nfsf3"&&(W.innerHTML=S),le=i(k),g=m(k,"P",{"data-svelte-h":!0}),f(g)!=="svelte-1pplc4a"&&(g.textContent=N),E=i(k),X=m(k,"UL",{"data-svelte-h":!0}),f(X)!=="svelte-1w7z84m"&&(X.innerHTML=Ce),_e=i(k),J=m(k,"DIV",{class:!0});var G=ue(J);y(de.$$.fragment,G),me=i(G),D=m(G,"P",{"data-svelte-h":!0}),f(D)!=="svelte-8rbifc"&&(D.innerHTML=je),Ie=i(G),y(z.$$.fragment,G),ze=i(G),y(U.$$.fragment,G),G.forEach(a),k.forEach(a),te=i(F),y($e.$$.fragment,F),q=i(F),Z=m(F,"DIV",{class:!0});var A=ue(Z);y(xe.$$.fragment,A),O=i(A),pe=m(A,"P",{"data-svelte-h":!0}),f(pe)!=="svelte-ju5wm2"&&(pe.textContent=Fe),oe=i(A),ke=m(A,"P",{"data-svelte-h":!0}),f(ke)!=="svelte-3daxed"&&(ke.innerHTML=ne),ye=i(A),se=m(A,"P",{"data-svelte-h":!0}),f(se)!=="svelte-10nfsf3"&&(se.innerHTML=K),Q=i(A),H=m(A,"P",{"data-svelte-h":!0}),f(H)!=="svelte-1pplc4a"&&(H.textContent=ce),Ue=i(A),he=m(A,"UL",{"data-svelte-h":!0}),f(he)!=="svelte-1w7z84m"&&(he.innerHTML=Je),fe=i(A),L=m(A,"DIV",{class:!0});var h=ue(L);y(ge.$$.fragment,h),Te=i(h),ae=m(h,"P",{"data-svelte-h":!0}),f(ae)!=="svelte-8rbifc"&&(ae.innerHTML=_),C=i(h),y(R.$$.fragment,h),B=i(h),y(Y.$$.fragment,h),h.forEach(a),A.forEach(a),this.h()},h(){ee(J,"class","docstring border-l-2 border-t-2 pl-4 pt-3.5 border-gray-100 rounded-tl-xl mb-6 mt-8"),ee(t,"class","docstring border-l-2 border-t-2 pl-4 pt-3.5 border-gray-100 rounded-tl-xl mb-6 mt-8"),ee(L,"class","docstring border-l-2 border-t-2 pl-4 pt-3.5 border-gray-100 rounded-tl-xl mb-6 mt-8"),ee(Z,"class","docstring border-l-2 border-t-2 pl-4 pt-3.5 border-gray-100 rounded-tl-xl mb-6 mt-8")},m(F,k){v(e,F,k),l(F,p,k),l(F,t,k),v(s,t,null),d(t,u),d(t,n),d(t,re),d(t,I),d(t,ie),d(t,W),d(t,le),d(t,g),d(t,E),d(t,X),d(t,_e),d(t,J),v(de,J,null),d(J,me),d(J,D),d(J,Ie),v(z,J,null),d(J,ze),v(U,J,null),l(F,te,k),v($e,F,k),l(F,q,k),l(F,Z,k),v(xe,Z,null),d(Z,O),d(Z,pe),d(Z,oe),d(Z,ke),d(Z,ye),d(Z,se),d(Z,Q),d(Z,H),d(Z,Ue),d(Z,he),d(Z,fe),d(Z,L),v(ge,L,null),d(L,Te),d(L,ae),d(L,C),v(R,L,null),d(L,B),v(Y,L,null),ve=!0},p(F,k){const G={};k&2&&(G.$$scope={dirty:k,ctx:F}),z.$set(G);const A={};k&2&&(A.$$scope={dirty:k,ctx:F}),U.$set(A);const h={};k&2&&(h.$$scope={dirty:k,ctx:F}),R.$set(h);const j={};k&2&&(j.$$scope={dirty:k,ctx:F}),Y.$set(j)},i(F){ve||(w(e.$$.fragment,F),w(s.$$.fragment,F),w(de.$$.fragment,F),w(z.$$.fragment,F),w(U.$$.fragment,F),w($e.$$.fragment,F),w(xe.$$.fragment,F),w(ge.$$.fragment,F),w(R.$$.fragment,F),w(Y.$$.fragment,F),ve=!0)},o(F){M(e.$$.fragment,F),M(s.$$.fragment,F),M(de.$$.fragment,F),M(z.$$.fragment,F),M(U.$$.fragment,F),M($e.$$.fragment,F),M(xe.$$.fragment,F),M(ge.$$.fragment,F),M(R.$$.fragment,F),M(Y.$$.fragment,F),ve=!1},d(F){F&&(a(p),a(t),a(te),a(q),a(Z)),$(e,F),$(s),$(de),$(z),$(U),$($e,F),$(xe),$(ge),$(R),$(Y)}}}function uo(V){let e,p;return e=new It({props:{$$slots:{default:[go]},$$scope:{ctx:V}}}),{c(){b(e.$$.fragment)},l(t){y(e.$$.fragment,t)},m(t,s){v(e,t,s),p=!0},p(t,s){const u={};s&2&&(u.$$scope={dirty:s,ctx:t}),e.$set(u)},i(t){p||(w(e.$$.fragment,t),p=!0)},o(t){M(e.$$.fragment,t),p=!1},d(t){$(e,t)}}}function _o(V){let e,p,t,s,u,n,x,re,I,P=`The Vision Transformer (ViT) model was proposed in <a href="https://arxiv.org/abs/2010.11929" rel="nofollow">An Image is Worth 16x16 Words: Transformers for Image Recognition
at Scale</a> by Alexey Dosovitskiy, Lucas Beyer, Alexander Kolesnikov, Dirk
Weissenborn, Xiaohua Zhai, Thomas Unterthiner, Mostafa Dehghani, Matthias Minderer, Georg Heigold, Sylvain Gelly, Jakob
Uszkoreit, Neil Houlsby. It’s the first paper that successfully trains a Transformer encoder on ImageNet, attaining
very good results compared to familiar convolutional architectures.`,ie,W,S="The abstract from the paper is the following:",le,g,N=`<em>While the Transformer architecture has become the de-facto standard for natural language processing tasks, its
applications to computer vision remain limited. In vision, attention is either applied in conjunction with
convolutional networks, or used to replace certain components of convolutional networks while keeping their overall
structure in place. We show that this reliance on CNNs is not necessary and a pure transformer applied directly to
sequences of image patches can perform very well on image classification tasks. When pre-trained on large amounts of
data and transferred to multiple mid-sized or small image recognition benchmarks (ImageNet, CIFAR-100, VTAB, etc.),
Vision Transformer (ViT) attains excellent results compared to state-of-the-art convolutional networks while requiring
substantially fewer computational resources to train.</em>`,E,X,Ce,_e,J,de='ViT architecture. Taken from the <a href="https://arxiv.org/abs/2010.11929">original paper.</a>',me,D,je="Following the original Vision Transformer, some follow-up works have been made:",Ie,z,ze=`<li><p><a href="deit">DeiT</a> (Data-efficient Image Transformers) by Facebook AI. DeiT models are distilled vision transformers.
The authors of DeiT also released more efficiently trained ViT models, which you can directly plug into <a href="/docs/transformers/main/en/model_doc/vit#transformers.ViTModel">ViTModel</a> or
<a href="/docs/transformers/main/en/model_doc/vit#transformers.ViTForImageClassification">ViTForImageClassification</a>. There are 4 variants available (in 3 different sizes): <em>facebook/deit-tiny-patch16-224</em>,
<em>facebook/deit-small-patch16-224</em>, <em>facebook/deit-base-patch16-224</em> and <em>facebook/deit-base-patch16-384</em>. Note that one should
use <a href="/docs/transformers/main/en/model_doc/deit#transformers.DeiTImageProcessor">DeiTImageProcessor</a> in order to prepare images for the model.</p></li> <li><p><a href="beit">BEiT</a> (BERT pre-training of Image Transformers) by Microsoft Research. BEiT models outperform supervised pre-trained
vision transformers using a self-supervised method inspired by BERT (masked image modeling) and based on a VQ-VAE.</p></li> <li><p>DINO (a method for self-supervised training of Vision Transformers) by Facebook AI. Vision Transformers trained using
the DINO method show very interesting properties not seen with convolutional models. They are capable of segmenting
objects, without having ever been trained to do so. DINO checkpoints can be found on the <a href="https://huggingface.co/models?other=dino" rel="nofollow">hub</a>.</p></li> <li><p><a href="vit_mae">MAE</a> (Masked Autoencoders) by Facebook AI. By pre-training Vision Transformers to reconstruct pixel values for a high portion
(75%) of masked patches (using an asymmetric encoder-decoder architecture), the authors show that this simple method outperforms
supervised pre-training after fine-tuning.</p></li>`,U,te,$e=`This model was contributed by <a href="https://huggingface.co/nielsr" rel="nofollow">nielsr</a>. The original code (written in JAX) can be
found <a href="https://github.com/google-research/vision_transformer" rel="nofollow">here</a>.`,q,Z,xe=`Note that we converted the weights from Ross Wightman’s <a href="https://github.com/rwightman/pytorch-image-models" rel="nofollow">timm library</a>,
who already converted the weights from JAX to PyTorch. Credits go to him!`,O,pe,Fe,oe,ke=`<li>To feed images to the Transformer encoder, each image is split into a sequence of fixed-size non-overlapping patches,
which are then linearly embedded. A [CLS] token is added to serve as representation of an entire image, which can be
used for classification. The authors also add absolute position embeddings, and feed the resulting sequence of
vectors to a standard Transformer encoder.</li> <li>As the Vision Transformer expects each image to be of the same size (resolution), one can use
<a href="/docs/transformers/main/en/model_doc/vit#transformers.ViTImageProcessor">ViTImageProcessor</a> to resize (or rescale) and normalize images for the model.</li> <li>Both the patch resolution and image resolution used during pre-training or fine-tuning are reflected in the name of
each checkpoint. For example, <code>google/vit-base-patch16-224</code> refers to a base-sized architecture with patch
resolution of 16x16 and fine-tuning resolution of 224x224. All checkpoints can be found on the <a href="https://huggingface.co/models?search=vit" rel="nofollow">hub</a>.</li> <li>The available checkpoints are either (1) pre-trained on <a href="http://www.image-net.org/" rel="nofollow">ImageNet-21k</a> (a collection of
14 million images and 21k classes) only, or (2) also fine-tuned on <a href="http://www.image-net.org/challenges/LSVRC/2012/" rel="nofollow">ImageNet</a> (also referred to as ILSVRC 2012, a collection of 1.3 million
images and 1,000 classes).</li> <li>The Vision Transformer was pre-trained using a resolution of 224x224. During fine-tuning, it is often beneficial to
use a higher resolution than pre-training <a href="https://arxiv.org/abs/1906.06423" rel="nofollow">(Touvron et al., 2019)</a>, <a href="https://arxiv.org/abs/1912.11370" rel="nofollow">(Kolesnikov
et al., 2020)</a>. In order to fine-tune at higher resolution, the authors perform
2D interpolation of the pre-trained position embeddings, according to their location in the original image.</li> <li>The best results are obtained with supervised pre-training, which is not the case in NLP. The authors also performed
an experiment with a self-supervised pre-training objective, namely masked patched prediction (inspired by masked
language modeling). With this approach, the smaller ViT-B/16 model achieves 79.9% accuracy on ImageNet, a significant
improvement of 2% to training from scratch, but still 4% behind supervised pre-training.</li>`,ne,ye,se,K,Q=`Demo notebooks regarding inference as well as fine-tuning ViT on custom data can be found <a href="https://github.com/NielsRogge/Transformers-Tutorials/tree/master/VisionTransformer" rel="nofollow">here</a>.
A list of official Hugging Face and community (indicated by 🌎) resources to help you get started with ViT. If you’re interested in submitting a resource to be included here, please feel free to open a Pull Request and we’ll review it! The resource should ideally demonstrate something new instead of duplicating an existing resource.`,H,ce,Ue="<code>ViTForImageClassification</code> is supported by:",he,Je,fe,L,ge='<li>A blog post on how to <a href="https://huggingface.co/blog/fine-tune-vit" rel="nofollow">Fine-Tune ViT for Image Classification with Hugging Face Transformers</a></li> <li>A blog post on <a href="https://www.philschmid.de/image-classification-huggingface-transformers-keras" rel="nofollow">Image Classification with Hugging Face Transformers and <code>Keras</code></a></li> <li>A notebook on <a href="https://github.com/huggingface/notebooks/blob/main/examples/image_classification.ipynb" rel="nofollow">Fine-tuning for Image Classification with Hugging Face Transformers</a></li> <li>A notebook on how to <a href="https://github.com/NielsRogge/Transformers-Tutorials/blob/master/VisionTransformer/Fine_tuning_the_Vision_Transformer_on_CIFAR_10_with_the_%F0%9F%A4%97_Trainer.ipynb" rel="nofollow">Fine-tune the Vision Transformer on CIFAR-10 with the Hugging Face Trainer</a></li> <li>A notebook on how to <a href="https://github.com/NielsRogge/Transformers-Tutorials/blob/master/VisionTransformer/Fine_tuning_the_Vision_Transformer_on_CIFAR_10_with_PyTorch_Lightning.ipynb" rel="nofollow">Fine-tune the Vision Transformer on CIFAR-10 with PyTorch Lightning</a></li>',Te,ae,_="⚗️ Optimization",C,R,B='<li>A blog post on how to <a href="https://www.philschmid.de/optimizing-vision-transformer" rel="nofollow">Accelerate Vision Transformer (ViT) with Quantization using Optimum</a></li>',Y,ve,F="⚡️ Inference",k,G,A='<li>A notebook on <a href="https://github.com/NielsRogge/Transformers-Tutorials/blob/master/VisionTransformer/Quick_demo_of_HuggingFace_version_of_Vision_Transformer_inference.ipynb" rel="nofollow">Quick demo: Vision Transformer (ViT) by Google Brain</a></li>',h,j,Le="🚀 Deploy",Ve,we,We='<li>A blog post on <a href="https://huggingface.co/blog/tf-serving-vision" rel="nofollow">Deploying Tensorflow Vision Models in Hugging Face with TF Serving</a></li> <li>A blog post on <a href="https://huggingface.co/blog/deploy-vertex-ai" rel="nofollow">Deploying Hugging Face ViT on Vertex AI</a></li> <li>A blog post on <a href="https://huggingface.co/blog/deploy-tfserving-kubernetes" rel="nofollow">Deploying Hugging Face ViT on Kubernetes with TF Serving</a></li>',Ze,Ge,Ae,Ne,Oe,wt,rt,kt=`This is the configuration class to store the configuration of a <a href="/docs/transformers/main/en/model_doc/vit#transformers.ViTModel">ViTModel</a>. It is used to instantiate an ViT
model according to the specified arguments, defining the model architecture. Instantiating a configuration with the
defaults will yield a similar configuration to that of the ViT
<a href="https://huggingface.co/google/vit-base-patch16-224" rel="nofollow">google/vit-base-patch16-224</a> architecture.`,Mt,it,Ut=`Configuration objects inherit from <a href="/docs/transformers/main/en/main_classes/configuration#transformers.PretrainedConfig">PretrainedConfig</a> and can be used to control the model outputs. Read the
documentation from <a href="/docs/transformers/main/en/main_classes/configuration#transformers.PretrainedConfig">PretrainedConfig</a> for more information.`,$t,qe,ht,Ke,ft,Ee,et,xt,Xe,tt,Ft,lt,Jt="Preprocess an image or a batch of images.",gt,ot,ut,Re,nt,Vt,dt,Wt="Constructs a ViT image processor.",Ct,Ye,st,jt,ct,Zt="Preprocess an image or batch of images.",_t,Se,Tt,pt,bt;return u=new Pe({props:{title:"Vision Transformer (ViT)",local:"vision-transformer-vit",headingTag:"h1"}}),x=new Pe({props:{title:"Overview",local:"overview",headingTag:"h2"}}),pe=new Pe({props:{title:"Usage tips",local:"usage-tips",headingTag:"h2"}}),ye=new Pe({props:{title:"Resources",local:"resources",headingTag:"h2"}}),Je=new Gt({props:{pipeline:"image-classification"}}),Ge=new Pe({props:{title:"ViTConfig",local:"transformers.ViTConfig",headingTag:"h2"}}),Oe=new Me({props:{name:"class transformers.ViTConfig",anchor:"transformers.ViTConfig",parameters:[{name:"hidden_size",val:" = 768"},{name:"num_hidden_layers",val:" = 12"},{name:"num_attention_heads",val:" = 12"},{name:"intermediate_size",val:" = 3072"},{name:"hidden_act",val:" = 'gelu'"},{name:"hidden_dropout_prob",val:" = 0.0"},{name:"attention_probs_dropout_prob",val:" = 0.0"},{name:"initializer_range",val:" = 0.02"},{name:"layer_norm_eps",val:" = 1e-12"},{name:"image_size",val:" = 224"},{name:"patch_size",val:" = 16"},{name:"num_channels",val:" = 3"},{name:"qkv_bias",val:" = True"},{name:"encoder_stride",val:" = 16"},{name:"**kwargs",val:""}],parametersDescription:[{anchor:"transformers.ViTConfig.hidden_size",description:`<strong>hidden_size</strong> (<code>int</code>, <em>optional</em>, defaults to 768) &#x2014;
Dimensionality of the encoder layers and the pooler layer.`,name:"hidden_size"},{anchor:"transformers.ViTConfig.num_hidden_layers",description:`<strong>num_hidden_layers</strong> (<code>int</code>, <em>optional</em>, defaults to 12) &#x2014;
Number of hidden layers in the Transformer encoder.`,name:"num_hidden_layers"},{anchor:"transformers.ViTConfig.num_attention_heads",description:`<strong>num_attention_heads</strong> (<code>int</code>, <em>optional</em>, defaults to 12) &#x2014;
Number of attention heads for each attention layer in the Transformer encoder.`,name:"num_attention_heads"},{anchor:"transformers.ViTConfig.intermediate_size",description:`<strong>intermediate_size</strong> (<code>int</code>, <em>optional</em>, defaults to 3072) &#x2014;
Dimensionality of the &#x201C;intermediate&#x201D; (i.e., feed-forward) layer in the Transformer encoder.`,name:"intermediate_size"},{anchor:"transformers.ViTConfig.hidden_act",description:`<strong>hidden_act</strong> (<code>str</code> or <code>function</code>, <em>optional</em>, defaults to <code>&quot;gelu&quot;</code>) &#x2014;
The non-linear activation function (function or string) in the encoder and pooler. If string, <code>&quot;gelu&quot;</code>,
<code>&quot;relu&quot;</code>, <code>&quot;selu&quot;</code> and <code>&quot;gelu_new&quot;</code> are supported.`,name:"hidden_act"},{anchor:"transformers.ViTConfig.hidden_dropout_prob",description:`<strong>hidden_dropout_prob</strong> (<code>float</code>, <em>optional</em>, defaults to 0.0) &#x2014;
The dropout probability for all fully connected layers in the embeddings, encoder, and pooler.`,name:"hidden_dropout_prob"},{anchor:"transformers.ViTConfig.attention_probs_dropout_prob",description:`<strong>attention_probs_dropout_prob</strong> (<code>float</code>, <em>optional</em>, defaults to 0.0) &#x2014;
The dropout ratio for the attention probabilities.`,name:"attention_probs_dropout_prob"},{anchor:"transformers.ViTConfig.initializer_range",description:`<strong>initializer_range</strong> (<code>float</code>, <em>optional</em>, defaults to 0.02) &#x2014;
The standard deviation of the truncated_normal_initializer for initializing all weight matrices.`,name:"initializer_range"},{anchor:"transformers.ViTConfig.layer_norm_eps",description:`<strong>layer_norm_eps</strong> (<code>float</code>, <em>optional</em>, defaults to 1e-12) &#x2014;
The epsilon used by the layer normalization layers.`,name:"layer_norm_eps"},{anchor:"transformers.ViTConfig.image_size",description:`<strong>image_size</strong> (<code>int</code>, <em>optional</em>, defaults to 224) &#x2014;
The size (resolution) of each image.`,name:"image_size"},{anchor:"transformers.ViTConfig.patch_size",description:`<strong>patch_size</strong> (<code>int</code>, <em>optional</em>, defaults to 16) &#x2014;
The size (resolution) of each patch.`,name:"patch_size"},{anchor:"transformers.ViTConfig.num_channels",description:`<strong>num_channels</strong> (<code>int</code>, <em>optional</em>, defaults to 3) &#x2014;
The number of input channels.`,name:"num_channels"},{anchor:"transformers.ViTConfig.qkv_bias",description:`<strong>qkv_bias</strong> (<code>bool</code>, <em>optional</em>, defaults to <code>True</code>) &#x2014;
Whether to add a bias to the queries, keys and values.`,name:"qkv_bias"},{anchor:"transformers.ViTConfig.encoder_stride",description:`<strong>encoder_stride</strong> (<code>int</code>, <em>optional</em>, defaults to 16) &#x2014;
Factor to increase the spatial resolution by in the decoder head for masked image modeling.`,name:"encoder_stride"}],source:"https://github.com/huggingface/transformers/blob/main/src/transformers/models/vit/configuration_vit.py#L35"}}),qe=new Qe({props:{anchor:"transformers.ViTConfig.example",$$slots:{default:[Et]},$$scope:{ctx:V}}}),Ke=new Pe({props:{title:"ViTFeatureExtractor",local:"transformers.ViTFeatureExtractor",headingTag:"h2"}}),et=new Me({props:{name:"class transformers.ViTFeatureExtractor",anchor:"transformers.ViTFeatureExtractor",parameters:[{name:"*args",val:""},{name:"**kwargs",val:""}],source:"https://github.com/huggingface/transformers/blob/main/src/transformers/models/vit/feature_extraction_vit.py#L26"}}),tt=new Me({props:{name:"__call__",anchor:"transformers.ViTFeatureExtractor.__call__",parameters:[{name:"images",val:""},{name:"**kwargs",val:""}],source:"https://github.com/huggingface/transformers/blob/main/src/transformers/image_processing_utils.py#L547"}}),ot=new Pe({props:{title:"ViTImageProcessor",local:"transformers.ViTImageProcessor",headingTag:"h2"}}),nt=new Me({props:{name:"class transformers.ViTImageProcessor",anchor:"transformers.ViTImageProcessor",parameters:[{name:"do_resize",val:": bool = True"},{name:"size",val:": typing.Union[typing.Dict[str, int], NoneType] = None"},{name:"resample",val:": Resampling = <Resampling.BILINEAR: 2>"},{name:"do_rescale",val:": bool = True"},{name:"rescale_factor",val:": typing.Union[int, float] = 0.00392156862745098"},{name:"do_normalize",val:": bool = True"},{name:"image_mean",val:": typing.Union[float, typing.List[float], NoneType] = None"},{name:"image_std",val:": typing.Union[float, typing.List[float], NoneType] = None"},{name:"**kwargs",val:""}],parametersDescription:[{anchor:"transformers.ViTImageProcessor.do_resize",description:`<strong>do_resize</strong> (<code>bool</code>, <em>optional</em>, defaults to <code>True</code>) &#x2014;
Whether to resize the image&#x2019;s (height, width) dimensions to the specified <code>(size[&quot;height&quot;], size[&quot;width&quot;])</code>. Can be overridden by the <code>do_resize</code> parameter in the <code>preprocess</code> method.`,name:"do_resize"},{anchor:"transformers.ViTImageProcessor.size",description:`<strong>size</strong> (<code>dict</code>, <em>optional</em>, defaults to <code>{&quot;height&quot; -- 224, &quot;width&quot;: 224}</code>):
Size of the output image after resizing. Can be overridden by the <code>size</code> parameter in the <code>preprocess</code>
method.`,name:"size"},{anchor:"transformers.ViTImageProcessor.resample",description:`<strong>resample</strong> (<code>PILImageResampling</code>, <em>optional</em>, defaults to <code>Resampling.BILINEAR</code>) &#x2014;
Resampling filter to use if resizing the image. Can be overridden by the <code>resample</code> parameter in the
<code>preprocess</code> method.`,name:"resample"},{anchor:"transformers.ViTImageProcessor.do_rescale",description:`<strong>do_rescale</strong> (<code>bool</code>, <em>optional</em>, defaults to <code>True</code>) &#x2014;
Whether to rescale the image by the specified scale <code>rescale_factor</code>. Can be overridden by the <code>do_rescale</code>
parameter in the <code>preprocess</code> method.`,name:"do_rescale"},{anchor:"transformers.ViTImageProcessor.rescale_factor",description:`<strong>rescale_factor</strong> (<code>int</code> or <code>float</code>, <em>optional</em>, defaults to <code>1/255</code>) &#x2014;
Scale factor to use if rescaling the image. Can be overridden by the <code>rescale_factor</code> parameter in the
<code>preprocess</code> method.`,name:"rescale_factor"},{anchor:"transformers.ViTImageProcessor.do_normalize",description:`<strong>do_normalize</strong> (<code>bool</code>, <em>optional</em>, defaults to <code>True</code>) &#x2014;
Whether to normalize the image. Can be overridden by the <code>do_normalize</code> parameter in the <code>preprocess</code>
method.`,name:"do_normalize"},{anchor:"transformers.ViTImageProcessor.image_mean",description:`<strong>image_mean</strong> (<code>float</code> or <code>List[float]</code>, <em>optional</em>, defaults to <code>IMAGENET_STANDARD_MEAN</code>) &#x2014;
Mean to use if normalizing the image. This is a float or list of floats the length of the number of
channels in the image. Can be overridden by the <code>image_mean</code> parameter in the <code>preprocess</code> method.`,name:"image_mean"},{anchor:"transformers.ViTImageProcessor.image_std",description:`<strong>image_std</strong> (<code>float</code> or <code>List[float]</code>, <em>optional</em>, defaults to <code>IMAGENET_STANDARD_STD</code>) &#x2014;
Standard deviation to use if normalizing the image. This is a float or list of floats the length of the
number of channels in the image. Can be overridden by the <code>image_std</code> parameter in the <code>preprocess</code> method.`,name:"image_std"}],source:"https://github.com/huggingface/transformers/blob/main/src/transformers/models/vit/image_processing_vit.py#L41"}}),st=new Me({props:{name:"preprocess",anchor:"transformers.ViTImageProcessor.preprocess",parameters:[{name:"images",val:": typing.Union[ForwardRef('PIL.Image.Image'), numpy.ndarray, ForwardRef('torch.Tensor'), typing.List[ForwardRef('PIL.Image.Image')], typing.List[numpy.ndarray], typing.List[ForwardRef('torch.Tensor')]]"},{name:"do_resize",val:": typing.Optional[bool] = None"},{name:"size",val:": typing.Dict[str, int] = None"},{name:"resample",val:": Resampling = None"},{name:"do_rescale",val:": typing.Optional[bool] = None"},{name:"rescale_factor",val:": typing.Optional[float] = None"},{name:"do_normalize",val:": typing.Optional[bool] = None"},{name:"image_mean",val:": typing.Union[float, typing.List[float], NoneType] = None"},{name:"image_std",val:": typing.Union[float, typing.List[float], NoneType] = None"},{name:"return_tensors",val:": typing.Union[str, transformers.utils.generic.TensorType, NoneType] = None"},{name:"data_format",val:": typing.Union[str, transformers.image_utils.ChannelDimension] = <ChannelDimension.FIRST: 'channels_first'>"},{name:"input_data_format",val:": typing.Union[str, transformers.image_utils.ChannelDimension, NoneType] = None"},{name:"**kwargs",val:""}],parametersDescription:[{anchor:"transformers.ViTImageProcessor.preprocess.images",description:`<strong>images</strong> (<code>ImageInput</code>) &#x2014;
Image to preprocess. Expects a single or batch of images with pixel values ranging from 0 to 255. If
passing in images with pixel values between 0 and 1, set <code>do_rescale=False</code>.`,name:"images"},{anchor:"transformers.ViTImageProcessor.preprocess.do_resize",description:`<strong>do_resize</strong> (<code>bool</code>, <em>optional</em>, defaults to <code>self.do_resize</code>) &#x2014;
Whether to resize the image.`,name:"do_resize"},{anchor:"transformers.ViTImageProcessor.preprocess.size",description:`<strong>size</strong> (<code>Dict[str, int]</code>, <em>optional</em>, defaults to <code>self.size</code>) &#x2014;
Dictionary in the format <code>{&quot;height&quot;: h, &quot;width&quot;: w}</code> specifying the size of the output image after
resizing.`,name:"size"},{anchor:"transformers.ViTImageProcessor.preprocess.resample",description:`<strong>resample</strong> (<code>PILImageResampling</code> filter, <em>optional</em>, defaults to <code>self.resample</code>) &#x2014;
<code>PILImageResampling</code> filter to use if resizing the image e.g. <code>PILImageResampling.BILINEAR</code>. Only has
an effect if <code>do_resize</code> is set to <code>True</code>.`,name:"resample"},{anchor:"transformers.ViTImageProcessor.preprocess.do_rescale",description:`<strong>do_rescale</strong> (<code>bool</code>, <em>optional</em>, defaults to <code>self.do_rescale</code>) &#x2014;
Whether to rescale the image values between [0 - 1].`,name:"do_rescale"},{anchor:"transformers.ViTImageProcessor.preprocess.rescale_factor",description:`<strong>rescale_factor</strong> (<code>float</code>, <em>optional</em>, defaults to <code>self.rescale_factor</code>) &#x2014;
Rescale factor to rescale the image by if <code>do_rescale</code> is set to <code>True</code>.`,name:"rescale_factor"},{anchor:"transformers.ViTImageProcessor.preprocess.do_normalize",description:`<strong>do_normalize</strong> (<code>bool</code>, <em>optional</em>, defaults to <code>self.do_normalize</code>) &#x2014;
Whether to normalize the image.`,name:"do_normalize"},{anchor:"transformers.ViTImageProcessor.preprocess.image_mean",description:`<strong>image_mean</strong> (<code>float</code> or <code>List[float]</code>, <em>optional</em>, defaults to <code>self.image_mean</code>) &#x2014;
Image mean to use if <code>do_normalize</code> is set to <code>True</code>.`,name:"image_mean"},{anchor:"transformers.ViTImageProcessor.preprocess.image_std",description:`<strong>image_std</strong> (<code>float</code> or <code>List[float]</code>, <em>optional</em>, defaults to <code>self.image_std</code>) &#x2014;
Image standard deviation to use if <code>do_normalize</code> is set to <code>True</code>.`,name:"image_std"},{anchor:"transformers.ViTImageProcessor.preprocess.return_tensors",description:`<strong>return_tensors</strong> (<code>str</code> or <code>TensorType</code>, <em>optional</em>) &#x2014;
The type of tensors to return. Can be one of:<ul>
<li>Unset: Return a list of <code>np.ndarray</code>.</li>
<li><code>TensorType.TENSORFLOW</code> or <code>&apos;tf&apos;</code>: Return a batch of type <code>tf.Tensor</code>.</li>
<li><code>TensorType.PYTORCH</code> or <code>&apos;pt&apos;</code>: Return a batch of type <code>torch.Tensor</code>.</li>
<li><code>TensorType.NUMPY</code> or <code>&apos;np&apos;</code>: Return a batch of type <code>np.ndarray</code>.</li>
<li><code>TensorType.JAX</code> or <code>&apos;jax&apos;</code>: Return a batch of type <code>jax.numpy.ndarray</code>.</li>
</ul>`,name:"return_tensors"},{anchor:"transformers.ViTImageProcessor.preprocess.data_format",description:`<strong>data_format</strong> (<code>ChannelDimension</code> or <code>str</code>, <em>optional</em>, defaults to <code>ChannelDimension.FIRST</code>) &#x2014;
The channel dimension format for the output 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>
<li>Unset: Use the channel dimension format of the input image.</li>
</ul>`,name:"data_format"},{anchor:"transformers.ViTImageProcessor.preprocess.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>
<li><code>&quot;none&quot;</code> or <code>ChannelDimension.NONE</code>: image in (height, width) format.</li>
</ul>`,name:"input_data_format"}],source:"https://github.com/huggingface/transformers/blob/main/src/transformers/models/vit/image_processing_vit.py#L146"}}),Se=new Bt({props:{pytorch:!0,tensorflow:!0,jax:!0,$$slots:{jax:[uo],tensorflow:[co],pytorch:[eo]},$$scope:{ctx:V}}}),{c(){e=c("meta"),p=r(),t=c("p"),s=r(),b(u.$$.fragment),n=r(),b(x.$$.fragment),re=r(),I=c("p"),I.innerHTML=P,ie=r(),W=c("p"),W.textContent=S,le=r(),g=c("p"),g.innerHTML=N,E=r(),X=c("img"),_e=r(),J=c("small"),J.innerHTML=de,me=r(),D=c("p"),D.textContent=je,Ie=r(),z=c("ul"),z.innerHTML=ze,U=r(),te=c("p"),te.innerHTML=$e,q=r(),Z=c("p"),Z.innerHTML=xe,O=r(),b(pe.$$.fragment),Fe=r(),oe=c("ul"),oe.innerHTML=ke,ne=r(),b(ye.$$.fragment),se=r(),K=c("p"),K.innerHTML=Q,H=r(),ce=c("p"),ce.innerHTML=Ue,he=r(),b(Je.$$.fragment),fe=r(),L=c("ul"),L.innerHTML=ge,Te=r(),ae=c("p"),ae.textContent=_,C=r(),R=c("ul"),R.innerHTML=B,Y=r(),ve=c("p"),ve.textContent=F,k=r(),G=c("ul"),G.innerHTML=A,h=r(),j=c("p"),j.textContent=Le,Ve=r(),we=c("ul"),we.innerHTML=We,Ze=r(),b(Ge.$$.fragment),Ae=r(),Ne=c("div"),b(Oe.$$.fragment),wt=r(),rt=c("p"),rt.innerHTML=kt,Mt=r(),it=c("p"),it.innerHTML=Ut,$t=r(),b(qe.$$.fragment),ht=r(),b(Ke.$$.fragment),ft=r(),Ee=c("div"),b(et.$$.fragment),xt=r(),Xe=c("div"),b(tt.$$.fragment),Ft=r(),lt=c("p"),lt.textContent=Jt,gt=r(),b(ot.$$.fragment),ut=r(),Re=c("div"),b(nt.$$.fragment),Vt=r(),dt=c("p"),dt.textContent=Wt,Ct=r(),Ye=c("div"),b(st.$$.fragment),jt=r(),ct=c("p"),ct.textContent=Zt,_t=r(),b(Se.$$.fragment),Tt=r(),pt=c("p"),this.h()},l(o){const T=Rt("svelte-u9bgzb",document.head);e=m(T,"META",{name:!0,content:!0}),T.forEach(a),p=i(o),t=m(o,"P",{}),ue(t).forEach(a),s=i(o),y(u.$$.fragment,o),n=i(o),y(x.$$.fragment,o),re=i(o),I=m(o,"P",{"data-svelte-h":!0}),f(I)!=="svelte-mxwj6a"&&(I.innerHTML=P),ie=i(o),W=m(o,"P",{"data-svelte-h":!0}),f(W)!=="svelte-vfdo9a"&&(W.textContent=S),le=i(o),g=m(o,"P",{"data-svelte-h":!0}),f(g)!=="svelte-yjj3f8"&&(g.innerHTML=N),E=i(o),X=m(o,"IMG",{src:!0,alt:!0,width:!0}),_e=i(o),J=m(o,"SMALL",{"data-svelte-h":!0}),f(J)!=="svelte-7mkw5i"&&(J.innerHTML=de),me=i(o),D=m(o,"P",{"data-svelte-h":!0}),f(D)!=="svelte-ghhnmw"&&(D.textContent=je),Ie=i(o),z=m(o,"UL",{"data-svelte-h":!0}),f(z)!=="svelte-fy3i6u"&&(z.innerHTML=ze),U=i(o),te=m(o,"P",{"data-svelte-h":!0}),f(te)!=="svelte-pwnwoc"&&(te.innerHTML=$e),q=i(o),Z=m(o,"P",{"data-svelte-h":!0}),f(Z)!=="svelte-11xcw47"&&(Z.innerHTML=xe),O=i(o),y(pe.$$.fragment,o),Fe=i(o),oe=m(o,"UL",{"data-svelte-h":!0}),f(oe)!=="svelte-af9b86"&&(oe.innerHTML=ke),ne=i(o),y(ye.$$.fragment,o),se=i(o),K=m(o,"P",{"data-svelte-h":!0}),f(K)!=="svelte-152spv0"&&(K.innerHTML=Q),H=i(o),ce=m(o,"P",{"data-svelte-h":!0}),f(ce)!=="svelte-qrf7lp"&&(ce.innerHTML=Ue),he=i(o),y(Je.$$.fragment,o),fe=i(o),L=m(o,"UL",{"data-svelte-h":!0}),f(L)!=="svelte-1fybkhs"&&(L.innerHTML=ge),Te=i(o),ae=m(o,"P",{"data-svelte-h":!0}),f(ae)!=="svelte-liq2q7"&&(ae.textContent=_),C=i(o),R=m(o,"UL",{"data-svelte-h":!0}),f(R)!=="svelte-1vxkfqp"&&(R.innerHTML=B),Y=i(o),ve=m(o,"P",{"data-svelte-h":!0}),f(ve)!=="svelte-1wntqpp"&&(ve.textContent=F),k=i(o),G=m(o,"UL",{"data-svelte-h":!0}),f(G)!=="svelte-1q3e2i6"&&(G.innerHTML=A),h=i(o),j=m(o,"P",{"data-svelte-h":!0}),f(j)!=="svelte-lk14e4"&&(j.textContent=Le),Ve=i(o),we=m(o,"UL",{"data-svelte-h":!0}),f(we)!=="svelte-1e4wiq4"&&(we.innerHTML=We),Ze=i(o),y(Ge.$$.fragment,o),Ae=i(o),Ne=m(o,"DIV",{class:!0});var Be=ue(Ne);y(Oe.$$.fragment,Be),wt=i(Be),rt=m(Be,"P",{"data-svelte-h":!0}),f(rt)!=="svelte-1jonrz8"&&(rt.innerHTML=kt),Mt=i(Be),it=m(Be,"P",{"data-svelte-h":!0}),f(it)!=="svelte-o55m63"&&(it.innerHTML=Ut),$t=i(Be),y(qe.$$.fragment,Be),Be.forEach(a),ht=i(o),y(Ke.$$.fragment,o),ft=i(o),Ee=m(o,"DIV",{class:!0});var at=ue(Ee);y(et.$$.fragment,at),xt=i(at),Xe=m(at,"DIV",{class:!0});var yt=ue(Xe);y(tt.$$.fragment,yt),Ft=i(yt),lt=m(yt,"P",{"data-svelte-h":!0}),f(lt)!=="svelte-khengj"&&(lt.textContent=Jt),yt.forEach(a),at.forEach(a),gt=i(o),y(ot.$$.fragment,o),ut=i(o),Re=m(o,"DIV",{class:!0});var mt=ue(Re);y(nt.$$.fragment,mt),Vt=i(mt),dt=m(mt,"P",{"data-svelte-h":!0}),f(dt)!=="svelte-1ebexfn"&&(dt.textContent=Wt),Ct=i(mt),Ye=m(mt,"DIV",{class:!0});var vt=ue(Ye);y(st.$$.fragment,vt),jt=i(vt),ct=m(vt,"P",{"data-svelte-h":!0}),f(ct)!=="svelte-1x3yxsa"&&(ct.textContent=Zt),vt.forEach(a),mt.forEach(a),_t=i(o),y(Se.$$.fragment,o),Tt=i(o),pt=m(o,"P",{}),ue(pt).forEach(a),this.h()},h(){ee(e,"name","hf:doc:metadata"),ee(e,"content",To),zt(X.src,Ce="https://huggingface.co/datasets/huggingface/documentation-images/resolve/main/transformers/model_doc/vit_architecture.jpg")||ee(X,"src",Ce),ee(X,"alt","drawing"),ee(X,"width","600"),ee(Ne,"class","docstring border-l-2 border-t-2 pl-4 pt-3.5 border-gray-100 rounded-tl-xl mb-6 mt-8"),ee(Xe,"class","docstring border-l-2 border-t-2 pl-4 pt-3.5 border-gray-100 rounded-tl-xl mb-6 mt-8"),ee(Ee,"class","docstring border-l-2 border-t-2 pl-4 pt-3.5 border-gray-100 rounded-tl-xl mb-6 mt-8"),ee(Ye,"class","docstring border-l-2 border-t-2 pl-4 pt-3.5 border-gray-100 rounded-tl-xl mb-6 mt-8"),ee(Re,"class","docstring border-l-2 border-t-2 pl-4 pt-3.5 border-gray-100 rounded-tl-xl mb-6 mt-8")},m(o,T){d(document.head,e),l(o,p,T),l(o,t,T),l(o,s,T),v(u,o,T),l(o,n,T),v(x,o,T),l(o,re,T),l(o,I,T),l(o,ie,T),l(o,W,T),l(o,le,T),l(o,g,T),l(o,E,T),l(o,X,T),l(o,_e,T),l(o,J,T),l(o,me,T),l(o,D,T),l(o,Ie,T),l(o,z,T),l(o,U,T),l(o,te,T),l(o,q,T),l(o,Z,T),l(o,O,T),v(pe,o,T),l(o,Fe,T),l(o,oe,T),l(o,ne,T),v(ye,o,T),l(o,se,T),l(o,K,T),l(o,H,T),l(o,ce,T),l(o,he,T),v(Je,o,T),l(o,fe,T),l(o,L,T),l(o,Te,T),l(o,ae,T),l(o,C,T),l(o,R,T),l(o,Y,T),l(o,ve,T),l(o,k,T),l(o,G,T),l(o,h,T),l(o,j,T),l(o,Ve,T),l(o,we,T),l(o,Ze,T),v(Ge,o,T),l(o,Ae,T),l(o,Ne,T),v(Oe,Ne,null),d(Ne,wt),d(Ne,rt),d(Ne,Mt),d(Ne,it),d(Ne,$t),v(qe,Ne,null),l(o,ht,T),v(Ke,o,T),l(o,ft,T),l(o,Ee,T),v(et,Ee,null),d(Ee,xt),d(Ee,Xe),v(tt,Xe,null),d(Xe,Ft),d(Xe,lt),l(o,gt,T),v(ot,o,T),l(o,ut,T),l(o,Re,T),v(nt,Re,null),d(Re,Vt),d(Re,dt),d(Re,Ct),d(Re,Ye),v(st,Ye,null),d(Ye,jt),d(Ye,ct),l(o,_t,T),v(Se,o,T),l(o,Tt,T),l(o,pt,T),bt=!0},p(o,[T]){const Be={};T&2&&(Be.$$scope={dirty:T,ctx:o}),qe.$set(Be);const at={};T&2&&(at.$$scope={dirty:T,ctx:o}),Se.$set(at)},i(o){bt||(w(u.$$.fragment,o),w(x.$$.fragment,o),w(pe.$$.fragment,o),w(ye.$$.fragment,o),w(Je.$$.fragment,o),w(Ge.$$.fragment,o),w(Oe.$$.fragment,o),w(qe.$$.fragment,o),w(Ke.$$.fragment,o),w(et.$$.fragment,o),w(tt.$$.fragment,o),w(ot.$$.fragment,o),w(nt.$$.fragment,o),w(st.$$.fragment,o),w(Se.$$.fragment,o),bt=!0)},o(o){M(u.$$.fragment,o),M(x.$$.fragment,o),M(pe.$$.fragment,o),M(ye.$$.fragment,o),M(Je.$$.fragment,o),M(Ge.$$.fragment,o),M(Oe.$$.fragment,o),M(qe.$$.fragment,o),M(Ke.$$.fragment,o),M(et.$$.fragment,o),M(tt.$$.fragment,o),M(ot.$$.fragment,o),M(nt.$$.fragment,o),M(st.$$.fragment,o),M(Se.$$.fragment,o),bt=!1},d(o){o&&(a(p),a(t),a(s),a(n),a(re),a(I),a(ie),a(W),a(le),a(g),a(E),a(X),a(_e),a(J),a(me),a(D),a(Ie),a(z),a(U),a(te),a(q),a(Z),a(O),a(Fe),a(oe),a(ne),a(se),a(K),a(H),a(ce),a(he),a(fe),a(L),a(Te),a(ae),a(C),a(R),a(Y),a(ve),a(k),a(G),a(h),a(j),a(Ve),a(we),a(Ze),a(Ae),a(Ne),a(ht),a(ft),a(Ee),a(gt),a(ut),a(Re),a(_t),a(Tt),a(pt)),a(e),$(u,o),$(x,o),$(pe,o),$(ye,o),$(Je,o),$(Ge,o),$(Oe),$(qe),$(Ke,o),$(et),$(tt),$(ot,o),$(nt),$(st),$(Se,o)}}}const To='{"title":"Vision Transformer (ViT)","local":"vision-transformer-vit","sections":[{"title":"Overview","local":"overview","sections":[],"depth":2},{"title":"Usage tips","local":"usage-tips","sections":[],"depth":2},{"title":"Resources","local":"resources","sections":[],"depth":2},{"title":"ViTConfig","local":"transformers.ViTConfig","sections":[],"depth":2},{"title":"ViTFeatureExtractor","local":"transformers.ViTFeatureExtractor","sections":[],"depth":2},{"title":"ViTImageProcessor","local":"transformers.ViTImageProcessor","sections":[],"depth":2},{"title":"ViTModel","local":"transformers.ViTModel","sections":[],"depth":2},{"title":"ViTForMaskedImageModeling","local":"transformers.ViTForMaskedImageModeling","sections":[],"depth":2},{"title":"ViTForImageClassification","local":"transformers.ViTForImageClassification","sections":[],"depth":2},{"title":"TFViTModel","local":"transformers.TFViTModel","sections":[],"depth":2},{"title":"TFViTForImageClassification","local":"transformers.TFViTForImageClassification","sections":[],"depth":2},{"title":"FlaxVitModel","local":"transformers.FlaxViTModel","sections":[],"depth":2},{"title":"FlaxViTForImageClassification","local":"transformers.FlaxViTForImageClassification","sections":[],"depth":2}],"depth":1}';function bo(V){return Lt(()=>{new URLSearchParams(window.location.search).get("fw")}),[]}class jo extends Pt{constructor(e){super(),Ht(this,e,bo,_o,Nt,{})}}export{jo as component};
