import{s as Ne,o as ze,n as je}from"../chunks/scheduler.25b97de1.js";import{S as Be,i as Re,g as h,s as l,r as _,A as Ve,h as u,f as s,c as i,j as ue,u as b,x as $,k as ge,y as c,a as d,v,d as y,t as M,w}from"../chunks/index.d9030fc9.js";import{T as Ze}from"../chunks/Tip.baa67368.js";import{D as Te}from"../chunks/Docstring.ffac8efa.js";import{C as Ue}from"../chunks/CodeBlock.e6cd0d95.js";import{F as Ye,M as De}from"../chunks/Markdown.7217f838.js";import{E as We}from"../chunks/ExampleCodeBlock.22dfe688.js";import{P as Ge}from"../chunks/PipelineTag.5f100392.js";import{H as $e,E as He}from"../chunks/EditOnGithub.91d95064.js";function Ee(I){let t,f="Example:",n,a,g;return a=new Ue({props:{code:"ZnJvbSUyMHRyYW5zZm9ybWVycyUyMGltcG9ydCUyMERpbm92MkNvbmZpZyUyQyUyMERpbm92Mk1vZGVsJTBBJTBBJTIzJTIwSW5pdGlhbGl6aW5nJTIwYSUyMERpbm92MiUyMGRpbm92Mi1iYXNlLXBhdGNoMTYtMjI0JTIwc3R5bGUlMjBjb25maWd1cmF0aW9uJTBBY29uZmlndXJhdGlvbiUyMCUzRCUyMERpbm92MkNvbmZpZygpJTBBJTBBJTIzJTIwSW5pdGlhbGl6aW5nJTIwYSUyMG1vZGVsJTIwKHdpdGglMjByYW5kb20lMjB3ZWlnaHRzKSUyMGZyb20lMjB0aGUlMjBkaW5vdjItYmFzZS1wYXRjaDE2LTIyNCUyMHN0eWxlJTIwY29uZmlndXJhdGlvbiUwQW1vZGVsJTIwJTNEJTIwRGlub3YyTW9kZWwoY29uZmlndXJhdGlvbiklMEElMEElMjMlMjBBY2Nlc3NpbmclMjB0aGUlMjBtb2RlbCUyMGNvbmZpZ3VyYXRpb24lMEFjb25maWd1cmF0aW9uJTIwJTNEJTIwbW9kZWwuY29uZmln",highlighted:`<span class="hljs-meta">&gt;&gt;&gt; </span><span class="hljs-keyword">from</span> transformers <span class="hljs-keyword">import</span> Dinov2Config, Dinov2Model

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

<span class="hljs-meta">&gt;&gt;&gt; </span><span class="hljs-comment"># Initializing a model (with random weights) from the dinov2-base-patch16-224 style configuration</span>
<span class="hljs-meta">&gt;&gt;&gt; </span>model = Dinov2Model(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(){t=h("p"),t.textContent=f,n=l(),_(a.$$.fragment)},l(o){t=u(o,"P",{"data-svelte-h":!0}),$(t)!=="svelte-11lpom8"&&(t.textContent=f),n=i(o),b(a.$$.fragment,o)},m(o,C){d(o,t,C),d(o,n,C),v(a,o,C),g=!0},p:je,i(o){g||(y(a.$$.fragment,o),g=!0)},o(o){M(a.$$.fragment,o),g=!1},d(o){o&&(s(t),s(n)),w(a,o)}}}function Xe(I){let t,f=`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(){t=h("p"),t.innerHTML=f},l(n){t=u(n,"P",{"data-svelte-h":!0}),$(t)!=="svelte-fincs2"&&(t.innerHTML=f)},m(n,a){d(n,t,a)},p:je,d(n){n&&s(t)}}}function Pe(I){let t,f="Example:",n,a,g;return a=new Ue({props:{code:"ZnJvbSUyMHRyYW5zZm9ybWVycyUyMGltcG9ydCUyMEF1dG9JbWFnZVByb2Nlc3NvciUyQyUyMERpbm92Mk1vZGVsJTBBaW1wb3J0JTIwdG9yY2glMEFmcm9tJTIwZGF0YXNldHMlMjBpbXBvcnQlMjBsb2FkX2RhdGFzZXQlMEElMEFkYXRhc2V0JTIwJTNEJTIwbG9hZF9kYXRhc2V0KCUyMmh1Z2dpbmdmYWNlJTJGY2F0cy1pbWFnZSUyMiUyQyUyMHRydXN0X3JlbW90ZV9jb2RlJTNEVHJ1ZSklMEFpbWFnZSUyMCUzRCUyMGRhdGFzZXQlNUIlMjJ0ZXN0JTIyJTVEJTVCJTIyaW1hZ2UlMjIlNUQlNUIwJTVEJTBBJTBBaW1hZ2VfcHJvY2Vzc29yJTIwJTNEJTIwQXV0b0ltYWdlUHJvY2Vzc29yLmZyb21fcHJldHJhaW5lZCglMjJmYWNlYm9vayUyRmRpbm92Mi1iYXNlJTIyKSUwQW1vZGVsJTIwJTNEJTIwRGlub3YyTW9kZWwuZnJvbV9wcmV0cmFpbmVkKCUyMmZhY2Vib29rJTJGZGlub3YyLWJhc2UlMjIpJTBBJTBBaW5wdXRzJTIwJTNEJTIwaW1hZ2VfcHJvY2Vzc29yKGltYWdlJTJDJTIwcmV0dXJuX3RlbnNvcnMlM0QlMjJwdCUyMiklMEElMEF3aXRoJTIwdG9yY2gubm9fZ3JhZCgpJTNBJTBBJTIwJTIwJTIwJTIwb3V0cHV0cyUyMCUzRCUyMG1vZGVsKCoqaW5wdXRzKSUwQSUwQWxhc3RfaGlkZGVuX3N0YXRlcyUyMCUzRCUyMG91dHB1dHMubGFzdF9oaWRkZW5fc3RhdGUlMEFsaXN0KGxhc3RfaGlkZGVuX3N0YXRlcy5zaGFwZSk=",highlighted:`<span class="hljs-meta">&gt;&gt;&gt; </span><span class="hljs-keyword">from</span> transformers <span class="hljs-keyword">import</span> AutoImageProcessor, Dinov2Model
<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>, trust_remote_code=<span class="hljs-literal">True</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;facebook/dinov2-base&quot;</span>)
<span class="hljs-meta">&gt;&gt;&gt; </span>model = Dinov2Model.from_pretrained(<span class="hljs-string">&quot;facebook/dinov2-base&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">257</span>, <span class="hljs-number">768</span>]`,wrap:!1}}),{c(){t=h("p"),t.textContent=f,n=l(),_(a.$$.fragment)},l(o){t=u(o,"P",{"data-svelte-h":!0}),$(t)!=="svelte-11lpom8"&&(t.textContent=f),n=i(o),b(a.$$.fragment,o)},m(o,C){d(o,t,C),d(o,n,C),v(a,o,C),g=!0},p:je,i(o){g||(y(a.$$.fragment,o),g=!0)},o(o){M(a.$$.fragment,o),g=!1},d(o){o&&(s(t),s(n)),w(a,o)}}}function Le(I){let t,f=`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(){t=h("p"),t.innerHTML=f},l(n){t=u(n,"P",{"data-svelte-h":!0}),$(t)!=="svelte-fincs2"&&(t.innerHTML=f)},m(n,a){d(n,t,a)},p:je,d(n){n&&s(t)}}}function qe(I){let t,f="Example:",n,a,g;return a=new Ue({props:{code:"ZnJvbSUyMHRyYW5zZm9ybWVycyUyMGltcG9ydCUyMEF1dG9JbWFnZVByb2Nlc3NvciUyQyUyMERpbm92MkZvckltYWdlQ2xhc3NpZmljYXRpb24lMEFpbXBvcnQlMjB0b3JjaCUwQWZyb20lMjBkYXRhc2V0cyUyMGltcG9ydCUyMGxvYWRfZGF0YXNldCUwQSUwQWRhdGFzZXQlMjAlM0QlMjBsb2FkX2RhdGFzZXQoJTIyaHVnZ2luZ2ZhY2UlMkZjYXRzLWltYWdlJTIyJTJDJTIwdHJ1c3RfcmVtb3RlX2NvZGUlM0RUcnVlKSUwQWltYWdlJTIwJTNEJTIwZGF0YXNldCU1QiUyMnRlc3QlMjIlNUQlNUIlMjJpbWFnZSUyMiU1RCU1QjAlNUQlMEElMEFpbWFnZV9wcm9jZXNzb3IlMjAlM0QlMjBBdXRvSW1hZ2VQcm9jZXNzb3IuZnJvbV9wcmV0cmFpbmVkKCUyMmZhY2Vib29rJTJGZGlub3YyLXNtYWxsLWltYWdlbmV0MWstMS1sYXllciUyMiklMEFtb2RlbCUyMCUzRCUyMERpbm92MkZvckltYWdlQ2xhc3NpZmljYXRpb24uZnJvbV9wcmV0cmFpbmVkKCUyMmZhY2Vib29rJTJGZGlub3YyLXNtYWxsLWltYWdlbmV0MWstMS1sYXllciUyMiklMEElMEFpbnB1dHMlMjAlM0QlMjBpbWFnZV9wcm9jZXNzb3IoaW1hZ2UlMkMlMjByZXR1cm5fdGVuc29ycyUzRCUyMnB0JTIyKSUwQSUwQXdpdGglMjB0b3JjaC5ub19ncmFkKCklM0ElMEElMjAlMjAlMjAlMjBsb2dpdHMlMjAlM0QlMjBtb2RlbCgqKmlucHV0cykubG9naXRzJTBBJTBBJTIzJTIwbW9kZWwlMjBwcmVkaWN0cyUyMG9uZSUyMG9mJTIwdGhlJTIwMTAwMCUyMEltYWdlTmV0JTIwY2xhc3NlcyUwQXByZWRpY3RlZF9sYWJlbCUyMCUzRCUyMGxvZ2l0cy5hcmdtYXgoLTEpLml0ZW0oKSUwQXByaW50KG1vZGVsLmNvbmZpZy5pZDJsYWJlbCU1QnByZWRpY3RlZF9sYWJlbCU1RCk=",highlighted:`<span class="hljs-meta">&gt;&gt;&gt; </span><span class="hljs-keyword">from</span> transformers <span class="hljs-keyword">import</span> AutoImageProcessor, Dinov2ForImageClassification
<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>, trust_remote_code=<span class="hljs-literal">True</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;facebook/dinov2-small-imagenet1k-1-layer&quot;</span>)
<span class="hljs-meta">&gt;&gt;&gt; </span>model = Dinov2ForImageClassification.from_pretrained(<span class="hljs-string">&quot;facebook/dinov2-small-imagenet1k-1-layer&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])
tabby, tabby cat`,wrap:!1}}),{c(){t=h("p"),t.textContent=f,n=l(),_(a.$$.fragment)},l(o){t=u(o,"P",{"data-svelte-h":!0}),$(t)!=="svelte-11lpom8"&&(t.textContent=f),n=i(o),b(a.$$.fragment,o)},m(o,C){d(o,t,C),d(o,n,C),v(a,o,C),g=!0},p:je,i(o){g||(y(a.$$.fragment,o),g=!0)},o(o){M(a.$$.fragment,o),g=!1},d(o){o&&(s(t),s(n)),w(a,o)}}}function Se(I){let t,f,n,a,g,o,C=`The bare DINOv2 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.`,ie,F,oe,de,N,xe='The <a href="/docs/transformers/main/en/model_doc/dinov2#transformers.Dinov2Model">Dinov2Model</a> forward method, overrides the <code>__call__</code> special method.',ce,k,ye,E,Y,ae,se,x,B,A,L,_e=`Dinov2 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.`,O,R,K=`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.`,X,U,H,re,J,le='The <a href="/docs/transformers/main/en/model_doc/dinov2#transformers.Dinov2ForImageClassification">Dinov2ForImageClassification</a> forward method, overrides the <code>__call__</code> special method.',me,W,pe,V,ee;return t=new $e({props:{title:"Dinov2Model",local:"transformers.Dinov2Model",headingTag:"h2"}}),a=new Te({props:{name:"class transformers.Dinov2Model",anchor:"transformers.Dinov2Model",parameters:[{name:"config",val:": Dinov2Config"}],parametersDescription:[{anchor:"transformers.Dinov2Model.config",description:`<strong>config</strong> (<a href="/docs/transformers/main/en/model_doc/dinov2#transformers.Dinov2Config">Dinov2Config</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/dinov2/modeling_dinov2.py#L576"}}),oe=new Te({props:{name:"forward",anchor:"transformers.Dinov2Model.forward",parameters:[{name:"pixel_values",val:": Optional = None"},{name:"bool_masked_pos",val:": Optional = None"},{name:"head_mask",val:": Optional = None"},{name:"output_attentions",val:": Optional = None"},{name:"output_hidden_states",val:": Optional = None"},{name:"return_dict",val:": Optional = None"}],parametersDescription:[{anchor:"transformers.Dinov2Model.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/bit#transformers.BitImageProcessor.preprocess">BitImageProcessor.preprocess()</a> for details.`,name:"pixel_values"},{anchor:"transformers.Dinov2Model.forward.bool_masked_pos",description:`<strong>bool_masked_pos</strong> (<code>torch.BoolTensor</code> of shape <code>(batch_size, sequence_length)</code>) &#x2014;
Boolean masked positions. Indicates which patches are masked (1) and which aren&#x2019;t (0). Only relevant for
pre-training.`,name:"bool_masked_pos"},{anchor:"transformers.Dinov2Model.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.Dinov2Model.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.Dinov2Model.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.Dinov2Model.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"}],source:"https://github.com/huggingface/transformers/blob/main/src/transformers/models/dinov2/modeling_dinov2.py#L604",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/dinov2#transformers.Dinov2Config"
>Dinov2Config</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>
`}}),k=new Ze({props:{$$slots:{default:[Xe]},$$scope:{ctx:I}}}),E=new We({props:{anchor:"transformers.Dinov2Model.forward.example",$$slots:{default:[Pe]},$$scope:{ctx:I}}}),ae=new $e({props:{title:"Dinov2ForImageClassification",local:"transformers.Dinov2ForImageClassification",headingTag:"h2"}}),B=new Te({props:{name:"class transformers.Dinov2ForImageClassification",anchor:"transformers.Dinov2ForImageClassification",parameters:[{name:"config",val:": Dinov2Config"}],parametersDescription:[{anchor:"transformers.Dinov2ForImageClassification.config",description:`<strong>config</strong> (<a href="/docs/transformers/main/en/model_doc/dinov2#transformers.Dinov2Config">Dinov2Config</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/dinov2/modeling_dinov2.py#L662"}}),H=new Te({props:{name:"forward",anchor:"transformers.Dinov2ForImageClassification.forward",parameters:[{name:"pixel_values",val:": Optional = None"},{name:"head_mask",val:": Optional = None"},{name:"labels",val:": Optional = None"},{name:"output_attentions",val:": Optional = None"},{name:"output_hidden_states",val:": Optional = None"},{name:"return_dict",val:": Optional = None"}],parametersDescription:[{anchor:"transformers.Dinov2ForImageClassification.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/bit#transformers.BitImageProcessor.preprocess">BitImageProcessor.preprocess()</a> for details.`,name:"pixel_values"},{anchor:"transformers.Dinov2ForImageClassification.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.Dinov2ForImageClassification.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.Dinov2ForImageClassification.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.Dinov2ForImageClassification.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.Dinov2ForImageClassification.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/dinov2/modeling_dinov2.py#L684",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/dinov2#transformers.Dinov2Config"
>Dinov2Config</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>
`}}),W=new Ze({props:{$$slots:{default:[Le]},$$scope:{ctx:I}}}),V=new We({props:{anchor:"transformers.Dinov2ForImageClassification.forward.example",$$slots:{default:[qe]},$$scope:{ctx:I}}}),{c(){_(t.$$.fragment),f=l(),n=h("div"),_(a.$$.fragment),g=l(),o=h("p"),o.innerHTML=C,ie=l(),F=h("div"),_(oe.$$.fragment),de=l(),N=h("p"),N.innerHTML=xe,ce=l(),_(k.$$.fragment),ye=l(),_(E.$$.fragment),Y=l(),_(ae.$$.fragment),se=l(),x=h("div"),_(B.$$.fragment),A=l(),L=h("p"),L.textContent=_e,O=l(),R=h("p"),R.innerHTML=K,X=l(),U=h("div"),_(H.$$.fragment),re=l(),J=h("p"),J.innerHTML=le,me=l(),_(W.$$.fragment),pe=l(),_(V.$$.fragment),this.h()},l(m){b(t.$$.fragment,m),f=i(m),n=u(m,"DIV",{class:!0});var j=ue(n);b(a.$$.fragment,j),g=i(j),o=u(j,"P",{"data-svelte-h":!0}),$(o)!=="svelte-1jmeimp"&&(o.innerHTML=C),ie=i(j),F=u(j,"DIV",{class:!0});var z=ue(F);b(oe.$$.fragment,z),de=i(z),N=u(z,"P",{"data-svelte-h":!0}),$(N)!=="svelte-g9ij7n"&&(N.innerHTML=xe),ce=i(z),b(k.$$.fragment,z),ye=i(z),b(E.$$.fragment,z),z.forEach(s),j.forEach(s),Y=i(m),b(ae.$$.fragment,m),se=i(m),x=u(m,"DIV",{class:!0});var G=ue(x);b(B.$$.fragment,G),A=i(G),L=u(G,"P",{"data-svelte-h":!0}),$(L)!=="svelte-1i57dtz"&&(L.textContent=_e),O=i(G),R=u(G,"P",{"data-svelte-h":!0}),$(R)!=="svelte-1gjh92c"&&(R.innerHTML=K),X=i(G),U=u(G,"DIV",{class:!0});var Z=ue(U);b(H.$$.fragment,Z),re=i(Z),J=u(Z,"P",{"data-svelte-h":!0}),$(J)!=="svelte-1olmd1j"&&(J.innerHTML=le),me=i(Z),b(W.$$.fragment,Z),pe=i(Z),b(V.$$.fragment,Z),Z.forEach(s),G.forEach(s),this.h()},h(){ge(F,"class","docstring border-l-2 border-t-2 pl-4 pt-3.5 border-gray-100 rounded-tl-xl mb-6 mt-8"),ge(n,"class","docstring border-l-2 border-t-2 pl-4 pt-3.5 border-gray-100 rounded-tl-xl mb-6 mt-8"),ge(U,"class","docstring border-l-2 border-t-2 pl-4 pt-3.5 border-gray-100 rounded-tl-xl mb-6 mt-8"),ge(x,"class","docstring border-l-2 border-t-2 pl-4 pt-3.5 border-gray-100 rounded-tl-xl mb-6 mt-8")},m(m,j){v(t,m,j),d(m,f,j),d(m,n,j),v(a,n,null),c(n,g),c(n,o),c(n,ie),c(n,F),v(oe,F,null),c(F,de),c(F,N),c(F,ce),v(k,F,null),c(F,ye),v(E,F,null),d(m,Y,j),v(ae,m,j),d(m,se,j),d(m,x,j),v(B,x,null),c(x,A),c(x,L),c(x,O),c(x,R),c(x,X),c(x,U),v(H,U,null),c(U,re),c(U,J),c(U,me),v(W,U,null),c(U,pe),v(V,U,null),ee=!0},p(m,j){const z={};j&2&&(z.$$scope={dirty:j,ctx:m}),k.$set(z);const G={};j&2&&(G.$$scope={dirty:j,ctx:m}),E.$set(G);const Z={};j&2&&(Z.$$scope={dirty:j,ctx:m}),W.$set(Z);const te={};j&2&&(te.$$scope={dirty:j,ctx:m}),V.$set(te)},i(m){ee||(y(t.$$.fragment,m),y(a.$$.fragment,m),y(oe.$$.fragment,m),y(k.$$.fragment,m),y(E.$$.fragment,m),y(ae.$$.fragment,m),y(B.$$.fragment,m),y(H.$$.fragment,m),y(W.$$.fragment,m),y(V.$$.fragment,m),ee=!0)},o(m){M(t.$$.fragment,m),M(a.$$.fragment,m),M(oe.$$.fragment,m),M(k.$$.fragment,m),M(E.$$.fragment,m),M(ae.$$.fragment,m),M(B.$$.fragment,m),M(H.$$.fragment,m),M(W.$$.fragment,m),M(V.$$.fragment,m),ee=!1},d(m){m&&(s(f),s(n),s(Y),s(se),s(x)),w(t,m),w(a),w(oe),w(k),w(E),w(ae,m),w(B),w(H),w(W),w(V)}}}function Qe(I){let t,f;return t=new De({props:{$$slots:{default:[Se]},$$scope:{ctx:I}}}),{c(){_(t.$$.fragment)},l(n){b(t.$$.fragment,n)},m(n,a){v(t,n,a),f=!0},p(n,a){const g={};a&2&&(g.$$scope={dirty:a,ctx:n}),t.$set(g)},i(n){f||(y(t.$$.fragment,n),f=!0)},o(n){M(t.$$.fragment,n),f=!1},d(n){w(t,n)}}}function Ae(I){let t,f=`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(){t=h("p"),t.innerHTML=f},l(n){t=u(n,"P",{"data-svelte-h":!0}),$(t)!=="svelte-fincs2"&&(t.innerHTML=f)},m(n,a){d(n,t,a)},p:je,d(n){n&&s(t)}}}function Oe(I){let t,f="Examples:",n,a,g;return a=new Ue({props:{code:"ZnJvbSUyMHRyYW5zZm9ybWVycyUyMGltcG9ydCUyMEF1dG9JbWFnZVByb2Nlc3NvciUyQyUyMEZsYXhEaW5vdjJNb2RlbCUwQWZyb20lMjBQSUwlMjBpbXBvcnQlMjBJbWFnZSUwQWltcG9ydCUyMHJlcXVlc3RzJTBBJTBBdXJsJTIwJTNEJTIwJTIyaHR0cCUzQSUyRiUyRmltYWdlcy5jb2NvZGF0YXNldC5vcmclMkZ2YWwyMDE3JTJGMDAwMDAwMDM5NzY5LmpwZyUyMiUwQWltYWdlJTIwJTNEJTIwSW1hZ2Uub3BlbihyZXF1ZXN0cy5nZXQodXJsJTJDJTIwc3RyZWFtJTNEVHJ1ZSkucmF3KSUwQSUwQWltYWdlX3Byb2Nlc3NvciUyMCUzRCUyMEF1dG9JbWFnZVByb2Nlc3Nvci5mcm9tX3ByZXRyYWluZWQoJTIyZmFjZWJvb2slMkZkaW5vdjItYmFzZSUyMiklMEFtb2RlbCUyMCUzRCUyMEZsYXhEaW5vdjJNb2RlbC5mcm9tX3ByZXRyYWluZWQoJTIyZmFjZWJvb2slMkZkaW5vdjItYmFzZSUyMiklMEElMEFpbnB1dHMlMjAlM0QlMjBpbWFnZV9wcm9jZXNzb3IoaW1hZ2VzJTNEaW1hZ2UlMkMlMjByZXR1cm5fdGVuc29ycyUzRCUyMm5wJTIyKSUwQW91dHB1dHMlMjAlM0QlMjBtb2RlbCgqKmlucHV0cyklMEFsYXN0X2hpZGRlbl9zdGF0ZXMlMjAlM0QlMjBvdXRwdXRzLmxhc3RfaGlkZGVuX3N0YXRl",highlighted:`<span class="hljs-meta">&gt;&gt;&gt; </span><span class="hljs-keyword">from</span> transformers <span class="hljs-keyword">import</span> AutoImageProcessor, FlaxDinov2Model
<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;facebook/dinov2-base&quot;</span>)
<span class="hljs-meta">&gt;&gt;&gt; </span>model = FlaxDinov2Model.from_pretrained(<span class="hljs-string">&quot;facebook/dinov2-base&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(){t=h("p"),t.textContent=f,n=l(),_(a.$$.fragment)},l(o){t=u(o,"P",{"data-svelte-h":!0}),$(t)!=="svelte-kvfsh7"&&(t.textContent=f),n=i(o),b(a.$$.fragment,o)},m(o,C){d(o,t,C),d(o,n,C),v(a,o,C),g=!0},p:je,i(o){g||(y(a.$$.fragment,o),g=!0)},o(o){M(a.$$.fragment,o),g=!1},d(o){o&&(s(t),s(n)),w(a,o)}}}function Ke(I){let t,f=`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(){t=h("p"),t.innerHTML=f},l(n){t=u(n,"P",{"data-svelte-h":!0}),$(t)!=="svelte-fincs2"&&(t.innerHTML=f)},m(n,a){d(n,t,a)},p:je,d(n){n&&s(t)}}}function et(I){let t,f="Example:",n,a,g;return a=new Ue({props:{code:"ZnJvbSUyMHRyYW5zZm9ybWVycyUyMGltcG9ydCUyMEF1dG9JbWFnZVByb2Nlc3NvciUyQyUyMEZsYXhEaW5vdjJGb3JJbWFnZUNsYXNzaWZpY2F0aW9uJTBBZnJvbSUyMFBJTCUyMGltcG9ydCUyMEltYWdlJTBBaW1wb3J0JTIwamF4JTBBaW1wb3J0JTIwcmVxdWVzdHMlMEElMEF1cmwlMjAlM0QlMjAlMjJodHRwJTNBJTJGJTJGaW1hZ2VzLmNvY29kYXRhc2V0Lm9yZyUyRnZhbDIwMTclMkYwMDAwMDAwMzk3NjkuanBnJTIyJTBBaW1hZ2UlMjAlM0QlMjBJbWFnZS5vcGVuKHJlcXVlc3RzLmdldCh1cmwlMkMlMjBzdHJlYW0lM0RUcnVlKS5yYXcpJTBBJTBBaW1hZ2VfcHJvY2Vzc29yJTIwJTNEJTIwQXV0b0ltYWdlUHJvY2Vzc29yLmZyb21fcHJldHJhaW5lZCglMjJmYWNlYm9vayUyRmRpbm92Mi1iYXNlLWltYWdlbmV0MWstMS1sYXllciUyMiklMEFtb2RlbCUyMCUzRCUyMEZsYXhEaW5vdjJGb3JJbWFnZUNsYXNzaWZpY2F0aW9uLmZyb21fcHJldHJhaW5lZCglMjJmYWNlYm9vayUyRmRpbm92Mi1iYXNlLWltYWdlbmV0MWstMS1sYXllciUyMiklMEElMEFpbnB1dHMlMjAlM0QlMjBpbWFnZV9wcm9jZXNzb3IoaW1hZ2VzJTNEaW1hZ2UlMkMlMjByZXR1cm5fdGVuc29ycyUzRCUyMm5wJTIyKSUwQW91dHB1dHMlMjAlM0QlMjBtb2RlbCgqKmlucHV0cyklMEFsb2dpdHMlMjAlM0QlMjBvdXRwdXRzLmxvZ2l0cyUwQSUwQSUyMyUyMG1vZGVsJTIwcHJlZGljdHMlMjBvbmUlMjBvZiUyMHRoZSUyMDEwMDAlMjBJbWFnZU5ldCUyMGNsYXNzZXMlMEFwcmVkaWN0ZWRfY2xhc3NfaWR4JTIwJTNEJTIwamF4Lm51bXB5LmFyZ21heChsb2dpdHMlMkMlMjBheGlzJTNELTEpJTBBcHJpbnQoJTIyUHJlZGljdGVkJTIwY2xhc3MlM0ElMjIlMkMlMjBtb2RlbC5jb25maWcuaWQybGFiZWwlNUJwcmVkaWN0ZWRfY2xhc3NfaWR4Lml0ZW0oKSU1RCk=",highlighted:`<span class="hljs-meta">&gt;&gt;&gt; </span><span class="hljs-keyword">from</span> transformers <span class="hljs-keyword">import</span> AutoImageProcessor, FlaxDinov2ForImageClassification
<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;facebook/dinov2-base-imagenet1k-1-layer&quot;</span>)
<span class="hljs-meta">&gt;&gt;&gt; </span>model = FlaxDinov2ForImageClassification.from_pretrained(<span class="hljs-string">&quot;facebook/dinov2-base-imagenet1k-1-layer&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(){t=h("p"),t.textContent=f,n=l(),_(a.$$.fragment)},l(o){t=u(o,"P",{"data-svelte-h":!0}),$(t)!=="svelte-11lpom8"&&(t.textContent=f),n=i(o),b(a.$$.fragment,o)},m(o,C){d(o,t,C),d(o,n,C),v(a,o,C),g=!0},p:je,i(o){g||(y(a.$$.fragment,o),g=!0)},o(o){M(a.$$.fragment,o),g=!1},d(o){o&&(s(t),s(n)),w(a,o)}}}function tt(I){let t,f,n,a,g,o,C="The bare Dinov2 Model transformer outputting raw hidden-states without any specific head on top.",ie,F,oe=`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)`,de,N,xe=`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.`,ce,k,ye="Finally, this model supports inherent JAX features such as:",E,Y,ae='<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>',se,x,B,A,L,_e="The <code>FlaxDinov2PreTrainedModel</code> forward method, overrides the <code>__call__</code> special method.",O,R,K,X,U,H,re,J,le,me,W,pe=`Dinov2 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.`,V,ee,m=`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)`,j,z,G=`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.`,Z,te,q="Finally, this model supports inherent JAX features such as:",fe,be,Me='<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>',Ie,S,ne,Fe,ve,he="The <code>FlaxDinov2PreTrainedModel</code> forward method, overrides the <code>__call__</code> special method.",Je,P,Ce,Q,we;return t=new $e({props:{title:"FlaxDinov2Model",local:"transformers.FlaxDinov2Model",headingTag:"h2"}}),a=new Te({props:{name:"class transformers.FlaxDinov2Model",anchor:"transformers.FlaxDinov2Model",parameters:[{name:"config",val:": Dinov2Config"},{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.FlaxDinov2Model.config",description:`<strong>config</strong> (<a href="/docs/transformers/main/en/model_doc/dinov2#transformers.Dinov2Config">Dinov2Config</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.FlaxDinov2Model.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/dinov2/modeling_flax_dinov2.py#L667"}}),B=new Te({props:{name:"__call__",anchor:"transformers.FlaxDinov2Model.__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:": Optional = None"},{name:"output_hidden_states",val:": Optional = None"},{name:"return_dict",val:": Optional = None"}],source:"https://github.com/huggingface/transformers/blob/main/src/transformers/models/dinov2/modeling_flax_dinov2.py#L588",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.dinov2.configuration_dinov2.Dinov2Config'&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>
`}}),R=new Ze({props:{$$slots:{default:[Ae]},$$scope:{ctx:I}}}),X=new We({props:{anchor:"transformers.FlaxDinov2Model.__call__.example",$$slots:{default:[Oe]},$$scope:{ctx:I}}}),H=new $e({props:{title:"FlaxDinov2ForImageClassification",local:"transformers.FlaxDinov2ForImageClassification",headingTag:"h2"}}),le=new Te({props:{name:"class transformers.FlaxDinov2ForImageClassification",anchor:"transformers.FlaxDinov2ForImageClassification",parameters:[{name:"config",val:": Dinov2Config"},{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.FlaxDinov2ForImageClassification.config",description:`<strong>config</strong> (<a href="/docs/transformers/main/en/model_doc/dinov2#transformers.Dinov2Config">Dinov2Config</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.FlaxDinov2ForImageClassification.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/dinov2/modeling_flax_dinov2.py#L754"}}),ne=new Te({props:{name:"__call__",anchor:"transformers.FlaxDinov2ForImageClassification.__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:": Optional = None"},{name:"output_hidden_states",val:": Optional = None"},{name:"return_dict",val:": Optional = None"}],source:"https://github.com/huggingface/transformers/blob/main/src/transformers/models/dinov2/modeling_flax_dinov2.py#L588",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.dinov2.configuration_dinov2.Dinov2Config'&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>
`}}),P=new Ze({props:{$$slots:{default:[Ke]},$$scope:{ctx:I}}}),Q=new We({props:{anchor:"transformers.FlaxDinov2ForImageClassification.__call__.example",$$slots:{default:[et]},$$scope:{ctx:I}}}),{c(){_(t.$$.fragment),f=l(),n=h("div"),_(a.$$.fragment),g=l(),o=h("p"),o.textContent=C,ie=l(),F=h("p"),F.innerHTML=oe,de=l(),N=h("p"),N.innerHTML=xe,ce=l(),k=h("p"),k.textContent=ye,E=l(),Y=h("ul"),Y.innerHTML=ae,se=l(),x=h("div"),_(B.$$.fragment),A=l(),L=h("p"),L.innerHTML=_e,O=l(),_(R.$$.fragment),K=l(),_(X.$$.fragment),U=l(),_(H.$$.fragment),re=l(),J=h("div"),_(le.$$.fragment),me=l(),W=h("p"),W.textContent=pe,V=l(),ee=h("p"),ee.innerHTML=m,j=l(),z=h("p"),z.innerHTML=G,Z=l(),te=h("p"),te.textContent=q,fe=l(),be=h("ul"),be.innerHTML=Me,Ie=l(),S=h("div"),_(ne.$$.fragment),Fe=l(),ve=h("p"),ve.innerHTML=he,Je=l(),_(P.$$.fragment),Ce=l(),_(Q.$$.fragment),this.h()},l(p){b(t.$$.fragment,p),f=i(p),n=u(p,"DIV",{class:!0});var T=ue(n);b(a.$$.fragment,T),g=i(T),o=u(T,"P",{"data-svelte-h":!0}),$(o)!=="svelte-11pdceb"&&(o.textContent=C),ie=i(T),F=u(T,"P",{"data-svelte-h":!0}),$(F)!=="svelte-3daxed"&&(F.innerHTML=oe),de=i(T),N=u(T,"P",{"data-svelte-h":!0}),$(N)!=="svelte-10nfsf3"&&(N.innerHTML=xe),ce=i(T),k=u(T,"P",{"data-svelte-h":!0}),$(k)!=="svelte-1pplc4a"&&(k.textContent=ye),E=i(T),Y=u(T,"UL",{"data-svelte-h":!0}),$(Y)!=="svelte-1w7z84m"&&(Y.innerHTML=ae),se=i(T),x=u(T,"DIV",{class:!0});var e=ue(x);b(B.$$.fragment,e),A=i(e),L=u(e,"P",{"data-svelte-h":!0}),$(L)!=="svelte-13irhfr"&&(L.innerHTML=_e),O=i(e),b(R.$$.fragment,e),K=i(e),b(X.$$.fragment,e),e.forEach(s),T.forEach(s),U=i(p),b(H.$$.fragment,p),re=i(p),J=u(p,"DIV",{class:!0});var r=ue(J);b(le.$$.fragment,r),me=i(r),W=u(r,"P",{"data-svelte-h":!0}),$(W)!=="svelte-kzwbbb"&&(W.textContent=pe),V=i(r),ee=u(r,"P",{"data-svelte-h":!0}),$(ee)!=="svelte-3daxed"&&(ee.innerHTML=m),j=i(r),z=u(r,"P",{"data-svelte-h":!0}),$(z)!=="svelte-10nfsf3"&&(z.innerHTML=G),Z=i(r),te=u(r,"P",{"data-svelte-h":!0}),$(te)!=="svelte-1pplc4a"&&(te.textContent=q),fe=i(r),be=u(r,"UL",{"data-svelte-h":!0}),$(be)!=="svelte-1w7z84m"&&(be.innerHTML=Me),Ie=i(r),S=u(r,"DIV",{class:!0});var D=ue(S);b(ne.$$.fragment,D),Fe=i(D),ve=u(D,"P",{"data-svelte-h":!0}),$(ve)!=="svelte-13irhfr"&&(ve.innerHTML=he),Je=i(D),b(P.$$.fragment,D),Ce=i(D),b(Q.$$.fragment,D),D.forEach(s),r.forEach(s),this.h()},h(){ge(x,"class","docstring border-l-2 border-t-2 pl-4 pt-3.5 border-gray-100 rounded-tl-xl mb-6 mt-8"),ge(n,"class","docstring border-l-2 border-t-2 pl-4 pt-3.5 border-gray-100 rounded-tl-xl mb-6 mt-8"),ge(S,"class","docstring border-l-2 border-t-2 pl-4 pt-3.5 border-gray-100 rounded-tl-xl mb-6 mt-8"),ge(J,"class","docstring border-l-2 border-t-2 pl-4 pt-3.5 border-gray-100 rounded-tl-xl mb-6 mt-8")},m(p,T){v(t,p,T),d(p,f,T),d(p,n,T),v(a,n,null),c(n,g),c(n,o),c(n,ie),c(n,F),c(n,de),c(n,N),c(n,ce),c(n,k),c(n,E),c(n,Y),c(n,se),c(n,x),v(B,x,null),c(x,A),c(x,L),c(x,O),v(R,x,null),c(x,K),v(X,x,null),d(p,U,T),v(H,p,T),d(p,re,T),d(p,J,T),v(le,J,null),c(J,me),c(J,W),c(J,V),c(J,ee),c(J,j),c(J,z),c(J,Z),c(J,te),c(J,fe),c(J,be),c(J,Ie),c(J,S),v(ne,S,null),c(S,Fe),c(S,ve),c(S,Je),v(P,S,null),c(S,Ce),v(Q,S,null),we=!0},p(p,T){const e={};T&2&&(e.$$scope={dirty:T,ctx:p}),R.$set(e);const r={};T&2&&(r.$$scope={dirty:T,ctx:p}),X.$set(r);const D={};T&2&&(D.$$scope={dirty:T,ctx:p}),P.$set(D);const ke={};T&2&&(ke.$$scope={dirty:T,ctx:p}),Q.$set(ke)},i(p){we||(y(t.$$.fragment,p),y(a.$$.fragment,p),y(B.$$.fragment,p),y(R.$$.fragment,p),y(X.$$.fragment,p),y(H.$$.fragment,p),y(le.$$.fragment,p),y(ne.$$.fragment,p),y(P.$$.fragment,p),y(Q.$$.fragment,p),we=!0)},o(p){M(t.$$.fragment,p),M(a.$$.fragment,p),M(B.$$.fragment,p),M(R.$$.fragment,p),M(X.$$.fragment,p),M(H.$$.fragment,p),M(le.$$.fragment,p),M(ne.$$.fragment,p),M(P.$$.fragment,p),M(Q.$$.fragment,p),we=!1},d(p){p&&(s(f),s(n),s(U),s(re),s(J)),w(t,p),w(a),w(B),w(R),w(X),w(H,p),w(le),w(ne),w(P),w(Q)}}}function nt(I){let t,f;return t=new De({props:{$$slots:{default:[tt]},$$scope:{ctx:I}}}),{c(){_(t.$$.fragment)},l(n){b(t.$$.fragment,n)},m(n,a){v(t,n,a),f=!0},p(n,a){const g={};a&2&&(g.$$scope={dirty:a,ctx:n}),t.$set(g)},i(n){f||(y(t.$$.fragment,n),f=!0)},o(n){M(t.$$.fragment,n),f=!1},d(n){w(t,n)}}}function ot(I){let t,f,n,a,g,o,C,ie,F,oe=`The DINOv2 model was proposed in <a href="https://arxiv.org/abs/2304.07193" rel="nofollow">DINOv2: Learning Robust Visual Features without Supervision</a> by
Maxime Oquab, Timothée Darcet, Théo Moutakanni, Huy Vo, Marc Szafraniec, Vasil Khalidov, Pierre Fernandez, Daniel Haziza, Francisco Massa, Alaaeldin El-Nouby, Mahmoud Assran, Nicolas Ballas, Wojciech Galuba, Russell Howes, Po-Yao Huang, Shang-Wen Li, Ishan Misra, Michael Rabbat, Vasu Sharma, Gabriel Synnaeve, Hu Xu, Hervé Jegou, Julien Mairal, Patrick Labatut, Armand Joulin, Piotr Bojanowski.
DINOv2 is an upgrade of <a href="https://arxiv.org/abs/2104.14294" rel="nofollow">DINO</a>, a self-supervised method applied on <a href="vit">Vision Transformers</a>. This method enables all-purpose visual features, i.e., features that work across image distributions and tasks without finetuning.`,de,N,xe="The abstract from the paper is the following:",ce,k,ye="<em>The recent breakthroughs in natural language processing for model pretraining on large quantities of data have opened the way for similar foundation models in computer vision. These models could greatly simplify the use of images in any system by producing all-purpose visual features, i.e., features that work across image distributions and tasks without finetuning. This work shows that existing pretraining methods, especially self-supervised methods, can produce such features if trained on enough curated data from diverse sources. We revisit existing approaches and combine different techniques to scale our pretraining in terms of data and model size. Most of the technical contributions aim at accelerating and stabilizing the training at scale. In terms of data, we propose an automatic pipeline to build a dedicated, diverse, and curated image dataset instead of uncurated data, as typically done in the self-supervised literature. In terms of models, we train a ViT model (Dosovitskiy et al., 2020) with 1B parameters and distill it into a series of smaller models that surpass the best available all-purpose features, OpenCLIP (Ilharco et al., 2021) on most of the benchmarks at image and pixel levels.</em>",E,Y,ae=`This model was contributed by <a href="https://huggingface.co/nielsr" rel="nofollow">nielsr</a>.
The original code can be found <a href="https://github.com/facebookresearch/dinov2" rel="nofollow">here</a>.`,se,x,B,A,L="The model can be traced using <code>torch.jit.trace</code> which leverages JIT compilation to optimize the model making it faster to run. Note this still produces some mis-matched elements and the difference between the original model and the traced model is of the order of 1e-4.",_e,O,R,K,X,U,H="A list of official Hugging Face and community (indicated by 🌎) resources to help you get started with DINOv2.",re,J,le='<li>Demo notebooks for DINOv2 can be found <a href="https://github.com/NielsRogge/Transformers-Tutorials/tree/master/DINOv2" rel="nofollow">here</a>. 🌎</li>',me,W,pe,V,ee='<li><a href="/docs/transformers/main/en/model_doc/dinov2#transformers.Dinov2ForImageClassification">Dinov2ForImageClassification</a> is supported by this <a href="https://github.com/huggingface/transformers/tree/main/examples/pytorch/image-classification" rel="nofollow">example script</a> and <a href="https://colab.research.google.com/github/huggingface/notebooks/blob/main/examples/image_classification.ipynb" rel="nofollow">notebook</a>.</li> <li>See also: <a href="../tasks/image_classification">Image classification task guide</a></li>',m,j,z="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.",G,Z,te,q,fe,be,Me,Ie=`This is the configuration class to store the configuration of a <a href="/docs/transformers/main/en/model_doc/dinov2#transformers.Dinov2Model">Dinov2Model</a>. It is used to instantiate an
Dinov2 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 Dinov2
<a href="https://huggingface.co/google/dinov2-base-patch16-224" rel="nofollow">google/dinov2-base-patch16-224</a> architecture.`,S,ne,Fe=`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.`,ve,he,Je,P,Ce,Q,we,p,T;return g=new $e({props:{title:"DINOv2",local:"dinov2",headingTag:"h1"}}),C=new $e({props:{title:"Overview",local:"overview",headingTag:"h2"}}),x=new $e({props:{title:"Usage tips",local:"usage-tips",headingTag:"h2"}}),O=new Ue({props:{code:"aW1wb3J0JTIwdG9yY2glMEFmcm9tJTIwdHJhbnNmb3JtZXJzJTIwaW1wb3J0JTIwQXV0b0ltYWdlUHJvY2Vzc29yJTJDJTIwQXV0b01vZGVsJTBBZnJvbSUyMFBJTCUyMGltcG9ydCUyMEltYWdlJTBBaW1wb3J0JTIwcmVxdWVzdHMlMEElMEF1cmwlMjAlM0QlMjAnaHR0cCUzQSUyRiUyRmltYWdlcy5jb2NvZGF0YXNldC5vcmclMkZ2YWwyMDE3JTJGMDAwMDAwMDM5NzY5LmpwZyclMEFpbWFnZSUyMCUzRCUyMEltYWdlLm9wZW4ocmVxdWVzdHMuZ2V0KHVybCUyQyUyMHN0cmVhbSUzRFRydWUpLnJhdyklMEElMEFwcm9jZXNzb3IlMjAlM0QlMjBBdXRvSW1hZ2VQcm9jZXNzb3IuZnJvbV9wcmV0cmFpbmVkKCdmYWNlYm9vayUyRmRpbm92Mi1iYXNlJyklMEFtb2RlbCUyMCUzRCUyMEF1dG9Nb2RlbC5mcm9tX3ByZXRyYWluZWQoJ2ZhY2Vib29rJTJGZGlub3YyLWJhc2UnKSUwQSUwQWlucHV0cyUyMCUzRCUyMHByb2Nlc3NvcihpbWFnZXMlM0RpbWFnZSUyQyUyMHJldHVybl90ZW5zb3JzJTNEJTIycHQlMjIpJTBBb3V0cHV0cyUyMCUzRCUyMG1vZGVsKCoqaW5wdXRzKSUwQWxhc3RfaGlkZGVuX3N0YXRlcyUyMCUzRCUyMG91dHB1dHMlNUIwJTVEJTBBJTBBJTIzJTIwV2UlMjBoYXZlJTIwdG8lMjBmb3JjZSUyMHJldHVybl9kaWN0JTNERmFsc2UlMjBmb3IlMjB0cmFjaW5nJTBBbW9kZWwuY29uZmlnLnJldHVybl9kaWN0JTIwJTNEJTIwRmFsc2UlMEElMEF3aXRoJTIwdG9yY2gubm9fZ3JhZCgpJTNBJTBBJTIwJTIwJTIwJTIwdHJhY2VkX21vZGVsJTIwJTNEJTIwdG9yY2guaml0LnRyYWNlKG1vZGVsJTJDJTIwJTVCaW5wdXRzLnBpeGVsX3ZhbHVlcyU1RCklMEElMjAlMjAlMjAlMjB0cmFjZWRfb3V0cHV0cyUyMCUzRCUyMHRyYWNlZF9tb2RlbChpbnB1dHMucGl4ZWxfdmFsdWVzKSUwQSUwQXByaW50KChsYXN0X2hpZGRlbl9zdGF0ZXMlMjAtJTIwdHJhY2VkX291dHB1dHMlNUIwJTVEKS5hYnMoKS5tYXgoKSk=",highlighted:`<span class="hljs-keyword">import</span> torch
<span class="hljs-keyword">from</span> transformers <span class="hljs-keyword">import</span> AutoImageProcessor, AutoModel
<span class="hljs-keyword">from</span> PIL <span class="hljs-keyword">import</span> Image
<span class="hljs-keyword">import</span> requests

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

processor = AutoImageProcessor.from_pretrained(<span class="hljs-string">&#x27;facebook/dinov2-base&#x27;</span>)
model = AutoModel.from_pretrained(<span class="hljs-string">&#x27;facebook/dinov2-base&#x27;</span>)

inputs = processor(images=image, return_tensors=<span class="hljs-string">&quot;pt&quot;</span>)
outputs = model(**inputs)
last_hidden_states = outputs[<span class="hljs-number">0</span>]

<span class="hljs-comment"># We have to force return_dict=False for tracing</span>
model.config.return_dict = <span class="hljs-literal">False</span>

<span class="hljs-keyword">with</span> torch.no_grad():
    traced_model = torch.jit.trace(model, [inputs.pixel_values])
    traced_outputs = traced_model(inputs.pixel_values)

<span class="hljs-built_in">print</span>((last_hidden_states - traced_outputs[<span class="hljs-number">0</span>]).<span class="hljs-built_in">abs</span>().<span class="hljs-built_in">max</span>())`,wrap:!1}}),K=new $e({props:{title:"Resources",local:"resources",headingTag:"h2"}}),W=new Ge({props:{pipeline:"image-classification"}}),Z=new $e({props:{title:"Dinov2Config",local:"transformers.Dinov2Config",headingTag:"h2"}}),fe=new Te({props:{name:"class transformers.Dinov2Config",anchor:"transformers.Dinov2Config",parameters:[{name:"hidden_size",val:" = 768"},{name:"num_hidden_layers",val:" = 12"},{name:"num_attention_heads",val:" = 12"},{name:"mlp_ratio",val:" = 4"},{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-06"},{name:"image_size",val:" = 224"},{name:"patch_size",val:" = 16"},{name:"num_channels",val:" = 3"},{name:"qkv_bias",val:" = True"},{name:"layerscale_value",val:" = 1.0"},{name:"drop_path_rate",val:" = 0.0"},{name:"use_swiglu_ffn",val:" = False"},{name:"out_features",val:" = None"},{name:"out_indices",val:" = None"},{name:"apply_layernorm",val:" = True"},{name:"reshape_hidden_states",val:" = True"},{name:"**kwargs",val:""}],parametersDescription:[{anchor:"transformers.Dinov2Config.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.Dinov2Config.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.Dinov2Config.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.Dinov2Config.mlp_ratio",description:`<strong>mlp_ratio</strong> (<code>int</code>, <em>optional</em>, defaults to 4) &#x2014;
Ratio of the hidden size of the MLPs relative to the <code>hidden_size</code>.`,name:"mlp_ratio"},{anchor:"transformers.Dinov2Config.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.Dinov2Config.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.Dinov2Config.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.Dinov2Config.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.Dinov2Config.layer_norm_eps",description:`<strong>layer_norm_eps</strong> (<code>float</code>, <em>optional</em>, defaults to 1e-06) &#x2014;
The epsilon used by the layer normalization layers.`,name:"layer_norm_eps"},{anchor:"transformers.Dinov2Config.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.Dinov2Config.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.Dinov2Config.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.Dinov2Config.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.Dinov2Config.layerscale_value",description:`<strong>layerscale_value</strong> (<code>float</code>, <em>optional</em>, defaults to 1.0) &#x2014;
Initial value to use for layer scale.`,name:"layerscale_value"},{anchor:"transformers.Dinov2Config.drop_path_rate",description:`<strong>drop_path_rate</strong> (<code>float</code>, <em>optional</em>, defaults to 0.0) &#x2014;
Stochastic depth rate per sample (when applied in the main path of residual layers).`,name:"drop_path_rate"},{anchor:"transformers.Dinov2Config.use_swiglu_ffn",description:`<strong>use_swiglu_ffn</strong> (<code>bool</code>, <em>optional</em>, defaults to <code>False</code>) &#x2014;
Whether to use the SwiGLU feedforward neural network.`,name:"use_swiglu_ffn"},{anchor:"transformers.Dinov2Config.out_features",description:`<strong>out_features</strong> (<code>List[str]</code>, <em>optional</em>) &#x2014;
If used as backbone, list of features to output. Can be any of <code>&quot;stem&quot;</code>, <code>&quot;stage1&quot;</code>, <code>&quot;stage2&quot;</code>, etc.
(depending on how many stages the model has). If unset and <code>out_indices</code> is set, will default to the
corresponding stages. If unset and <code>out_indices</code> is unset, will default to the last stage. Must be in the
same order as defined in the <code>stage_names</code> attribute.`,name:"out_features"},{anchor:"transformers.Dinov2Config.out_indices",description:`<strong>out_indices</strong> (<code>List[int]</code>, <em>optional</em>) &#x2014;
If used as backbone, list of indices of features to output. Can be any of 0, 1, 2, etc. (depending on how
many stages the model has). If unset and <code>out_features</code> is set, will default to the corresponding stages.
If unset and <code>out_features</code> is unset, will default to the last stage. Must be in the
same order as defined in the <code>stage_names</code> attribute.`,name:"out_indices"},{anchor:"transformers.Dinov2Config.apply_layernorm",description:`<strong>apply_layernorm</strong> (<code>bool</code>, <em>optional</em>, defaults to <code>True</code>) &#x2014;
Whether to apply layer normalization to the feature maps in case the model is used as backbone.`,name:"apply_layernorm"},{anchor:"transformers.Dinov2Config.reshape_hidden_states",description:`<strong>reshape_hidden_states</strong> (<code>bool</code>, <em>optional</em>, defaults to <code>True</code>) &#x2014;
Whether to reshape the feature maps to 4D tensors of shape <code>(batch_size, hidden_size, height, width)</code> in
case the model is used as backbone. If <code>False</code>, the feature maps will be 3D tensors of shape <code>(batch_size, seq_len, hidden_size)</code>.`,name:"reshape_hidden_states"}],source:"https://github.com/huggingface/transformers/blob/main/src/transformers/models/dinov2/configuration_dinov2.py#L31"}}),he=new We({props:{anchor:"transformers.Dinov2Config.example",$$slots:{default:[Ee]},$$scope:{ctx:I}}}),P=new Ye({props:{pytorch:!0,tensorflow:!1,jax:!0,$$slots:{jax:[nt],pytorch:[Qe]},$$scope:{ctx:I}}}),Q=new He({props:{source:"https://github.com/huggingface/transformers/blob/main/docs/source/en/model_doc/dinov2.md"}}),{c(){t=h("meta"),f=l(),n=h("p"),a=l(),_(g.$$.fragment),o=l(),_(C.$$.fragment),ie=l(),F=h("p"),F.innerHTML=oe,de=l(),N=h("p"),N.textContent=xe,ce=l(),k=h("p"),k.innerHTML=ye,E=l(),Y=h("p"),Y.innerHTML=ae,se=l(),_(x.$$.fragment),B=l(),A=h("p"),A.innerHTML=L,_e=l(),_(O.$$.fragment),R=l(),_(K.$$.fragment),X=l(),U=h("p"),U.textContent=H,re=l(),J=h("ul"),J.innerHTML=le,me=l(),_(W.$$.fragment),pe=l(),V=h("ul"),V.innerHTML=ee,m=l(),j=h("p"),j.textContent=z,G=l(),_(Z.$$.fragment),te=l(),q=h("div"),_(fe.$$.fragment),be=l(),Me=h("p"),Me.innerHTML=Ie,S=l(),ne=h("p"),ne.innerHTML=Fe,ve=l(),_(he.$$.fragment),Je=l(),_(P.$$.fragment),Ce=l(),_(Q.$$.fragment),we=l(),p=h("p"),this.h()},l(e){const r=Ve("svelte-u9bgzb",document.head);t=u(r,"META",{name:!0,content:!0}),r.forEach(s),f=i(e),n=u(e,"P",{}),ue(n).forEach(s),a=i(e),b(g.$$.fragment,e),o=i(e),b(C.$$.fragment,e),ie=i(e),F=u(e,"P",{"data-svelte-h":!0}),$(F)!=="svelte-189nb70"&&(F.innerHTML=oe),de=i(e),N=u(e,"P",{"data-svelte-h":!0}),$(N)!=="svelte-vfdo9a"&&(N.textContent=xe),ce=i(e),k=u(e,"P",{"data-svelte-h":!0}),$(k)!=="svelte-1p4dq7"&&(k.innerHTML=ye),E=i(e),Y=u(e,"P",{"data-svelte-h":!0}),$(Y)!=="svelte-1exxkia"&&(Y.innerHTML=ae),se=i(e),b(x.$$.fragment,e),B=i(e),A=u(e,"P",{"data-svelte-h":!0}),$(A)!=="svelte-1bw89ap"&&(A.innerHTML=L),_e=i(e),b(O.$$.fragment,e),R=i(e),b(K.$$.fragment,e),X=i(e),U=u(e,"P",{"data-svelte-h":!0}),$(U)!=="svelte-1oq63gf"&&(U.textContent=H),re=i(e),J=u(e,"UL",{"data-svelte-h":!0}),$(J)!=="svelte-1vxq6gu"&&(J.innerHTML=le),me=i(e),b(W.$$.fragment,e),pe=i(e),V=u(e,"UL",{"data-svelte-h":!0}),$(V)!=="svelte-1fr57ih"&&(V.innerHTML=ee),m=i(e),j=u(e,"P",{"data-svelte-h":!0}),$(j)!=="svelte-1xesile"&&(j.textContent=z),G=i(e),b(Z.$$.fragment,e),te=i(e),q=u(e,"DIV",{class:!0});var D=ue(q);b(fe.$$.fragment,D),be=i(D),Me=u(D,"P",{"data-svelte-h":!0}),$(Me)!=="svelte-x3ratf"&&(Me.innerHTML=Ie),S=i(D),ne=u(D,"P",{"data-svelte-h":!0}),$(ne)!=="svelte-o55m63"&&(ne.innerHTML=Fe),ve=i(D),b(he.$$.fragment,D),D.forEach(s),Je=i(e),b(P.$$.fragment,e),Ce=i(e),b(Q.$$.fragment,e),we=i(e),p=u(e,"P",{}),ue(p).forEach(s),this.h()},h(){ge(t,"name","hf:doc:metadata"),ge(t,"content",at),ge(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(e,r){c(document.head,t),d(e,f,r),d(e,n,r),d(e,a,r),v(g,e,r),d(e,o,r),v(C,e,r),d(e,ie,r),d(e,F,r),d(e,de,r),d(e,N,r),d(e,ce,r),d(e,k,r),d(e,E,r),d(e,Y,r),d(e,se,r),v(x,e,r),d(e,B,r),d(e,A,r),d(e,_e,r),v(O,e,r),d(e,R,r),v(K,e,r),d(e,X,r),d(e,U,r),d(e,re,r),d(e,J,r),d(e,me,r),v(W,e,r),d(e,pe,r),d(e,V,r),d(e,m,r),d(e,j,r),d(e,G,r),v(Z,e,r),d(e,te,r),d(e,q,r),v(fe,q,null),c(q,be),c(q,Me),c(q,S),c(q,ne),c(q,ve),v(he,q,null),d(e,Je,r),v(P,e,r),d(e,Ce,r),v(Q,e,r),d(e,we,r),d(e,p,r),T=!0},p(e,[r]){const D={};r&2&&(D.$$scope={dirty:r,ctx:e}),he.$set(D);const ke={};r&2&&(ke.$$scope={dirty:r,ctx:e}),P.$set(ke)},i(e){T||(y(g.$$.fragment,e),y(C.$$.fragment,e),y(x.$$.fragment,e),y(O.$$.fragment,e),y(K.$$.fragment,e),y(W.$$.fragment,e),y(Z.$$.fragment,e),y(fe.$$.fragment,e),y(he.$$.fragment,e),y(P.$$.fragment,e),y(Q.$$.fragment,e),T=!0)},o(e){M(g.$$.fragment,e),M(C.$$.fragment,e),M(x.$$.fragment,e),M(O.$$.fragment,e),M(K.$$.fragment,e),M(W.$$.fragment,e),M(Z.$$.fragment,e),M(fe.$$.fragment,e),M(he.$$.fragment,e),M(P.$$.fragment,e),M(Q.$$.fragment,e),T=!1},d(e){e&&(s(f),s(n),s(a),s(o),s(ie),s(F),s(de),s(N),s(ce),s(k),s(E),s(Y),s(se),s(B),s(A),s(_e),s(R),s(X),s(U),s(re),s(J),s(me),s(pe),s(V),s(m),s(j),s(G),s(te),s(q),s(Je),s(Ce),s(we),s(p)),s(t),w(g,e),w(C,e),w(x,e),w(O,e),w(K,e),w(W,e),w(Z,e),w(fe),w(he),w(P,e),w(Q,e)}}}const at='{"title":"DINOv2","local":"dinov2","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":"Dinov2Config","local":"transformers.Dinov2Config","sections":[],"depth":2},{"title":"Dinov2Model","local":"transformers.Dinov2Model","sections":[],"depth":2},{"title":"Dinov2ForImageClassification","local":"transformers.Dinov2ForImageClassification","sections":[],"depth":2},{"title":"FlaxDinov2Model","local":"transformers.FlaxDinov2Model","sections":[],"depth":2},{"title":"FlaxDinov2ForImageClassification","local":"transformers.FlaxDinov2ForImageClassification","sections":[],"depth":2}],"depth":1}';function st(I){return ze(()=>{new URLSearchParams(window.location.search).get("fw")}),[]}class ut extends Be{constructor(t){super(),Re(this,t,st,ot,Ne,{})}}export{ut as component};
