Buckets:
| import"../chunks/DsnmJJEf.js";import{i as be,h as Te,C as ye,H as l,b as Me,a as c,D as a,E as Ne,s as Ie}from"../chunks/B_l3KsN0.js";import{p as we,o as Ce,s as e,f as m,a as i,b as Je,c as t,d as p,r as s,n as h}from"../chunks/DdiSzEty.js";import{T as g}from"../chunks/XXUkly4Z.js";import{E as u}from"../chunks/9S4mkmb-.js";import{H as ae}from"../chunks/CWpPqiD6.js";const ke='{"title":"DINOv3","local":"dinov3","sections":[{"title":"Notes","local":"notes","sections":[],"depth":2},{"title":"DINOv3ViTConfig","local":"transformers.DINOv3ViTConfig","sections":[],"depth":2},{"title":"DINOv3ConvNextConfig","local":"transformers.DINOv3ConvNextConfig","sections":[],"depth":2},{"title":"DINOv3ViTModel","local":"transformers.DINOv3ViTModel","sections":[],"depth":2},{"title":"DINOv3ViTBackbone","local":"transformers.DINOv3ViTBackbone","sections":[],"depth":2},{"title":"DINOv3ConvNextModel","local":"transformers.DINOv3ConvNextModel","sections":[],"depth":2},{"title":"DINOv3ViTImageProcessor","local":"transformers.DINOv3ViTImageProcessor","sections":[],"depth":2},{"title":"DINOv3ConvNextBackbone","local":"transformers.DINOv3ConvNextBackbone","sections":[],"depth":2}],"depth":1}';var De=p('<meta name="hf:doc:metadata"/>'),ze=p("<!> <!>",1),f=p("<p>Example:</p> <!>",1),_=p(`<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.</p>`),Ve=p(`<p></p> <p><em>This model was published in HF papers on 2025-08-13 and contributed to Hugging Face Transformers on 2025-08-14.</em></p> <!> <div style="float: right;"><div class="flex flex-wrap space-x-1"><img alt="FlashAttention" src="https://img.shields.io/badge/%E2%9A%A1%EF%B8%8E%20FlashAttention-eae0c8?style=flat"/> <img alt="SDPA" src="https://img.shields.io/badge/SDPA-DE3412?style=flat&logo=pytorch&logoColor=white"/></div></div> <!> <p><a href="https://huggingface.co/papers/2508.10104" rel="nofollow">DINOv3</a> is a family of versatile vision foundation models that outperforms the specialized state of the art across a broad range of settings, without fine-tuning. DINOv3 produces high-quality dense features that achieve outstanding performance on various vision tasks, significantly surpassing previous self- and weakly-supervised foundation models.</p> <p>You can find all the original DINOv3 checkpoints under the <a href="https://huggingface.co/collections/facebook/dinov3-68924841bd6b561778e31009" rel="nofollow">DINOv3</a> collection.</p> <blockquote class="tip"><p>Click on the DINOv3 models in the right sidebar for more examples of how to apply DINOv3 to different vision tasks.</p></blockquote> <p>The example below demonstrates how to obtain an image embedding with <a href="/docs/transformers/pr_49141/en/main_classes/pipelines#transformers.Pipeline">Pipeline</a> or the <a href="/docs/transformers/pr_49141/en/model_doc/auto#transformers.AutoModel">AutoModel</a> class.</p> <!> <p>Quantization reduces the memory burden of large models by representing the weights in a lower precision. Refer to the <a href="../quantization/overview">Quantization</a> overview for more available quantization backends.</p> <p>The example below uses <a href="../quantization/torchao">torchao</a> to only quantize the weights to int4.</p> <!> <!> <ul><li><p>The example below shows how to split the output tensor into:</p> <ul><li>one embedding for the whole image, commonly referred to as a <code>CLS</code> token, | |
| useful for classification and retrieval</li> <li>register tokens - learnable embeddings that act as dedicated “memory slots” for global information, | |
| they reduce high-norm artifacts in patch tokens, yielding cleaner attention maps and better | |
| performance on dense prediction tasks.</li> <li>a set of local embeddings, one for each <code>16x16</code> patch of the input image, | |
| useful for dense tasks, such as semantic segmentation</li></ul> <!></li></ul> <!> <div class="docstring border-l-2 border-t-2 pl-4 pt-3.5 border-gray-100 rounded-tl-xl mb-6 mt-8"><!> <p>This is the configuration class to store the configuration of a DINOv3ViTModel. It is used to instantiate a Dinov3 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 <a href="https://huggingface.co/facebook/dinov3-vits16-pretrain-lvd1689m" rel="nofollow">facebook/dinov3-vits16-pretrain-lvd1689m</a></p> <p>Configuration objects inherit from <a href="/docs/transformers/pr_49141/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/pr_49141/en/main_classes/configuration#transformers.PreTrainedConfig">PreTrainedConfig</a> for more information.</p> <!></div> <!> <div class="docstring border-l-2 border-t-2 pl-4 pt-3.5 border-gray-100 rounded-tl-xl mb-6 mt-8"><!> <p>This is the configuration class to store the configuration of a DINOv3ConvNextModel. It is used to instantiate a Dinov3 Convnext | |
| 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 <a href="https://huggingface.co/facebook/dinov3-convnext-tiny-pretrain-lvd1689m" rel="nofollow">facebook/dinov3-convnext-tiny-pretrain-lvd1689m</a></p> <p>Configuration objects inherit from <a href="/docs/transformers/pr_49141/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/pr_49141/en/main_classes/configuration#transformers.PreTrainedConfig">PreTrainedConfig</a> for more information.</p> <!></div> <!> <div class="docstring border-l-2 border-t-2 pl-4 pt-3.5 border-gray-100 rounded-tl-xl mb-6 mt-8"><!> <p>The bare Dinov3 Vit Model outputting raw hidden-states without any specific head on top.</p> <p>This model inherits from <a href="/docs/transformers/pr_49141/en/main_classes/model#transformers.PreTrainedModel">PreTrainedModel</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.)</p> <p>This model is also 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.</p> <div class="docstring border-l-2 border-t-2 pl-4 pt-3.5 border-gray-100 rounded-tl-xl mb-6 mt-8"><!> <p>The <a href="/docs/transformers/pr_49141/en/model_doc/dinov3#transformers.DINOv3ViTModel">DINOv3ViTModel</a> forward method, overrides the <code>__call__</code> special method.</p> <!> <ul><li><p><strong>last_hidden_state</strong> (<code>torch.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>torch.Tensor</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.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>torch.Tensor</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.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>torch.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> <!></div></div> <!> <div class="docstring border-l-2 border-t-2 pl-4 pt-3.5 border-gray-100 rounded-tl-xl mb-6 mt-8"><!> <p>The Dinov3 Vit backbone.</p> <p>This model inherits from <a href="/docs/transformers/pr_49141/en/main_classes/model#transformers.PreTrainedModel">PreTrainedModel</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.)</p> <p>This model is also 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.</p> <div class="docstring border-l-2 border-t-2 pl-4 pt-3.5 border-gray-100 rounded-tl-xl mb-6 mt-8"><!> <p>The <a href="/docs/transformers/pr_49141/en/model_doc/dinov3#transformers.DINOv3ViTBackbone">DINOv3ViTBackbone</a> forward method, overrides the <code>__call__</code> special method.</p> <!> <ul><li><p><strong>feature_maps</strong> (<code>tuple(torch.Tensor)</code> of shape <code>(batch_size, num_channels, height, width)</code>) — Feature maps of the stages.</p></li> <li><p><strong>hidden_states</strong> (<code>tuple(torch.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>torch.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> or <code>(batch_size, num_channels, height, width)</code>, | |
| depending on the backbone.</p> <p>Hidden-states of the model at the output of each stage plus the initial embedding outputs.</p></li> <li><p><strong>attentions</strong> (<code>tuple(torch.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>torch.Tensor</code> (one for each layer) of shape <code>(batch_size, num_heads, sequence_length, sequence_length)</code>. Only applicable if the backbone uses attention.</p> <p>Attentions weights after the attention softmax, used to compute the weighted average in the self-attention | |
| heads.</p></li> <li><p><strong>cls_tokens</strong> (<code>tuple(torch.Tensor)</code>, <em>optional</em>) — CLS token from each selected feature stage, each of shape <code>(batch_size, hidden_size)</code>. | |
| Only present when <code>config.return_class_token=True</code>.</p></li></ul></div></div> <!> <div class="docstring border-l-2 border-t-2 pl-4 pt-3.5 border-gray-100 rounded-tl-xl mb-6 mt-8"><!> <p>The bare Dinov3 Convnext Model outputting raw hidden-states without any specific head on top.</p> <p>This model inherits from <a href="/docs/transformers/pr_49141/en/main_classes/model#transformers.PreTrainedModel">PreTrainedModel</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.)</p> <p>This model is also 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.</p> <div class="docstring border-l-2 border-t-2 pl-4 pt-3.5 border-gray-100 rounded-tl-xl mb-6 mt-8"><!> <p>The <a href="/docs/transformers/pr_49141/en/model_doc/dinov3#transformers.DINOv3ConvNextModel">DINOv3ConvNextModel</a> forward method, overrides the <code>__call__</code> special method.</p> <!> <ul><li><p><strong>last_hidden_state</strong> (<code>torch.Tensor</code> of shape <code>(batch_size, num_channels, height, width)</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.Tensor</code> of shape <code>(batch_size, hidden_size)</code>) — Last layer hidden-state after a pooling operation on the spatial dimensions.</p></li> <li><p><strong>hidden_states</strong> (<code>tuple(torch.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>torch.Tensor</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, num_channels, height, width)</code>.</p> <p>Hidden-states of the model at the output of each layer plus the optional initial embedding outputs.</p></li></ul> <!></div></div> <!> <div class="docstring border-l-2 border-t-2 pl-4 pt-3.5 border-gray-100 rounded-tl-xl mb-6 mt-8"><!> <p>Constructs a DINOv3ViTImageProcessor image processor.</p> <div class="docstring border-l-2 border-t-2 pl-4 pt-3.5 border-gray-100 rounded-tl-xl mb-6 mt-8"><!> <p>Preprocess an image or a batch of images.</p></div></div> <!> <div class="docstring border-l-2 border-t-2 pl-4 pt-3.5 border-gray-100 rounded-tl-xl mb-6 mt-8"><!> <p>The Dinov3 Convnext backbone.</p> <p>This model inherits from <a href="/docs/transformers/pr_49141/en/main_classes/model#transformers.PreTrainedModel">PreTrainedModel</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.)</p> <p>This model is also 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.</p> <div class="docstring border-l-2 border-t-2 pl-4 pt-3.5 border-gray-100 rounded-tl-xl mb-6 mt-8"><!> <p>The <a href="/docs/transformers/pr_49141/en/model_doc/dinov3#transformers.DINOv3ConvNextBackbone">DINOv3ConvNextBackbone</a> forward method, overrides the <code>__call__</code> special method.</p> <!> <ul><li><p><strong>feature_maps</strong> (<code>tuple(torch.Tensor)</code> of shape <code>(batch_size, num_channels, height, width)</code>) — Feature maps of the stages.</p></li> <li><p><strong>hidden_states</strong> (<code>tuple(torch.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>torch.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> or <code>(batch_size, num_channels, height, width)</code>, | |
| depending on the backbone.</p> <p>Hidden-states of the model at the output of each stage plus the initial embedding outputs.</p></li> <li><p><strong>attentions</strong> (<code>tuple(torch.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>torch.Tensor</code> (one for each layer) of shape <code>(batch_size, num_heads, sequence_length, sequence_length)</code>. Only applicable if the backbone uses attention.</p> <p>Attentions weights after the attention softmax, used to compute the weighted average in the self-attention | |
| heads.</p></li></ul></div></div> <!> <p></p>`,1);function Be(re,ie){we(ie,!1),Ce(()=>{new URLSearchParams(window.location.search).get("fw")}),be();var J=Ve();Te("1p9qwpj",n=>{var r=De();Ie(r,"content",ke),i(n,r)});var k=e(m(J),4);ye(k,{containerStyle:"float: inline-end; margin-inline-start: 10px; display: inline-flex; position: relative; z-index: 10;"});var D=e(k,4);l(D,{title:"DINOv3",local:"dinov3",headingTag:"h1"});var z=e(D,10);Me(z,{id:"usage",options:["Pipeline","AutoModel"],children:(n,r)=>{var o=ze(),d=m(o);ae(d,{id:"usage",option:"Pipeline",children:(C,ve)=>{c(C,{code:"ZnJvbSUyMHRyYW5zZm9ybWVycyUyMGltcG9ydCUyMHBpcGVsaW5lJTBBJTBBJTBBcGlwZSUyMCUzRCUyMHBpcGVsaW5lKCUwQSUyMCUyMCUyMCUyMHRhc2slM0QlMjJpbWFnZS1mZWF0dXJlLWV4dHJhY3Rpb24lMjIlMkMlMEElMjAlMjAlMjAlMjBtb2RlbCUzRCUyMmZhY2Vib29rJTJGZGlub3YzLXZpdHMxNi1wcmV0cmFpbi1sdmQxNjg5bSUyMiUyQyUwQSklMEElMEFwaXBlKCUyMmh0dHBzJTNBJTJGJTJGaHVnZ2luZ2ZhY2UuY28lMkZkYXRhc2V0cyUyRmh1Z2dpbmdmYWNlJTJGZG9jdW1lbnRhdGlvbi1pbWFnZXMlMkZyZXNvbHZlJTJGbWFpbiUyRnBpcGVsaW5lLWNhdC1jaG9uay5qcGVnJTIyKQ==",highlighted:`<span class="hljs-keyword">from</span> transformers <span class="hljs-keyword">import</span> pipeline | |
| pipe = pipeline( | |
| task=<span class="hljs-string">"image-feature-extraction"</span>, | |
| model=<span class="hljs-string">"facebook/dinov3-vits16-pretrain-lvd1689m"</span>, | |
| ) | |
| pipe(<span class="hljs-string">"https://huggingface.co/datasets/huggingface/documentation-images/resolve/main/pipeline-cat-chonk.jpeg"</span>)`,lang:"python",wrap:!1})},$$slots:{default:!0}});var _e=e(d,2);ae(_e,{id:"usage",option:"AutoModel",children:(C,ve)=>{c(C,{code:"aW1wb3J0JTIwdG9yY2glMEElMEFmcm9tJTIwdHJhbnNmb3JtZXJzJTIwaW1wb3J0JTIwQXV0b0ltYWdlUHJvY2Vzc29yJTJDJTIwQXV0b01vZGVsJTBBZnJvbSUyMHRyYW5zZm9ybWVycy5pbWFnZV91dGlscyUyMGltcG9ydCUyMGxvYWRfaW1hZ2UlMEElMEElMEF1cmwlMjAlM0QlMjAlMjJodHRwJTNBJTJGJTJGaW1hZ2VzLmNvY29kYXRhc2V0Lm9yZyUyRnZhbDIwMTclMkYwMDAwMDAwMzk3NjkuanBnJTIyJTBBaW1hZ2UlMjAlM0QlMjBsb2FkX2ltYWdlKHVybCklMEElMEFwcm9jZXNzb3IlMjAlM0QlMjBBdXRvSW1hZ2VQcm9jZXNzb3IuZnJvbV9wcmV0cmFpbmVkKCUyMmZhY2Vib29rJTJGZGlub3YzLXZpdHMxNi1wcmV0cmFpbi1sdmQxNjg5bSUyMiklMEFtb2RlbCUyMCUzRCUyMEF1dG9Nb2RlbC5mcm9tX3ByZXRyYWluZWQoJTBBJTIwJTIwJTIwJTIwJTIyZmFjZWJvb2slMkZkaW5vdjMtdml0czE2LXByZXRyYWluLWx2ZDE2ODltJTIyJTJDJTBBJTIwJTIwJTIwJTIwZGV2aWNlX21hcCUzRCUyMmF1dG8lMjIlMkMlMEElMjAlMjAlMjAlMjBhdHRuX2ltcGxlbWVudGF0aW9uJTNEJTIyc2RwYSUyMiUwQSklMEElMEFpbnB1dHMlMjAlM0QlMjBwcm9jZXNzb3IoaW1hZ2VzJTNEaW1hZ2UlMkMlMjByZXR1cm5fdGVuc29ycyUzRCUyMnB0JTIyKS50byhtb2RlbC5kZXZpY2UpJTBBd2l0aCUyMHRvcmNoLmluZmVyZW5jZV9tb2RlKCklM0ElMEElMjAlMjAlMjAlMjBvdXRwdXRzJTIwJTNEJTIwbW9kZWwoKippbnB1dHMpJTBBJTBBcG9vbGVkX291dHB1dCUyMCUzRCUyMG91dHB1dHMucG9vbGVyX291dHB1dCUwQXByaW50KCUyMlBvb2xlZCUyMG91dHB1dCUyMHNoYXBlJTNBJTIyJTJDJTIwcG9vbGVkX291dHB1dC5zaGFwZSk=",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> transformers.image_utils <span class="hljs-keyword">import</span> load_image | |
| url = <span class="hljs-string">"http://images.cocodataset.org/val2017/000000039769.jpg"</span> | |
| image = load_image(url) | |
| processor = AutoImageProcessor.from_pretrained(<span class="hljs-string">"facebook/dinov3-vits16-pretrain-lvd1689m"</span>) | |
| model = AutoModel.from_pretrained( | |
| <span class="hljs-string">"facebook/dinov3-vits16-pretrain-lvd1689m"</span>, | |
| device_map=<span class="hljs-string">"auto"</span>, | |
| attn_implementation=<span class="hljs-string">"sdpa"</span> | |
| ) | |
| inputs = processor(images=image, return_tensors=<span class="hljs-string">"pt"</span>).to(model.device) | |
| <span class="hljs-keyword">with</span> torch.inference_mode(): | |
| outputs = model(**inputs) | |
| pooled_output = outputs.pooler_output | |
| <span class="hljs-built_in">print</span>(<span class="hljs-string">"Pooled output shape:"</span>, pooled_output.shape)`,lang:"python",wrap:!1})},$$slots:{default:!0}}),i(n,o)},$$slots:{default:!0}});var V=e(z,6);c(V,{code:"JTIzJTIwcGlwJTIwaW5zdGFsbCUyMHRvcmNoYW8lMEFpbXBvcnQlMjB0b3JjaCUwQWZyb20lMjB0b3JjaGFvLnF1YW50aXphdGlvbiUyMGltcG9ydCUyMEludDRXZWlnaHRPbmx5Q29uZmlnJTBBJTBBZnJvbSUyMHRyYW5zZm9ybWVycyUyMGltcG9ydCUyMEF1dG9JbWFnZVByb2Nlc3NvciUyQyUyMEF1dG9Nb2RlbCUyQyUyMFRvcmNoQW9Db25maWclMEFmcm9tJTIwdHJhbnNmb3JtZXJzLmltYWdlX3V0aWxzJTIwaW1wb3J0JTIwbG9hZF9pbWFnZSUwQSUwQSUwQXVybCUyMCUzRCUyMCUyMmh0dHAlM0ElMkYlMkZpbWFnZXMuY29jb2RhdGFzZXQub3JnJTJGdmFsMjAxNyUyRjAwMDAwMDAzOTc2OS5qcGclMjIlMEFpbWFnZSUyMCUzRCUyMGxvYWRfaW1hZ2UodXJsKSUwQSUwQXByb2Nlc3NvciUyMCUzRCUyMEF1dG9JbWFnZVByb2Nlc3Nvci5mcm9tX3ByZXRyYWluZWQoJTIyZmFjZWJvb2slMkZkaW5vdjMtdml0c3BsdXMtcHJldHJhaW4tbHZkMTY4OW0lMjIpJTBBJTBBcXVhbnRfdHlwZSUyMCUzRCUyMEludDRXZWlnaHRPbmx5Q29uZmlnKGdyb3VwX3NpemUlM0QxMjgpJTBBcXVhbnRpemF0aW9uX2NvbmZpZyUyMCUzRCUyMFRvcmNoQW9Db25maWcocXVhbnRfdHlwZSUzRHF1YW50X3R5cGUpJTBBJTBBbW9kZWwlMjAlM0QlMjBBdXRvTW9kZWwuZnJvbV9wcmV0cmFpbmVkKCUwQSUyMCUyMCUyMCUyMCUyMmZhY2Vib29rJTJGZGlub3YzLXZpdDdiMTYtcHJldHJhaW4tbHZkMTY4OW0lMjIlMkMlMEElMjAlMjAlMjAlMjBkZXZpY2VfbWFwJTNEJTIyYXV0byUyMiUyQyUwQSUyMCUyMCUyMCUyMHF1YW50aXphdGlvbl9jb25maWclM0RxdWFudGl6YXRpb25fY29uZmlnJTBBKSUwQSUwQWlucHV0cyUyMCUzRCUyMHByb2Nlc3NvcihpbWFnZXMlM0RpbWFnZSUyQyUyMHJldHVybl90ZW5zb3JzJTNEJTIycHQlMjIpLnRvKG1vZGVsLmRldmljZSklMEF3aXRoJTIwdG9yY2guaW5mZXJlbmNlX21vZGUoKSUzQSUwQSUyMCUyMCUyMCUyMG91dHB1dHMlMjAlM0QlMjBtb2RlbCgqKmlucHV0cyklMEElMEFwb29sZWRfb3V0cHV0JTIwJTNEJTIwb3V0cHV0cy5wb29sZXJfb3V0cHV0JTBBcHJpbnQoJTIyUG9vbGVkJTIwb3V0cHV0JTIwc2hhcGUlM0ElMjIlMkMlMjBwb29sZWRfb3V0cHV0LnNoYXBlKQ==",highlighted:`<span class="hljs-comment"># pip install torchao</span> | |
| <span class="hljs-keyword">import</span> torch | |
| <span class="hljs-keyword">from</span> torchao.quantization <span class="hljs-keyword">import</span> Int4WeightOnlyConfig | |
| <span class="hljs-keyword">from</span> transformers <span class="hljs-keyword">import</span> AutoImageProcessor, AutoModel, TorchAoConfig | |
| <span class="hljs-keyword">from</span> transformers.image_utils <span class="hljs-keyword">import</span> load_image | |
| url = <span class="hljs-string">"http://images.cocodataset.org/val2017/000000039769.jpg"</span> | |
| image = load_image(url) | |
| processor = AutoImageProcessor.from_pretrained(<span class="hljs-string">"facebook/dinov3-vitsplus-pretrain-lvd1689m"</span>) | |
| quant_type = Int4WeightOnlyConfig(group_size=<span class="hljs-number">128</span>) | |
| quantization_config = TorchAoConfig(quant_type=quant_type) | |
| model = AutoModel.from_pretrained( | |
| <span class="hljs-string">"facebook/dinov3-vit7b16-pretrain-lvd1689m"</span>, | |
| device_map=<span class="hljs-string">"auto"</span>, | |
| quantization_config=quantization_config | |
| ) | |
| inputs = processor(images=image, return_tensors=<span class="hljs-string">"pt"</span>).to(model.device) | |
| <span class="hljs-keyword">with</span> torch.inference_mode(): | |
| outputs = model(**inputs) | |
| pooled_output = outputs.pooler_output | |
| <span class="hljs-built_in">print</span>(<span class="hljs-string">"Pooled output shape:"</span>, pooled_output.shape)`,lang:"python",wrap:!1});var j=e(V,2);l(j,{title:"Notes",local:"notes",headingTag:"h2"});var v=e(j,2),U=t(v),de=e(t(U),4);c(de,{code:"aW1wb3J0JTIwdG9yY2glMEFmcm9tJTIwdHJhbnNmb3JtZXJzJTIwaW1wb3J0JTIwQXV0b0ltYWdlUHJvY2Vzc29yJTJDJTIwQXV0b01vZGVsJTBBZnJvbSUyMHRyYW5zZm9ybWVycy5pbWFnZV91dGlscyUyMGltcG9ydCUyMGxvYWRfaW1hZ2UlMEElMEF1cmwlMjAlM0QlMjAlMjJodHRwJTNBJTJGJTJGaW1hZ2VzLmNvY29kYXRhc2V0Lm9yZyUyRnZhbDIwMTclMkYwMDAwMDAwMzk3NjkuanBnJTIyJTBBaW1hZ2UlMjAlM0QlMjBsb2FkX2ltYWdlKHVybCklMEFwcmludCglMjJJbWFnZSUyMHNpemUlM0ElMjIlMkMlMjBpbWFnZS5oZWlnaHQlMkMlMjBpbWFnZS53aWR0aCklMjAlMjAlMjMlMjAlNUI0ODAlMkMlMjA2NDAlNUQlMEElMEFwcm9jZXNzb3IlMjAlM0QlMjBBdXRvSW1hZ2VQcm9jZXNzb3IuZnJvbV9wcmV0cmFpbmVkKCUyMmZhY2Vib29rJTJGZGlub3YzLXZpdHMxNi1wcmV0cmFpbi1sdmQxNjg5bSUyMiklMEFtb2RlbCUyMCUzRCUyMEF1dG9Nb2RlbC5mcm9tX3ByZXRyYWluZWQoJTIyZmFjZWJvb2slMkZkaW5vdjMtdml0czE2LXByZXRyYWluLWx2ZDE2ODltJTIyJTJDJTIwZGV2aWNlX21hcCUzRCUyMmF1dG8lMjIpJTBBcGF0Y2hfc2l6ZSUyMCUzRCUyMG1vZGVsLmNvbmZpZy5wYXRjaF9zaXplJTBBcHJpbnQoJTIyUGF0Y2glMjBzaXplJTNBJTIyJTJDJTIwcGF0Y2hfc2l6ZSklMjAlMjMlMjAxNiUwQXByaW50KCUyMk51bSUyMHJlZ2lzdGVyJTIwdG9rZW5zJTNBJTIyJTJDJTIwbW9kZWwuY29uZmlnLm51bV9yZWdpc3Rlcl90b2tlbnMpJTIwJTIzJTIwNCUwQSUwQWlucHV0cyUyMCUzRCUyMHByb2Nlc3NvcihpbWFnZXMlM0RpbWFnZSUyQyUyMHJldHVybl90ZW5zb3JzJTNEJTIycHQlMjIpLnRvKG1vZGVsLmRldmljZSklMEFwcmludCglMjJQcmVwcm9jZXNzZWQlMjBpbWFnZSUyMHNpemUlM0ElMjIlMkMlMjBpbnB1dHMucGl4ZWxfdmFsdWVzLnNoYXBlKSUyMCUyMCUyMyUyMCU1QjElMkMlMjAzJTJDJTIwMjI0JTJDJTIwMjI0JTVEJTBBJTBBYmF0Y2hfc2l6ZSUyQyUyMF8lMkMlMjBpbWdfaGVpZ2h0JTJDJTIwaW1nX3dpZHRoJTIwJTNEJTIwaW5wdXRzLnBpeGVsX3ZhbHVlcy5zaGFwZSUwQW51bV9wYXRjaGVzX2hlaWdodCUyQyUyMG51bV9wYXRjaGVzX3dpZHRoJTIwJTNEJTIwaW1nX2hlaWdodCUyMCUyRiUyRiUyMHBhdGNoX3NpemUlMkMlMjBpbWdfd2lkdGglMjAlMkYlMkYlMjBwYXRjaF9zaXplJTBBbnVtX3BhdGNoZXNfZmxhdCUyMCUzRCUyMG51bV9wYXRjaGVzX2hlaWdodCUyMColMjBudW1fcGF0Y2hlc193aWR0aCUwQSUwQXdpdGglMjB0b3JjaC5pbmZlcmVuY2VfbW9kZSgpJTNBJTBBJTIwJTIwb3V0cHV0cyUyMCUzRCUyMG1vZGVsKCoqaW5wdXRzKSUwQSUwQWxhc3RfaGlkZGVuX3N0YXRlcyUyMCUzRCUyMG91dHB1dHMubGFzdF9oaWRkZW5fc3RhdGUlMEFwcmludChsYXN0X2hpZGRlbl9zdGF0ZXMuc2hhcGUpJTIwJTIwJTIzJTIwJTVCMSUyQyUyMDElMjAlMkIlMjA0JTIwJTJCJTIwMjU2JTJDJTIwMzg0JTVEJTBBYXNzZXJ0JTIwbGFzdF9oaWRkZW5fc3RhdGVzLnNoYXBlJTIwJTNEJTNEJTIwKGJhdGNoX3NpemUlMkMlMjAxJTIwJTJCJTIwbW9kZWwuY29uZmlnLm51bV9yZWdpc3Rlcl90b2tlbnMlMjAlMkIlMjBudW1fcGF0Y2hlc19mbGF0JTJDJTIwbW9kZWwuY29uZmlnLmhpZGRlbl9zaXplKSUwQSUwQWNsc190b2tlbiUyMCUzRCUyMGxhc3RfaGlkZGVuX3N0YXRlcyU1QiUzQSUyQyUyMDAlMkMlMjAlM0ElNUQlMEFwYXRjaF9mZWF0dXJlc19mbGF0JTIwJTNEJTIwbGFzdF9oaWRkZW5fc3RhdGVzJTVCJTNBJTJDJTIwMSUyMCUyQiUyMG1vZGVsLmNvbmZpZy5udW1fcmVnaXN0ZXJfdG9rZW5zJTNBJTJDJTIwJTNBJTVEJTBBcGF0Y2hfZmVhdHVyZXMlMjAlM0QlMjBwYXRjaF9mZWF0dXJlc19mbGF0LnVuZmxhdHRlbigxJTJDJTIwKG51bV9wYXRjaGVzX2hlaWdodCUyQyUyMG51bV9wYXRjaGVzX3dpZHRoKSk=",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> transformers.image_utils <span class="hljs-keyword">import</span> load_image | |
| url = <span class="hljs-string">"http://images.cocodataset.org/val2017/000000039769.jpg"</span> | |
| image = load_image(url) | |
| <span class="hljs-built_in">print</span>(<span class="hljs-string">"Image size:"</span>, image.height, image.width) <span class="hljs-comment"># [480, 640]</span> | |
| processor = AutoImageProcessor.from_pretrained(<span class="hljs-string">"facebook/dinov3-vits16-pretrain-lvd1689m"</span>) | |
| model = AutoModel.from_pretrained(<span class="hljs-string">"facebook/dinov3-vits16-pretrain-lvd1689m"</span>, device_map=<span class="hljs-string">"auto"</span>) | |
| patch_size = model.config.patch_size | |
| <span class="hljs-built_in">print</span>(<span class="hljs-string">"Patch size:"</span>, patch_size) <span class="hljs-comment"># 16</span> | |
| <span class="hljs-built_in">print</span>(<span class="hljs-string">"Num register tokens:"</span>, model.config.num_register_tokens) <span class="hljs-comment"># 4</span> | |
| inputs = processor(images=image, return_tensors=<span class="hljs-string">"pt"</span>).to(model.device) | |
| <span class="hljs-built_in">print</span>(<span class="hljs-string">"Preprocessed image size:"</span>, inputs.pixel_values.shape) <span class="hljs-comment"># [1, 3, 224, 224]</span> | |
| batch_size, _, img_height, img_width = inputs.pixel_values.shape | |
| num_patches_height, num_patches_width = img_height // patch_size, img_width // patch_size | |
| num_patches_flat = num_patches_height * num_patches_width | |
| <span class="hljs-keyword">with</span> torch.inference_mode(): | |
| outputs = model(**inputs) | |
| last_hidden_states = outputs.last_hidden_state | |
| <span class="hljs-built_in">print</span>(last_hidden_states.shape) <span class="hljs-comment"># [1, 1 + 4 + 256, 384]</span> | |
| <span class="hljs-keyword">assert</span> last_hidden_states.shape == (batch_size, <span class="hljs-number">1</span> + model.config.num_register_tokens + num_patches_flat, model.config.hidden_size) | |
| cls_token = last_hidden_states[:, <span class="hljs-number">0</span>, :] | |
| patch_features_flat = last_hidden_states[:, <span class="hljs-number">1</span> + model.config.num_register_tokens:, :] | |
| patch_features = patch_features_flat.unflatten(<span class="hljs-number">1</span>, (num_patches_height, num_patches_width))`,lang:"py",wrap:!1}),s(U),s(v);var x=e(v,2);l(x,{title:"DINOv3ViTConfig",local:"transformers.DINOv3ViTConfig",headingTag:"h2"});var b=e(x,2),O=t(b);a(O,{name:"class transformers.DINOv3ViTConfig",anchor:"transformers.DINOv3ViTConfig",source:"https://github.com/huggingface/transformers/blob/vr_49141/src/transformers/models/dinov3_vit/configuration_dinov3_vit.py#L25",parameters:[{name:"transformers_version",val:": str | None = None"},{name:"architectures",val:": list[str] | None = None"},{name:"output_hidden_states",val:": bool | None = False"},{name:"return_dict",val:": bool | None = True"},{name:"dtype",val:": str | torch.dtype | None = None"},{name:"chunk_size_feed_forward",val:": int = 0"},{name:"is_encoder_decoder",val:": bool = False"},{name:"id2label",val:": dict[int, str] | dict[str, str] | None = None"},{name:"label2id",val:": dict[str, int] | dict[str, str] | None = None"},{name:"problem_type",val:": Literal['regression', 'single_label_classification', 'multi_label_classification'] | None = None"},{name:"patch_size",val:": int | list[int] | tuple[int, int] = 16"},{name:"hidden_size",val:": int = 384"},{name:"intermediate_size",val:": int = 1536"},{name:"num_hidden_layers",val:": int = 12"},{name:"num_attention_heads",val:": int = 6"},{name:"hidden_act",val:": str = 'gelu'"},{name:"attention_dropout",val:": float | int = 0.0"},{name:"initializer_range",val:": float = 0.02"},{name:"layer_norm_eps",val:": float = 1e-05"},{name:"rope_theta",val:": float = 100.0"},{name:"image_size",val:": int | list[int] | tuple[int, int] = 224"},{name:"num_channels",val:": int = 3"},{name:"query_bias",val:": bool = True"},{name:"key_bias",val:": bool = False"},{name:"value_bias",val:": bool = True"},{name:"proj_bias",val:": bool = True"},{name:"mlp_bias",val:": bool = True"},{name:"layerscale_value",val:": float = 1.0"},{name:"drop_path_rate",val:": float | int = 0.0"},{name:"use_gated_mlp",val:": bool = False"},{name:"num_register_tokens",val:": int = 0"},{name:"pos_embed_shift",val:": float | None = None"},{name:"pos_embed_jitter",val:": float | None = None"},{name:"pos_embed_rescale",val:": float | None = 2.0"},{name:"_out_features",val:": list[str] | None = None"},{name:"_out_indices",val:": list[int] | None = None"},{name:"apply_layernorm",val:": bool = True"},{name:"reshape_hidden_states",val:": bool = True"}],parametersDescription:[{anchor:"transformers.DINOv3ViTConfig.patch_size",description:`<strong>patch_size</strong> (<code>Union[int, list[int], tuple[int, int]]</code>, <em>optional</em>, defaults to <code>16</code>) — | |
| The size (resolution) of each patch.`,name:"patch_size"},{anchor:"transformers.DINOv3ViTConfig.hidden_size",description:`<strong>hidden_size</strong> (<code>int</code>, <em>optional</em>, defaults to <code>384</code>) — | |
| Dimension of the hidden representations.`,name:"hidden_size"},{anchor:"transformers.DINOv3ViTConfig.intermediate_size",description:`<strong>intermediate_size</strong> (<code>int</code>, <em>optional</em>, defaults to <code>1536</code>) — | |
| Dimension of the MLP representations.`,name:"intermediate_size"},{anchor:"transformers.DINOv3ViTConfig.num_hidden_layers",description:`<strong>num_hidden_layers</strong> (<code>int</code>, <em>optional</em>, defaults to <code>12</code>) — | |
| Number of hidden layers in the Transformer decoder.`,name:"num_hidden_layers"},{anchor:"transformers.DINOv3ViTConfig.num_attention_heads",description:`<strong>num_attention_heads</strong> (<code>int</code>, <em>optional</em>, defaults to <code>6</code>) — | |
| Number of attention heads for each attention layer in the Transformer decoder.`,name:"num_attention_heads"},{anchor:"transformers.DINOv3ViTConfig.hidden_act",description:`<strong>hidden_act</strong> (<code>str</code>, <em>optional</em>, defaults to <code>gelu</code>) — | |
| The non-linear activation function (function or string) in the decoder. For example, <code>"gelu"</code>, | |
| <code>"relu"</code>, <code>"silu"</code>, etc.`,name:"hidden_act"},{anchor:"transformers.DINOv3ViTConfig.attention_dropout",description:`<strong>attention_dropout</strong> (<code>Union[float, int]</code>, <em>optional</em>, defaults to <code>0.0</code>) — | |
| The dropout ratio for the attention probabilities.`,name:"attention_dropout"},{anchor:"transformers.DINOv3ViTConfig.initializer_range",description:`<strong>initializer_range</strong> (<code>float</code>, <em>optional</em>, defaults to <code>0.02</code>) — | |
| The standard deviation of the truncated_normal_initializer for initializing all weight matrices.`,name:"initializer_range"},{anchor:"transformers.DINOv3ViTConfig.layer_norm_eps",description:`<strong>layer_norm_eps</strong> (<code>float</code>, <em>optional</em>, defaults to <code>1e-05</code>) — | |
| The epsilon used by the layer normalization layers.`,name:"layer_norm_eps"},{anchor:"transformers.DINOv3ViTConfig.rope_theta",description:`<strong>rope_theta</strong> (<code>float</code>, <em>optional</em>, defaults to 100.0) — | |
| The base period of the RoPE embeddings.`,name:"rope_theta"},{anchor:"transformers.DINOv3ViTConfig.image_size",description:`<strong>image_size</strong> (<code>Union[int, list[int], tuple[int, int]]</code>, <em>optional</em>, defaults to <code>224</code>) — | |
| The size (resolution) of each image.`,name:"image_size"},{anchor:"transformers.DINOv3ViTConfig.num_channels",description:`<strong>num_channels</strong> (<code>int</code>, <em>optional</em>, defaults to <code>3</code>) — | |
| The number of input channels.`,name:"num_channels"},{anchor:"transformers.DINOv3ViTConfig.query_bias",description:`<strong>query_bias</strong> (<code>bool</code>, <em>optional</em>, defaults to <code>True</code>) — | |
| Whether to add a bias to the query projection.`,name:"query_bias"},{anchor:"transformers.DINOv3ViTConfig.key_bias",description:`<strong>key_bias</strong> (<code>bool</code>, <em>optional</em>, defaults to <code>False</code>) — | |
| Whether to add a bias to the key projection.`,name:"key_bias"},{anchor:"transformers.DINOv3ViTConfig.value_bias",description:`<strong>value_bias</strong> (<code>bool</code>, <em>optional</em>, defaults to <code>True</code>) — | |
| Whether to add a bias to the value projection.`,name:"value_bias"},{anchor:"transformers.DINOv3ViTConfig.proj_bias",description:`<strong>proj_bias</strong> (<code>bool</code>, <em>optional</em>, defaults to <code>True</code>) — | |
| Whether to add a bias to the output projection.`,name:"proj_bias"},{anchor:"transformers.DINOv3ViTConfig.mlp_bias",description:`<strong>mlp_bias</strong> (<code>bool</code>, <em>optional</em>, defaults to <code>True</code>) — | |
| Whether to use a bias in up_proj, down_proj and gate_proj layers in the MLP layers.`,name:"mlp_bias"},{anchor:"transformers.DINOv3ViTConfig.layerscale_value",description:`<strong>layerscale_value</strong> (<code>float</code>, <em>optional</em>, defaults to 1.0) — | |
| Initial value to use for layer scale.`,name:"layerscale_value"},{anchor:"transformers.DINOv3ViTConfig.drop_path_rate",description:`<strong>drop_path_rate</strong> (<code>Union[float, int]</code>, <em>optional</em>, defaults to <code>0.0</code>) — | |
| Drop path rate for the patch fusion.`,name:"drop_path_rate"},{anchor:"transformers.DINOv3ViTConfig.use_gated_mlp",description:`<strong>use_gated_mlp</strong> (<code>bool</code>, <em>optional</em>, defaults to <code>False</code>) — | |
| Whether to use the SwiGLU feedforward neural network.`,name:"use_gated_mlp"},{anchor:"transformers.DINOv3ViTConfig.num_register_tokens",description:`<strong>num_register_tokens</strong> (<code>int</code>, <em>optional</em>, defaults to 0) — | |
| The number of register tokens.`,name:"num_register_tokens"},{anchor:"transformers.DINOv3ViTConfig.pos_embed_shift",description:`<strong>pos_embed_shift</strong> (<code>float</code>, <em>optional</em>) — | |
| Amount to randomly shift position embedding coordinates in [-shift, shift], | |
| applied only in training mode if not <code>None</code>.`,name:"pos_embed_shift"},{anchor:"transformers.DINOv3ViTConfig.pos_embed_jitter",description:`<strong>pos_embed_jitter</strong> (<code>float</code>, <em>optional</em>) — | |
| Amount to randomly jitter position embedding coordinates in log-uniform value in [1/jitter, jitter], | |
| applied only in training mode if not <code>None</code>.`,name:"pos_embed_jitter"},{anchor:"transformers.DINOv3ViTConfig.pos_embed_rescale",description:`<strong>pos_embed_rescale</strong> (<code>float</code>, <em>optional</em>, defaults to 2.0) — | |
| Amount to randomly rescale position embedding coordinates in log-uniform value in [1/rescale, rescale], | |
| applied only in training mode if not <code>None</code>.`,name:"pos_embed_rescale"},{anchor:"transformers.DINOv3ViTConfig.apply_layernorm",description:`<strong>apply_layernorm</strong> (<code>bool</code>, <em>optional</em>, defaults to <code>True</code>) — | |
| Whether to apply layer normalization to the feature maps when used as backbone.`,name:"apply_layernorm"},{anchor:"transformers.DINOv3ViTConfig.reshape_hidden_states",description:`<strong>reshape_hidden_states</strong> (<code>bool</code>, <em>optional</em>, defaults to <code>True</code>) — | |
| Whether to reshape the hidden states to spatial dimensions when used as backbone.`,name:"reshape_hidden_states"}]});var le=e(O,6);u(le,{anchor:"transformers.DINOv3ViTConfig.example",children:(n,r)=>{var o=f(),d=e(m(o),2);c(d,{code:"ZnJvbSUyMHRyYW5zZm9ybWVycyUyMGltcG9ydCUyMERJTk92M1ZpVENvbmZpZyUyQyUyMERJTk92M1ZpVE1vZGVsJTBBJTBBJTIzJTIwSW5pdGlhbGl6aW5nJTIwYSUyMERJTk92MyUyMFZpVC1zbWFsbCUyMHN0eWxlJTIwY29uZmlndXJhdGlvbiUwQWNvbmZpZyUyMCUzRCUyMERJTk92M1ZpVENvbmZpZygpJTBBJTBBJTIzJTIwSW5pdGlhbGl6aW5nJTIwYSUyMG1vZGVsJTIwKHdpdGglMjByYW5kb20lMjB3ZWlnaHRzKSUyMGZyb20lMjB0aGUlMjBjb25maWclMEFtb2RlbCUyMCUzRCUyMERJTk92M1ZpVE1vZGVsKGNvbmZpZyklMEElMEElMjMlMjBBY2Nlc3NpbmclMjB0aGUlMjBtb2RlbCUyMGNvbmZpZyUwQWNvbmZpZyUyMCUzRCUyMG1vZGVsLmNvbmZpZw==",highlighted:`<span class="hljs-meta">>>> </span><span class="hljs-keyword">from</span> transformers <span class="hljs-keyword">import</span> DINOv3ViTConfig, DINOv3ViTModel | |
| <span class="hljs-meta">>>> </span><span class="hljs-comment"># Initializing a DINOv3 ViT-small style configuration</span> | |
| <span class="hljs-meta">>>> </span>config = DINOv3ViTConfig() | |
| <span class="hljs-meta">>>> </span><span class="hljs-comment"># Initializing a model (with random weights) from the config</span> | |
| <span class="hljs-meta">>>> </span>model = DINOv3ViTModel(config) | |
| <span class="hljs-meta">>>> </span><span class="hljs-comment"># Accessing the model config</span> | |
| <span class="hljs-meta">>>> </span>config = model.config`,lang:"python",wrap:!1}),i(n,o)},$$slots:{default:!0}}),s(b);var Z=e(b,2);l(Z,{title:"DINOv3ConvNextConfig",local:"transformers.DINOv3ConvNextConfig",headingTag:"h2"});var T=e(Z,2),W=t(T);a(W,{name:"class transformers.DINOv3ConvNextConfig",anchor:"transformers.DINOv3ConvNextConfig",source:"https://github.com/huggingface/transformers/blob/vr_49141/src/transformers/models/dinov3_convnext/configuration_dinov3_convnext.py#L25",parameters:[{name:"transformers_version",val:": str | None = None"},{name:"architectures",val:": list[str] | None = None"},{name:"output_hidden_states",val:": bool | None = False"},{name:"return_dict",val:": bool | None = True"},{name:"dtype",val:": str | torch.dtype | None = None"},{name:"chunk_size_feed_forward",val:": int = 0"},{name:"is_encoder_decoder",val:": bool = False"},{name:"id2label",val:": dict[int, str] | dict[str, str] | None = None"},{name:"label2id",val:": dict[str, int] | dict[str, str] | None = None"},{name:"problem_type",val:": Literal['regression', 'single_label_classification', 'multi_label_classification'] | None = None"},{name:"num_channels",val:": int = 3"},{name:"hidden_sizes",val:": list[int] | None = None"},{name:"depths",val:": list[int] | None = None"},{name:"hidden_act",val:": str = 'gelu'"},{name:"initializer_range",val:": float = 0.02"},{name:"layer_norm_eps",val:": float = 1e-06"},{name:"layer_scale_init_value",val:": float = 1e-06"},{name:"drop_path_rate",val:": float | int = 0.0"},{name:"image_size",val:": int | list[int] | tuple[int, int] = 224"},{name:"_out_features",val:": list[str] | None = None"},{name:"_out_indices",val:": list[int] | None = None"}],parametersDescription:[{anchor:"transformers.DINOv3ConvNextConfig.num_channels",description:`<strong>num_channels</strong> (<code>int</code>, <em>optional</em>, defaults to <code>3</code>) — | |
| The number of input channels.`,name:"num_channels"},{anchor:"transformers.DINOv3ConvNextConfig.hidden_sizes",description:`<strong>hidden_sizes</strong> (<code>list[int]</code>, <em>optional</em>) — | |
| Dimensionality (hidden size) at each stage of the model.`,name:"hidden_sizes"},{anchor:"transformers.DINOv3ConvNextConfig.depths",description:`<strong>depths</strong> (<code>list[int]</code>, <em>optional</em>) — | |
| Depth of each layer in the Transformer.`,name:"depths"},{anchor:"transformers.DINOv3ConvNextConfig.hidden_act",description:`<strong>hidden_act</strong> (<code>str</code>, <em>optional</em>, defaults to <code>gelu</code>) — | |
| The non-linear activation function (function or string) in the decoder. For example, <code>"gelu"</code>, | |
| <code>"relu"</code>, <code>"silu"</code>, etc.`,name:"hidden_act"},{anchor:"transformers.DINOv3ConvNextConfig.initializer_range",description:`<strong>initializer_range</strong> (<code>float</code>, <em>optional</em>, defaults to <code>0.02</code>) — | |
| The standard deviation of the truncated_normal_initializer for initializing all weight matrices.`,name:"initializer_range"},{anchor:"transformers.DINOv3ConvNextConfig.layer_norm_eps",description:`<strong>layer_norm_eps</strong> (<code>float</code>, <em>optional</em>, defaults to <code>1e-06</code>) — | |
| The epsilon used by the layer normalization layers.`,name:"layer_norm_eps"},{anchor:"transformers.DINOv3ConvNextConfig.layer_scale_init_value",description:`<strong>layer_scale_init_value</strong> (<code>float</code>, <em>optional</em>, defaults to <code>1e-06</code>) — | |
| Scale to use in the self-attention layers. 0.1 for base, 1e-6 for large. Set 0 to disable layer scale.`,name:"layer_scale_init_value"},{anchor:"transformers.DINOv3ConvNextConfig.drop_path_rate",description:`<strong>drop_path_rate</strong> (<code>Union[float, int]</code>, <em>optional</em>, defaults to <code>0.0</code>) — | |
| Drop path rate for the patch fusion.`,name:"drop_path_rate"},{anchor:"transformers.DINOv3ConvNextConfig.image_size",description:`<strong>image_size</strong> (<code>Union[int, list[int], tuple[int, int]]</code>, <em>optional</em>, defaults to <code>224</code>) — | |
| The size (resolution) of each image.`,name:"image_size"}]});var ce=e(W,6);u(ce,{anchor:"transformers.DINOv3ConvNextConfig.example",children:(n,r)=>{var o=f(),d=e(m(o),2);c(d,{code:"ZnJvbSUyMHRyYW5zZm9ybWVycyUyMGltcG9ydCUyMERJTk92M0NvbnZOZXh0Q29uZmlnJTJDJTIwRElOT3YzQ29udk5leHRNb2RlbCUwQSUwQSUyMyUyMEluaXRpYWxpemluZyUyMGElMjBESU5PdjNDb252TmV4dCUyMCh0aW55JTIwdmFyaWFudCklMjBzdHlsZSUyMGNvbmZpZ3VyYXRpb24lMEFjb25maWclMjAlM0QlMjBESU5PdjNDb252TmV4dENvbmZpZygpJTBBJTBBJTIzJTIwSW5pdGlhbGl6aW5nJTIwYSUyMG1vZGVsJTIwKHdpdGglMjByYW5kb20lMjB3ZWlnaHRzKSUwQW1vZGVsJTIwJTNEJTIwRElOT3YzQ29udk5leHRNb2RlbChjb25maWcpJTBBJTBBJTIzJTIwQWNjZXNzaW5nJTIwdGhlJTIwbW9kZWwlMjBjb25maWclMEFjb25maWclMjAlM0QlMjBtb2RlbC5jb25maWc=",highlighted:`<span class="hljs-meta">>>> </span><span class="hljs-keyword">from</span> transformers <span class="hljs-keyword">import</span> DINOv3ConvNextConfig, DINOv3ConvNextModel | |
| <span class="hljs-meta">>>> </span><span class="hljs-comment"># Initializing a DINOv3ConvNext (tiny variant) style configuration</span> | |
| <span class="hljs-meta">>>> </span>config = DINOv3ConvNextConfig() | |
| <span class="hljs-meta">>>> </span><span class="hljs-comment"># Initializing a model (with random weights)</span> | |
| <span class="hljs-meta">>>> </span>model = DINOv3ConvNextModel(config) | |
| <span class="hljs-meta">>>> </span><span class="hljs-comment"># Accessing the model config</span> | |
| <span class="hljs-meta">>>> </span>config = model.config`,lang:"python",wrap:!1}),i(n,o)},$$slots:{default:!0}}),s(T);var B=e(T,2);l(B,{title:"DINOv3ViTModel",local:"transformers.DINOv3ViTModel",headingTag:"h2"});var y=e(B,2),G=t(y);a(G,{name:"class transformers.DINOv3ViTModel",anchor:"transformers.DINOv3ViTModel",source:"https://github.com/huggingface/transformers/blob/vr_49141/src/transformers/models/dinov3_vit/modeling_dinov3_vit.py#L515",parameters:[{name:"config",val:": DINOv3ViTConfig"}],parametersDescription:[{anchor:"transformers.DINOv3ViTModel.config",description:`<strong>config</strong> (<a href="/docs/transformers/pr_49141/en/model_doc/dinov3#transformers.DINOv3ViTConfig">DINOv3ViTConfig</a>) — | |
| 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/pr_49141/en/main_classes/model#transformers.PreTrainedModel.from_pretrained">from_pretrained()</a> method to load the model weights.`,name:"config"}]});var R=e(G,8),P=t(R);a(P,{name:"forward",anchor:"transformers.DINOv3ViTModel.forward",source:"https://github.com/huggingface/transformers/blob/vr_49141/src/transformers/models/dinov3_vit/modeling_dinov3_vit.py#L528",parameters:[{name:"pixel_values",val:": Tensor"},{name:"bool_masked_pos",val:": typing.Optional[torch.Tensor] = None"},{name:"**kwargs",val:": *<class 'transformers.utils.generic.TransformersKwargs'>"}],parametersDescription:[{anchor:"transformers.DINOv3ViTModel.forward.pixel_values",description:`<strong>pixel_values</strong> (<code>torch.Tensor</code> of shape <code>(batch_size, num_channels, image_size, image_size)</code>) — | |
| The tensors corresponding to the input images. Pixel values can be obtained using | |
| <a href="/docs/transformers/pr_49141/en/model_doc/dinov3#transformers.DINOv3ViTImageProcessor">DINOv3ViTImageProcessor</a>. See <a href="/docs/transformers/pr_49141/en/model_doc/molmo2#transformers.Molmo2ImageProcessor.__call__">DINOv3ViTImageProcessor.<strong>call</strong>()</a> for details (<code>processor_class</code> uses | |
| <a href="/docs/transformers/pr_49141/en/model_doc/dinov3#transformers.DINOv3ViTImageProcessor">DINOv3ViTImageProcessor</a> for processing images).`,name:"pixel_values"},{anchor:"transformers.DINOv3ViTModel.forward.bool_masked_pos",description:`<strong>bool_masked_pos</strong> (<code>torch.BoolTensor</code> of shape <code>(batch_size, sequence_length)</code>) — | |
| Boolean masked positions. Indicates which patches are masked (1) and which aren’t (0). Only relevant for | |
| pre-training.`,name:"bool_masked_pos"}],returnDescription:` | |
| <p>A <a | |
| href="/docs/transformers/pr_49141/en/main_classes/output#transformers.modeling_outputs.BaseModelOutputWithPooling" | |
| >BaseModelOutputWithPooling</a> or a tuple of | |
| <code>torch.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/pr_49141/en/model_doc/dinov3#transformers.DINOv3ViTConfig" | |
| >DINOv3ViTConfig</a>) and inputs.</p> | |
| `,returnType:` | |
| <p><a | |
| href="/docs/transformers/pr_49141/en/main_classes/output#transformers.modeling_outputs.BaseModelOutputWithPooling" | |
| >BaseModelOutputWithPooling</a> or <code>tuple(torch.Tensor)</code></p> | |
| `});var F=e(P,4);g(F,{children:(n,r)=>{var o=_();i(n,o)},$$slots:{default:!0}});var me=e(F,4);u(me,{anchor:"transformers.DINOv3ViTModel.forward.example",children:(n,r)=>{var o=f(),d=e(m(o),2);c(d,{code:"",highlighted:"",lang:"python",wrap:!1}),i(n,o)},$$slots:{default:!0}}),s(R),s(y);var q=e(y,2);l(q,{title:"DINOv3ViTBackbone",local:"transformers.DINOv3ViTBackbone",headingTag:"h2"});var M=e(q,2),X=t(M);a(X,{name:"class transformers.DINOv3ViTBackbone",anchor:"transformers.DINOv3ViTBackbone",source:"https://github.com/huggingface/transformers/blob/vr_49141/src/transformers/models/dinov3_vit/modeling_dinov3_vit.py#L557",parameters:[{name:"config",val:": DINOv3ViTConfig"}],parametersDescription:[{anchor:"transformers.DINOv3ViTBackbone.config",description:`<strong>config</strong> (<a href="/docs/transformers/pr_49141/en/model_doc/dinov3#transformers.DINOv3ViTConfig">DINOv3ViTConfig</a>) — | |
| 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/pr_49141/en/main_classes/model#transformers.PreTrainedModel.from_pretrained">from_pretrained()</a> method to load the model weights.`,name:"config"}]});var E=e(X,8),A=t(E);a(A,{name:"forward",anchor:"transformers.DINOv3ViTBackbone.forward",source:"https://github.com/huggingface/transformers/blob/vr_49141/src/transformers/models/dinov3_vit/modeling_dinov3_vit.py#L570",parameters:[{name:"pixel_values",val:": Tensor"},{name:"**kwargs",val:": *<class 'transformers.utils.generic.TransformersKwargs'>"}],parametersDescription:[{anchor:"transformers.DINOv3ViTBackbone.forward.pixel_values",description:`<strong>pixel_values</strong> (<code>torch.Tensor</code> of shape <code>(batch_size, num_channels, image_size, image_size)</code>) — | |
| The tensors corresponding to the input images. Pixel values can be obtained using | |
| <a href="/docs/transformers/pr_49141/en/model_doc/dinov3#transformers.DINOv3ViTImageProcessor">DINOv3ViTImageProcessor</a>. See <a href="/docs/transformers/pr_49141/en/model_doc/molmo2#transformers.Molmo2ImageProcessor.__call__">DINOv3ViTImageProcessor.<strong>call</strong>()</a> for details (<code>processor_class</code> uses | |
| <a href="/docs/transformers/pr_49141/en/model_doc/dinov3#transformers.DINOv3ViTImageProcessor">DINOv3ViTImageProcessor</a> for processing images).`,name:"pixel_values"}],returnDescription:` | |
| <p>A <code>DINOv3ViTBackboneOutput</code> or a tuple of | |
| <code>torch.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/pr_49141/en/model_doc/dinov3#transformers.DINOv3ViTConfig" | |
| >DINOv3ViTConfig</a>) and inputs.</p> | |
| `,returnType:` | |
| <p><code>DINOv3ViTBackboneOutput</code> or <code>tuple(torch.Tensor)</code></p> | |
| `});var pe=e(A,4);g(pe,{children:(n,r)=>{var o=_();i(n,o)},$$slots:{default:!0}}),h(2),s(E),s(M);var H=e(M,2);l(H,{title:"DINOv3ConvNextModel",local:"transformers.DINOv3ConvNextModel",headingTag:"h2"});var N=e(H,2),Y=t(N);a(Y,{name:"class transformers.DINOv3ConvNextModel",anchor:"transformers.DINOv3ConvNextModel",source:"https://github.com/huggingface/transformers/blob/vr_49141/src/transformers/models/dinov3_convnext/modeling_dinov3_convnext.py#L218",parameters:[{name:"config",val:": DINOv3ConvNextConfig"}],parametersDescription:[{anchor:"transformers.DINOv3ConvNextModel.config",description:`<strong>config</strong> (<a href="/docs/transformers/pr_49141/en/model_doc/dinov3#transformers.DINOv3ConvNextConfig">DINOv3ConvNextConfig</a>) — | |
| 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/pr_49141/en/main_classes/model#transformers.PreTrainedModel.from_pretrained">from_pretrained()</a> method to load the model weights.`,name:"config"}]});var Q=e(Y,8),S=t(Q);a(S,{name:"forward",anchor:"transformers.DINOv3ConvNextModel.forward",source:"https://github.com/huggingface/transformers/blob/vr_49141/src/transformers/models/dinov3_convnext/modeling_dinov3_convnext.py#L226",parameters:[{name:"pixel_values",val:": Tensor"},{name:"**kwargs",val:""}],parametersDescription:[{anchor:"transformers.DINOv3ConvNextModel.forward.pixel_values",description:`<strong>pixel_values</strong> (<code>torch.Tensor</code> of shape <code>(batch_size, num_channels, image_size, image_size)</code>) — | |
| The tensors corresponding to the input images. Pixel values can be obtained using | |
| <code>image_processor_class</code>. See <code>image_processor_class.__call__</code> for details (<code>processor_class</code> uses | |
| <code>image_processor_class</code> for processing images).`,name:"pixel_values"}],returnDescription:` | |
| <p>A <code>BaseModelOutputWithPoolingAndNoAttention</code> or a tuple of | |
| <code>torch.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/pr_49141/en/model_doc/dinov3#transformers.DINOv3ConvNextConfig" | |
| >DINOv3ConvNextConfig</a>) and inputs.</p> | |
| `,returnType:` | |
| <p><code>BaseModelOutputWithPoolingAndNoAttention</code> or <code>tuple(torch.Tensor)</code></p> | |
| `});var L=e(S,4);g(L,{children:(n,r)=>{var o=_();i(n,o)},$$slots:{default:!0}});var he=e(L,4);u(he,{anchor:"transformers.DINOv3ConvNextModel.forward.example",children:(n,r)=>{var o=f(),d=e(m(o),2);c(d,{code:"",highlighted:"",lang:"python",wrap:!1}),i(n,o)},$$slots:{default:!0}}),s(Q),s(N);var $=e(N,2);l($,{title:"DINOv3ViTImageProcessor",local:"transformers.DINOv3ViTImageProcessor",headingTag:"h2"});var I=e($,2),K=t(I);a(K,{name:"class transformers.DINOv3ViTImageProcessor",anchor:"transformers.DINOv3ViTImageProcessor",source:"https://github.com/huggingface/transformers/blob/vr_49141/src/transformers/models/dinov3_vit/image_processing_dinov3_vit.py#L34",parameters:[{name:"**kwargs",val:": *<class 'transformers.processing_utils.ImagesKwargs'>"}],parametersDescription:[{anchor:"transformers.DINOv3ViTImageProcessor.do_convert_rgb",description:`<strong>do_convert_rgb</strong> (<code>bool</code>, <em>kwargs</em>, <em>optional</em>) — | |
| Whether to convert the image to RGB.`,name:"do_convert_rgb"},{anchor:"transformers.DINOv3ViTImageProcessor.do_resize",description:`<strong>do_resize</strong> (<code>bool</code>, <em>kwargs</em>, <em>optional</em>, defaults to <code>True</code>) — | |
| Whether to resize the image.`,name:"do_resize"},{anchor:"transformers.DINOv3ViTImageProcessor.size",description:`<strong>size</strong> (<code>Annotated[int | list[int] | tuple[int, ...] | dict[str, int] | None, None]</code>, <em>kwargs</em>, defaults to <code>{'height' -- 224, 'width': 224}</code>): | |
| Describes the maximum input dimensions to the model.`,name:"size"},{anchor:"transformers.DINOv3ViTImageProcessor.default_to_square",description:`<strong>default_to_square</strong> (<code>bool</code>, <em>kwargs</em>, <em>optional</em>, defaults to <code>True</code>) — | |
| Whether to default to a square image when resizing, if size is an int.`,name:"default_to_square"},{anchor:"transformers.DINOv3ViTImageProcessor.crop_size",description:`<strong>crop_size</strong> (<code>Annotated[int | list[int] | tuple[int, ...] | dict[str, int] | None, None]</code>, <em>kwargs</em>) — | |
| Size of the output image after applying <code>center_crop</code>.`,name:"crop_size"},{anchor:"transformers.DINOv3ViTImageProcessor.resample",description:`<strong>resample</strong> (<code>Annotated[Union[int, PILImageResampling, NoneType], None]</code>, <em>kwargs</em>, defaults to <code>2</code>) — | |
| Resampling filter to use if resizing the image. This can be one of the enum <code>PILImageResampling</code>. Only | |
| has an effect if <code>do_resize</code> is set to <code>True</code>.`,name:"resample"},{anchor:"transformers.DINOv3ViTImageProcessor.do_rescale",description:`<strong>do_rescale</strong> (<code>bool</code>, <em>kwargs</em>, <em>optional</em>, defaults to <code>True</code>) — | |
| Whether to rescale the image.`,name:"do_rescale"},{anchor:"transformers.DINOv3ViTImageProcessor.rescale_factor",description:`<strong>rescale_factor</strong> (<code>float</code>, <em>kwargs</em>, <em>optional</em>, defaults to <code>0.00392156862745098</code>) — | |
| Rescale factor to rescale the image by if <code>do_rescale</code> is set to <code>True</code>.`,name:"rescale_factor"},{anchor:"transformers.DINOv3ViTImageProcessor.do_normalize",description:`<strong>do_normalize</strong> (<code>bool</code>, <em>kwargs</em>, <em>optional</em>, defaults to <code>True</code>) — | |
| Whether to normalize the image.`,name:"do_normalize"},{anchor:"transformers.DINOv3ViTImageProcessor.image_mean",description:`<strong>image_mean</strong> (<code>Union[float, list[float], tuple[float, ...]]</code>, <em>kwargs</em>, <em>optional</em>, defaults to <code>[0.485, 0.456, 0.406]</code>) — | |
| Image mean to use for normalization. Only has an effect if <code>do_normalize</code> is set to <code>True</code>.`,name:"image_mean"},{anchor:"transformers.DINOv3ViTImageProcessor.image_std",description:`<strong>image_std</strong> (<code>Union[float, list[float], tuple[float, ...]]</code>, <em>kwargs</em>, <em>optional</em>, defaults to <code>[0.229, 0.224, 0.225]</code>) — | |
| Image standard deviation to use for normalization. Only has an effect if <code>do_normalize</code> is set to | |
| <code>True</code>.`,name:"image_std"},{anchor:"transformers.DINOv3ViTImageProcessor.do_pad",description:`<strong>do_pad</strong> (<code>bool</code>, <em>kwargs</em>, <em>optional</em>) — | |
| Whether to pad the image. Padding is done either to the largest size in the batch | |
| or to a fixed square size per image. The exact padding strategy depends on the model.`,name:"do_pad"},{anchor:"transformers.DINOv3ViTImageProcessor.pad_size",description:`<strong>pad_size</strong> (<code>Annotated[int | list[int] | tuple[int, ...] | dict[str, int] | None, None]</code>, <em>kwargs</em>) — | |
| The size in <code>{"height": int, "width" int}</code> to pad the images to. Must be larger than any image size | |
| provided for preprocessing. If <code>pad_size</code> is not provided, images will be padded to the largest | |
| height and width in the batch. Applied only when <code>do_pad=True.</code>`,name:"pad_size"},{anchor:"transformers.DINOv3ViTImageProcessor.do_center_crop",description:`<strong>do_center_crop</strong> (<code>bool</code>, <em>kwargs</em>, <em>optional</em>) — | |
| Whether to center crop the image.`,name:"do_center_crop"},{anchor:"transformers.DINOv3ViTImageProcessor.data_format",description:`<strong>data_format</strong> (<code>Union[str, ~image_utils.ChannelDimension]</code>, <em>kwargs</em>, <em>optional</em>) — | |
| Only <code>ChannelDimension.FIRST</code> is supported. Added for compatibility with slow processors.`,name:"data_format"},{anchor:"transformers.DINOv3ViTImageProcessor.input_data_format",description:`<strong>input_data_format</strong> (<code>Union[str, ~image_utils.ChannelDimension]</code>, <em>kwargs</em>, <em>optional</em>) — | |
| 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>"channels_first"</code> or <code>ChannelDimension.FIRST</code>: image in (num_channels, height, width) format.</li> | |
| <li><code>"channels_last"</code> or <code>ChannelDimension.LAST</code>: image in (height, width, num_channels) format.</li> | |
| <li><code>"none"</code> or <code>ChannelDimension.NONE</code>: image in (height, width) format.</li> | |
| </ul>`,name:"input_data_format"},{anchor:"transformers.DINOv3ViTImageProcessor.device",description:`<strong>device</strong> (<code>Annotated[Union[str, torch.device, NoneType], None]</code>, <em>kwargs</em>) — | |
| The device to process the videos on. If unset, the device is inferred from the input videos.`,name:"device"},{anchor:"transformers.DINOv3ViTImageProcessor.return_tensors",description:`<strong>return_tensors</strong> (<code>Annotated[str | ~utils.generic.TensorType | None, None]</code>, <em>kwargs</em>) — | |
| Returns stacked tensors if set to <code>'pt'</code>, otherwise returns a list of tensors.`,name:"return_tensors"},{anchor:"transformers.DINOv3ViTImageProcessor.disable_grouping",description:`<strong>disable_grouping</strong> (<code>bool</code>, <em>kwargs</em>, <em>optional</em>) — | |
| Whether to disable grouping of images by size to process them individually and not in batches. | |
| If None, will be set to True if the images are on CPU, and False otherwise. This choice is based on | |
| empirical observations, as detailed here: <a href="https://github.com/huggingface/transformers/pull/38157" rel="nofollow">https://github.com/huggingface/transformers/pull/38157</a>`,name:"disable_grouping"},{anchor:"transformers.DINOv3ViTImageProcessor.image_seq_length",description:`<strong>image_seq_length</strong> (<code>int</code>, <em>kwargs</em>, <em>optional</em>) — | |
| The number of image tokens to be used for each image in the input. | |
| Added for backward compatibility but this should be set as a processor attribute in future models.`,name:"image_seq_length"}]});var ee=e(K,4),ge=t(ee);a(ge,{name:"preprocess",anchor:"transformers.DINOv3ViTImageProcessor.preprocess",source:"https://github.com/huggingface/transformers/blob/vr_49141/src/transformers/image_processing_utils.py#L382",parameters:[{name:"images",val:": typing.Union[ForwardRef('PIL.Image.Image'), numpy.ndarray, ForwardRef('torch.Tensor'), list['PIL.Image.Image'], list[numpy.ndarray], list['torch.Tensor']]"},{name:"*args",val:""},{name:"image_like_kwargs",val:": dict[str, typing.Any] | None = None"},{name:"**kwargs",val:": *<class 'transformers.processing_utils.ImagesKwargs'>"}],parametersDescription:[{anchor:"transformers.DINOv3ViTImageProcessor.preprocess.images",description:`<strong>images</strong> (<code>Union[PIL.Image.Image, numpy.ndarray, torch.Tensor, list[PIL.Image.Image], list[numpy.ndarray], list[torch.Tensor]]</code>) — | |
| 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.DINOv3ViTImageProcessor.preprocess.image_like_kwargs",description:`<strong>image_like_kwargs</strong> (<code>dict[str, Any]</code>, <em>optional</em>) — | |
| Developer flag for additional image like inputs that will also be preprocessed. Only use this if | |
| passing the inputs as kwarg doesn’t work. For example, <code>preprocess(images, masks=masks)</code> is the | |
| preferred option but results in argument priority issues for some models. In those cases | |
| <code>preprocess(images, image_like_inputs={"masks": masks})</code> can be used instead.`,name:"image_like_kwargs"},{anchor:"transformers.DINOv3ViTImageProcessor.preprocess.do_convert_rgb",description:`<strong>do_convert_rgb</strong> (<code>bool</code>, <em>kwargs</em>, <em>optional</em>) — | |
| Whether to convert the image to RGB.`,name:"do_convert_rgb"},{anchor:"transformers.DINOv3ViTImageProcessor.preprocess.do_resize",description:`<strong>do_resize</strong> (<code>bool</code>, <em>kwargs</em>, <em>optional</em>) — | |
| Whether to resize the image.`,name:"do_resize"},{anchor:"transformers.DINOv3ViTImageProcessor.preprocess.size",description:`<strong>size</strong> (<code>Annotated[int | list[int] | tuple[int, ...] | dict[str, int] | None, None]</code>, <em>kwargs</em>) — | |
| Describes the maximum input dimensions to the model.`,name:"size"},{anchor:"transformers.DINOv3ViTImageProcessor.preprocess.default_to_square",description:`<strong>default_to_square</strong> (<code>bool</code>, <em>kwargs</em>, <em>optional</em>) — | |
| Whether to default to a square image when resizing, if size is an int.`,name:"default_to_square"},{anchor:"transformers.DINOv3ViTImageProcessor.preprocess.crop_size",description:`<strong>crop_size</strong> (<code>Annotated[int | list[int] | tuple[int, ...] | dict[str, int] | None, None]</code>, <em>kwargs</em>) — | |
| Size of the output image after applying <code>center_crop</code>.`,name:"crop_size"},{anchor:"transformers.DINOv3ViTImageProcessor.preprocess.resample",description:`<strong>resample</strong> (<code>Annotated[Union[int, PILImageResampling, NoneType], None]</code>, <em>kwargs</em>) — | |
| Resampling filter to use if resizing the image. This can be one of the enum <code>PILImageResampling</code>. Only | |
| has an effect if <code>do_resize</code> is set to <code>True</code>.`,name:"resample"},{anchor:"transformers.DINOv3ViTImageProcessor.preprocess.do_rescale",description:`<strong>do_rescale</strong> (<code>bool</code>, <em>kwargs</em>, <em>optional</em>) — | |
| Whether to rescale the image.`,name:"do_rescale"},{anchor:"transformers.DINOv3ViTImageProcessor.preprocess.rescale_factor",description:`<strong>rescale_factor</strong> (<code>float</code>, <em>kwargs</em>, <em>optional</em>) — | |
| Rescale factor to rescale the image by if <code>do_rescale</code> is set to <code>True</code>.`,name:"rescale_factor"},{anchor:"transformers.DINOv3ViTImageProcessor.preprocess.do_normalize",description:`<strong>do_normalize</strong> (<code>bool</code>, <em>kwargs</em>, <em>optional</em>) — | |
| Whether to normalize the image.`,name:"do_normalize"},{anchor:"transformers.DINOv3ViTImageProcessor.preprocess.image_mean",description:`<strong>image_mean</strong> (<code>Union[float, list[float], tuple[float, ...]]</code>, <em>kwargs</em>, <em>optional</em>) — | |
| Image mean to use for normalization. Only has an effect if <code>do_normalize</code> is set to <code>True</code>.`,name:"image_mean"},{anchor:"transformers.DINOv3ViTImageProcessor.preprocess.image_std",description:`<strong>image_std</strong> (<code>Union[float, list[float], tuple[float, ...]]</code>, <em>kwargs</em>, <em>optional</em>) — | |
| Image standard deviation to use for normalization. Only has an effect if <code>do_normalize</code> is set to | |
| <code>True</code>.`,name:"image_std"},{anchor:"transformers.DINOv3ViTImageProcessor.preprocess.do_pad",description:`<strong>do_pad</strong> (<code>bool</code>, <em>kwargs</em>, <em>optional</em>) — | |
| Whether to pad the image. Padding is done either to the largest size in the batch | |
| or to a fixed square size per image. The exact padding strategy depends on the model.`,name:"do_pad"},{anchor:"transformers.DINOv3ViTImageProcessor.preprocess.pad_size",description:`<strong>pad_size</strong> (<code>Annotated[int | list[int] | tuple[int, ...] | dict[str, int] | None, None]</code>, <em>kwargs</em>) — | |
| The size in <code>{"height": int, "width" int}</code> to pad the images to. Must be larger than any image size | |
| provided for preprocessing. If <code>pad_size</code> is not provided, images will be padded to the largest | |
| height and width in the batch. Applied only when <code>do_pad=True.</code>`,name:"pad_size"},{anchor:"transformers.DINOv3ViTImageProcessor.preprocess.do_center_crop",description:`<strong>do_center_crop</strong> (<code>bool</code>, <em>kwargs</em>, <em>optional</em>) — | |
| Whether to center crop the image.`,name:"do_center_crop"},{anchor:"transformers.DINOv3ViTImageProcessor.preprocess.data_format",description:`<strong>data_format</strong> (<code>Union[str, ~image_utils.ChannelDimension]</code>, <em>kwargs</em>, <em>optional</em>) — | |
| Only <code>ChannelDimension.FIRST</code> is supported. Added for compatibility with slow processors.`,name:"data_format"},{anchor:"transformers.DINOv3ViTImageProcessor.preprocess.input_data_format",description:`<strong>input_data_format</strong> (<code>Union[str, ~image_utils.ChannelDimension]</code>, <em>kwargs</em>, <em>optional</em>) — | |
| 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>"channels_first"</code> or <code>ChannelDimension.FIRST</code>: image in (num_channels, height, width) format.</li> | |
| <li><code>"channels_last"</code> or <code>ChannelDimension.LAST</code>: image in (height, width, num_channels) format.</li> | |
| <li><code>"none"</code> or <code>ChannelDimension.NONE</code>: image in (height, width) format.</li> | |
| </ul>`,name:"input_data_format"},{anchor:"transformers.DINOv3ViTImageProcessor.preprocess.device",description:`<strong>device</strong> (<code>Annotated[Union[str, torch.device, NoneType], None]</code>, <em>kwargs</em>) — | |
| The device to process the videos on. If unset, the device is inferred from the input videos.`,name:"device"},{anchor:"transformers.DINOv3ViTImageProcessor.preprocess.return_tensors",description:`<strong>return_tensors</strong> (<code>Annotated[str | ~utils.generic.TensorType | None, None]</code>, <em>kwargs</em>) — | |
| Returns stacked tensors if set to <code>'pt'</code>, otherwise returns a list of tensors.`,name:"return_tensors"},{anchor:"transformers.DINOv3ViTImageProcessor.preprocess.disable_grouping",description:`<strong>disable_grouping</strong> (<code>bool</code>, <em>kwargs</em>, <em>optional</em>) — | |
| Whether to disable grouping of images by size to process them individually and not in batches. | |
| If None, will be set to True if the images are on CPU, and False otherwise. This choice is based on | |
| empirical observations, as detailed here: <a href="https://github.com/huggingface/transformers/pull/38157" rel="nofollow">https://github.com/huggingface/transformers/pull/38157</a>`,name:"disable_grouping"},{anchor:"transformers.DINOv3ViTImageProcessor.preprocess.image_seq_length",description:`<strong>image_seq_length</strong> (<code>int</code>, <em>kwargs</em>, <em>optional</em>) — | |
| The number of image tokens to be used for each image in the input. | |
| Added for backward compatibility but this should be set as a processor attribute in future models.`,name:"image_seq_length"}],returnDescription:` | |
| <ul> | |
| <li><strong>data</strong> (<code>dict</code>) — Dictionary of lists/arrays/tensors returned by the <strong>call</strong> method (‘pixel_values’, etc.).</li> | |
| <li><strong>tensor_type</strong> (<code>Union[None, str, TensorType]</code>, <em>optional</em>) — You can give a tensor_type here to convert the lists of integers in PyTorch/Numpy Tensors at | |
| initialization.</li> | |
| </ul> | |
| `,returnType:` | |
| <p><code>~image_processing_base.BatchFeature</code></p> | |
| `}),h(2),s(ee),s(I);var oe=e(I,2);l(oe,{title:"DINOv3ConvNextBackbone",local:"transformers.DINOv3ConvNextBackbone",headingTag:"h2"});var w=e(oe,2),ne=t(w);a(ne,{name:"class transformers.DINOv3ConvNextBackbone",anchor:"transformers.DINOv3ConvNextBackbone",source:"https://github.com/huggingface/transformers/blob/vr_49141/src/transformers/models/dinov3_convnext/modeling_dinov3_convnext.py#L253",parameters:[{name:"config",val:": DINOv3ConvNextConfig"}],parametersDescription:[{anchor:"transformers.DINOv3ConvNextBackbone.config",description:`<strong>config</strong> (<a href="/docs/transformers/pr_49141/en/model_doc/dinov3#transformers.DINOv3ConvNextConfig">DINOv3ConvNextConfig</a>) — | |
| 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/pr_49141/en/main_classes/model#transformers.PreTrainedModel.from_pretrained">from_pretrained()</a> method to load the model weights.`,name:"config"}]});var te=e(ne,8),se=t(te);a(se,{name:"forward",anchor:"transformers.DINOv3ConvNextBackbone.forward",source:"https://github.com/huggingface/transformers/blob/vr_49141/src/transformers/models/dinov3_convnext/modeling_dinov3_convnext.py#L268",parameters:[{name:"pixel_values",val:": Tensor"},{name:"**kwargs",val:""}],parametersDescription:[{anchor:"transformers.DINOv3ConvNextBackbone.forward.pixel_values",description:`<strong>pixel_values</strong> (<code>torch.Tensor</code> of shape <code>(batch_size, num_channels, image_size, image_size)</code>) — | |
| The tensors corresponding to the input images. Pixel values can be obtained using | |
| <code>image_processor_class</code>. See <code>image_processor_class.__call__</code> for details (<code>processor_class</code> uses | |
| <code>image_processor_class</code> for processing images).`,name:"pixel_values"}],returnDescription:` | |
| <p>A <code>BackboneOutput</code> or a tuple of | |
| <code>torch.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/pr_49141/en/model_doc/dinov3#transformers.DINOv3ConvNextConfig" | |
| >DINOv3ConvNextConfig</a>) and inputs.</p> | |
| `,returnType:` | |
| <p><code>BackboneOutput</code> or <code>tuple(torch.Tensor)</code></p> | |
| `});var ue=e(se,4);g(ue,{children:(n,r)=>{var o=_();i(n,o)},$$slots:{default:!0}}),h(2),s(te),s(w);var fe=e(w,2);Ne(fe,{source:"https://github.com/huggingface/transformers/blob/main/docs/source/en/model_doc/dinov3.md"}),h(2),i(re,J),Je()}export{Be as component}; | |
Xet Storage Details
- Size:
- 73.5 kB
- Xet hash:
- 996de08bb292af6843b20e06478a1afc2990bc351d541c329feb937a7d2c3443
·
Xet efficiently stores files, intelligently splitting them into unique chunks and accelerating uploads and downloads. More info.