import{s as Ut,o as Zt,n as Me}from"../chunks/scheduler.9bc65507.js";import{S as It,i as Wt,g as c,s as r,r as h,A as kt,h as m,f as o,c as i,j as ce,u,x as f,k as me,y as p,a as n,v as g,d as v,t as b,w as _}from"../chunks/index.707bf1b6.js";import{T as Ct}from"../chunks/Tip.c2ecdbf4.js";import{D as we}from"../chunks/Docstring.570ddb64.js";import{C as Te}from"../chunks/CodeBlock.54a9f38d.js";import{E as dt}from"../chunks/ExampleCodeBlock.bc2be6bc.js";import{H as pe,E as xt}from"../chunks/EditOnGithub.922df6ba.js";function Ft($){let s,w="Example:",l,d,y;return d=new Te({props:{code:"ZnJvbSUyMHRyYW5zZm9ybWVycyUyMGltcG9ydCUyMFB2dFYyTW9kZWwlMkMlMjBQdnRWMkNvbmZpZyUwQSUwQSUyMyUyMEluaXRpYWxpemluZyUyMGElMjBwdnRfdjJfYjAlMjBzdHlsZSUyMGNvbmZpZ3VyYXRpb24lMEFjb25maWd1cmF0aW9uJTIwJTNEJTIwUHZ0VjJDb25maWcoKSUwQSUwQSUyMyUyMEluaXRpYWxpemluZyUyMGElMjBtb2RlbCUyMGZyb20lMjB0aGUlMjBPcGVuR1ZMYWIlMkZwdnRfdjJfYjAlMjBzdHlsZSUyMGNvbmZpZ3VyYXRpb24lMEFtb2RlbCUyMCUzRCUyMFB2dFYyTW9kZWwoY29uZmlndXJhdGlvbiklMEElMEElMjMlMjBBY2Nlc3NpbmclMjB0aGUlMjBtb2RlbCUyMGNvbmZpZ3VyYXRpb24lMEFjb25maWd1cmF0aW9uJTIwJTNEJTIwbW9kZWwuY29uZmln",highlighted:`<span class="hljs-meta">&gt;&gt;&gt; </span><span class="hljs-keyword">from</span> transformers <span class="hljs-keyword">import</span> PvtV2Model, PvtV2Config

<span class="hljs-meta">&gt;&gt;&gt; </span><span class="hljs-comment"># Initializing a pvt_v2_b0 style configuration</span>
<span class="hljs-meta">&gt;&gt;&gt; </span>configuration = PvtV2Config()

<span class="hljs-meta">&gt;&gt;&gt; </span><span class="hljs-comment"># Initializing a model from the OpenGVLab/pvt_v2_b0 style configuration</span>
<span class="hljs-meta">&gt;&gt;&gt; </span>model = PvtV2Model(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(){s=c("p"),s.textContent=w,l=r(),h(d.$$.fragment)},l(a){s=m(a,"P",{"data-svelte-h":!0}),f(s)!=="svelte-11lpom8"&&(s.textContent=w),l=i(a),u(d.$$.fragment,a)},m(a,T){n(a,s,T),n(a,l,T),g(d,a,T),y=!0},p:Me,i(a){y||(v(d.$$.fragment,a),y=!0)},o(a){b(d.$$.fragment,a),y=!1},d(a){a&&(o(s),o(l)),_(d,a)}}}function Bt($){let s,w=`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(){s=c("p"),s.innerHTML=w},l(l){s=m(l,"P",{"data-svelte-h":!0}),f(s)!=="svelte-fincs2"&&(s.innerHTML=w)},m(l,d){n(l,s,d)},p:Me,d(l){l&&o(s)}}}function Rt($){let s,w="Example:",l,d,y;return d=new Te({props:{code:"ZnJvbSUyMHRyYW5zZm9ybWVycyUyMGltcG9ydCUyMEF1dG9JbWFnZVByb2Nlc3NvciUyQyUyMFB2dFYyRm9ySW1hZ2VDbGFzc2lmaWNhdGlvbiUwQWltcG9ydCUyMHRvcmNoJTBBZnJvbSUyMGRhdGFzZXRzJTIwaW1wb3J0JTIwbG9hZF9kYXRhc2V0JTBBJTBBZGF0YXNldCUyMCUzRCUyMGxvYWRfZGF0YXNldCglMjJodWdnaW5nZmFjZSUyRmNhdHMtaW1hZ2UlMjIpJTBBaW1hZ2UlMjAlM0QlMjBkYXRhc2V0JTVCJTIydGVzdCUyMiU1RCU1QiUyMmltYWdlJTIyJTVEJTVCMCU1RCUwQSUwQWltYWdlX3Byb2Nlc3NvciUyMCUzRCUyMEF1dG9JbWFnZVByb2Nlc3Nvci5mcm9tX3ByZXRyYWluZWQoJTIyT3BlbkdWTGFiJTJGcHZ0X3YyX2IwJTIyKSUwQW1vZGVsJTIwJTNEJTIwUHZ0VjJGb3JJbWFnZUNsYXNzaWZpY2F0aW9uLmZyb21fcHJldHJhaW5lZCglMjJPcGVuR1ZMYWIlMkZwdnRfdjJfYjAlMjIpJTBBJTBBaW5wdXRzJTIwJTNEJTIwaW1hZ2VfcHJvY2Vzc29yKGltYWdlJTJDJTIwcmV0dXJuX3RlbnNvcnMlM0QlMjJwdCUyMiklMEElMEF3aXRoJTIwdG9yY2gubm9fZ3JhZCgpJTNBJTBBJTIwJTIwJTIwJTIwbG9naXRzJTIwJTNEJTIwbW9kZWwoKippbnB1dHMpLmxvZ2l0cyUwQSUwQSUyMyUyMG1vZGVsJTIwcHJlZGljdHMlMjBvbmUlMjBvZiUyMHRoZSUyMDEwMDAlMjBJbWFnZU5ldCUyMGNsYXNzZXMlMEFwcmVkaWN0ZWRfbGFiZWwlMjAlM0QlMjBsb2dpdHMuYXJnbWF4KC0xKS5pdGVtKCklMEFwcmludChtb2RlbC5jb25maWcuaWQybGFiZWwlNUJwcmVkaWN0ZWRfbGFiZWwlNUQp",highlighted:`<span class="hljs-meta">&gt;&gt;&gt; </span><span class="hljs-keyword">from</span> transformers <span class="hljs-keyword">import</span> AutoImageProcessor, PvtV2ForImageClassification
<span class="hljs-meta">&gt;&gt;&gt; </span><span class="hljs-keyword">import</span> torch
<span class="hljs-meta">&gt;&gt;&gt; </span><span class="hljs-keyword">from</span> datasets <span class="hljs-keyword">import</span> load_dataset

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

<span class="hljs-meta">&gt;&gt;&gt; </span>image_processor = AutoImageProcessor.from_pretrained(<span class="hljs-string">&quot;OpenGVLab/pvt_v2_b0&quot;</span>)
<span class="hljs-meta">&gt;&gt;&gt; </span>model = PvtV2ForImageClassification.from_pretrained(<span class="hljs-string">&quot;OpenGVLab/pvt_v2_b0&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])
LABEL_281`,wrap:!1}}),{c(){s=c("p"),s.textContent=w,l=r(),h(d.$$.fragment)},l(a){s=m(a,"P",{"data-svelte-h":!0}),f(s)!=="svelte-11lpom8"&&(s.textContent=w),l=i(a),u(d.$$.fragment,a)},m(a,T){n(a,s,T),n(a,l,T),g(d,a,T),y=!0},p:Me,i(a){y||(v(d.$$.fragment,a),y=!0)},o(a){b(d.$$.fragment,a),y=!1},d(a){a&&(o(s),o(l)),_(d,a)}}}function zt($){let s,w=`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(){s=c("p"),s.innerHTML=w},l(l){s=m(l,"P",{"data-svelte-h":!0}),f(s)!=="svelte-fincs2"&&(s.innerHTML=w)},m(l,d){n(l,s,d)},p:Me,d(l){l&&o(s)}}}function Nt($){let s,w="Example:",l,d,y;return d=new Te({props:{code:"ZnJvbSUyMHRyYW5zZm9ybWVycyUyMGltcG9ydCUyMEF1dG9JbWFnZVByb2Nlc3NvciUyQyUyMFB2dFYyTW9kZWwlMEFpbXBvcnQlMjB0b3JjaCUwQWZyb20lMjBkYXRhc2V0cyUyMGltcG9ydCUyMGxvYWRfZGF0YXNldCUwQSUwQWRhdGFzZXQlMjAlM0QlMjBsb2FkX2RhdGFzZXQoJTIyaHVnZ2luZ2ZhY2UlMkZjYXRzLWltYWdlJTIyKSUwQWltYWdlJTIwJTNEJTIwZGF0YXNldCU1QiUyMnRlc3QlMjIlNUQlNUIlMjJpbWFnZSUyMiU1RCU1QjAlNUQlMEElMEFpbWFnZV9wcm9jZXNzb3IlMjAlM0QlMjBBdXRvSW1hZ2VQcm9jZXNzb3IuZnJvbV9wcmV0cmFpbmVkKCUyMk9wZW5HVkxhYiUyRnB2dF92Ml9iMCUyMiklMEFtb2RlbCUyMCUzRCUyMFB2dFYyTW9kZWwuZnJvbV9wcmV0cmFpbmVkKCUyMk9wZW5HVkxhYiUyRnB2dF92Ml9iMCUyMiklMEElMEFpbnB1dHMlMjAlM0QlMjBpbWFnZV9wcm9jZXNzb3IoaW1hZ2UlMkMlMjByZXR1cm5fdGVuc29ycyUzRCUyMnB0JTIyKSUwQSUwQXdpdGglMjB0b3JjaC5ub19ncmFkKCklM0ElMEElMjAlMjAlMjAlMjBvdXRwdXRzJTIwJTNEJTIwbW9kZWwoKippbnB1dHMpJTBBJTBBbGFzdF9oaWRkZW5fc3RhdGVzJTIwJTNEJTIwb3V0cHV0cy5sYXN0X2hpZGRlbl9zdGF0ZSUwQWxpc3QobGFzdF9oaWRkZW5fc3RhdGVzLnNoYXBlKQ==",highlighted:`<span class="hljs-meta">&gt;&gt;&gt; </span><span class="hljs-keyword">from</span> transformers <span class="hljs-keyword">import</span> AutoImageProcessor, PvtV2Model
<span class="hljs-meta">&gt;&gt;&gt; </span><span class="hljs-keyword">import</span> torch
<span class="hljs-meta">&gt;&gt;&gt; </span><span class="hljs-keyword">from</span> datasets <span class="hljs-keyword">import</span> load_dataset

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

<span class="hljs-meta">&gt;&gt;&gt; </span>image_processor = AutoImageProcessor.from_pretrained(<span class="hljs-string">&quot;OpenGVLab/pvt_v2_b0&quot;</span>)
<span class="hljs-meta">&gt;&gt;&gt; </span>model = PvtV2Model.from_pretrained(<span class="hljs-string">&quot;OpenGVLab/pvt_v2_b0&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">256</span>, <span class="hljs-number">7</span>, <span class="hljs-number">7</span>]`,wrap:!1}}),{c(){s=c("p"),s.textContent=w,l=r(),h(d.$$.fragment)},l(a){s=m(a,"P",{"data-svelte-h":!0}),f(s)!=="svelte-11lpom8"&&(s.textContent=w),l=i(a),u(d.$$.fragment,a)},m(a,T){n(a,s,T),n(a,l,T),g(d,a,T),y=!0},p:Me,i(a){y||(v(d.$$.fragment,a),y=!0)},o(a){b(d.$$.fragment,a),y=!1},d(a){a&&(o(s),o(l)),_(d,a)}}}function Gt($){let s,w,l,d,y,a,T,Ve,z,ct=`The PVTv2 model was proposed in
<a href="https://arxiv.org/abs/2106.13797" rel="nofollow">PVT v2: Improved Baselines with Pyramid Vision Transformer</a> by Wenhai Wang, Enze Xie, Xiang Li, Deng-Ping Fan, Kaitao Song, Ding Liang, Tong Lu, Ping Luo, and Ling Shao. As an improved variant of PVT, it eschews position embeddings, relying instead on positional information encoded through zero-padding and overlapping patch embeddings. This lack of reliance on position embeddings simplifies the architecture, and enables running inference at any resolution without needing to interpolate them.`,$e,N,mt='The PVTv2 encoder structure has been successfully deployed to achieve state-of-the-art scores in <a href="https://arxiv.org/abs/2105.15203" rel="nofollow">Segformer</a> for semantic segmentation, <a href="https://arxiv.org/abs/2201.07436" rel="nofollow">GLPN</a> for monocular depth, and <a href="https://arxiv.org/abs/2109.03814" rel="nofollow">Panoptic Segformer</a> for panoptic segmentation.',Je,G,pt='PVTv2 belongs to a family of models called <a href="https://natecibik.medium.com/the-rise-of-vision-transformers-f623c980419f" rel="nofollow">hierarchical transformers</a> , which make adaptations to transformer layers in order to generate multi-scale feature maps. Unlike the columnal structure of Vision Transformer (<a href="https://arxiv.org/abs/2010.11929" rel="nofollow">ViT</a>) which loses fine-grained detail, multi-scale feature maps are known preserve this detail and aid performance in dense prediction tasks. In the case of PVTv2, this is achieved by generating image patch tokens using 2D convolution with overlapping kernels in each encoder layer.',je,L,ft="The multi-scale features of hierarchical transformers allow them to be easily swapped in for traditional workhorse computer vision backbone models like ResNet in larger architectures. Both Segformer and Panoptic Segformer demonstrated that configurations using PVTv2 for a backbone consistently outperformed those with similarly sized ResNet backbones.",Pe,X,ht="Another powerful feature of the PVTv2 is the complexity reduction in the self-attention layers called Spatial Reduction Attention (SRA), which uses 2D convolution layers to project hidden states to a smaller resolution before attending to them with the queries, improving the $O(n^2)$ complexity of self-attention to $O(n^2/R)$, with $R$ being the spatial reduction ratio (<code>sr_ratio</code>, aka kernel size and stride in the 2D convolution).",Ce,Y,ut="SRA was introduced in PVT, and is the default attention complexity reduction method used in PVTv2. However, PVTv2 also introduced the option of using a self-attention mechanism with linear complexity related to image size, which they called “Linear SRA”. This method uses average pooling to reduce the hidden states to a fixed size that is invariant to their original resolution (although this is inherently more lossy than regular SRA). This option can be enabled by setting <code>linear_attention</code> to <code>True</code> in the PVTv2Config.",Ue,H,Ze,q,gt='<em>Transformer recently has presented encouraging progress in computer vision. In this work, we present new baselines by improving the original Pyramid Vision Transformer (PVT v1) by adding three designs, including (1) linear complexity attention layer, (2) overlapping patch embedding, and (3) convolutional feed-forward network. With these modifications, PVT v2 reduces the computational complexity of PVT v1 to linear and achieves significant improvements on fundamental vision tasks such as classification, detection, and segmentation. Notably, the proposed PVT v2 achieves comparable or better performances than recent works such as Swin Transformer. We hope this work will facilitate state-of-the-art Transformer researches in computer vision. Code is available at <a href="https://github.com/whai362/PVT" rel="nofollow">https://github.com/whai362/PVT</a>.</em>',Ie,E,vt='This model was contributed by <a href="https://huggingface.co/FoamoftheSea" rel="nofollow">FoamoftheSea</a>. The original code can be found <a href="https://github.com/whai362/PVT" rel="nofollow">here</a>.',We,S,ke,A,bt='<li><p><a href="https://arxiv.org/abs/2106.13797" rel="nofollow">PVTv2</a> is a hierarchical transformer model which has demonstrated powerful performance in image classification and multiple other tasks, used as a backbone for semantic segmentation in <a href="https://arxiv.org/abs/2105.15203" rel="nofollow">Segformer</a>, monocular depth estimation in <a href="https://arxiv.org/abs/2201.07436" rel="nofollow">GLPN</a>, and panoptic segmentation in <a href="https://arxiv.org/abs/2109.03814" rel="nofollow">Panoptic Segformer</a>, consistently showing higher performance than similar ResNet configurations.</p></li> <li><p>Hierarchical transformers like PVTv2 achieve superior data and parameter efficiency on image data compared with pure transformer architectures by incorporating design elements of convolutional neural networks (CNNs) into their encoders. This creates a best-of-both-worlds architecture that infuses the useful inductive biases of CNNs like translation equivariance and locality into the network while still enjoying the benefits of dynamic data response and global relationship modeling provided by the self-attention mechanism of <a href="https://arxiv.org/abs/1706.03762" rel="nofollow">transformers</a>.</p></li> <li><p>PVTv2 uses overlapping patch embeddings to create multi-scale feature maps, which are infused with location information using zero-padding and depth-wise convolutions.</p></li> <li><p>To reduce the complexity in the attention layers, PVTv2 performs a spatial reduction on the hidden states using either strided 2D convolution (SRA) or fixed-size average pooling (Linear SRA). Although inherently more lossy, Linear SRA provides impressive performance with a linear complexity with respect to image size. To use Linear SRA in the self-attention layers, set <code>linear_attention=True</code> in the <code>PvtV2Config</code>.</p></li> <li><p><a href="/docs/transformers/main/en/model_doc/pvt_v2#transformers.PvtV2Model">PvtV2Model</a> is the hierarchical transformer encoder (which is also often referred to as Mix Transformer or MiT in the literature). <a href="/docs/transformers/main/en/model_doc/pvt_v2#transformers.PvtV2ForImageClassification">PvtV2ForImageClassification</a> adds a simple classifier head on top to perform Image Classification. <code>PvtV2Backbone</code> can be used with the <a href="/docs/transformers/main/en/main_classes/backbones#transformers.AutoBackbone">AutoBackbone</a> system in larger architectures like Deformable DETR.</p></li> <li><p>ImageNet pretrained weights for all model sizes can be found on the <a href="https://huggingface.co/models?other=pvt_v2" rel="nofollow">hub</a>.</p> <p>The best way to get started with the PVTv2 is to load the pretrained checkpoint with the size of your choosing using <code>AutoModelForImageClassification</code>:</p></li>',xe,Q,Fe,D,_t="To use the PVTv2 as a backbone for more complex architectures like DeformableDETR, you can use AutoBackbone (this model would need fine-tuning as you’re replacing the backbone in the pretrained model):",Be,O,Re,K,yt='<a href="https://github.com/whai362/PVT/tree/v2" rel="nofollow">PVTv2</a> performance on ImageNet-1K by model size (B0-B5):',ze,ee,wt='<thead><tr><th>Method</th> <th align="center">Size</th> <th align="center">Acc@1</th> <th align="center">#Params (M)</th></tr></thead> <tbody><tr><td>PVT-V2-B0</td> <td align="center">224</td> <td align="center">70.5</td> <td align="center">3.7</td></tr> <tr><td>PVT-V2-B1</td> <td align="center">224</td> <td align="center">78.7</td> <td align="center">14.0</td></tr> <tr><td>PVT-V2-B2-Linear</td> <td align="center">224</td> <td align="center">82.1</td> <td align="center">22.6</td></tr> <tr><td>PVT-V2-B2</td> <td align="center">224</td> <td align="center">82.0</td> <td align="center">25.4</td></tr> <tr><td>PVT-V2-B3</td> <td align="center">224</td> <td align="center">83.1</td> <td align="center">45.2</td></tr> <tr><td>PVT-V2-B4</td> <td align="center">224</td> <td align="center">83.6</td> <td align="center">62.6</td></tr> <tr><td>PVT-V2-B5</td> <td align="center">224</td> <td align="center">83.8</td> <td align="center">82.0</td></tr></tbody>',Ne,te,Ge,M,oe,Ae,fe,Tt=`This is the configuration class to store the configuration of a <a href="/docs/transformers/main/en/model_doc/pvt_v2#transformers.PvtV2Model">PvtV2Model</a>. It is used to instantiate a Pvt V2
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 Pvt V2 B0
<a href="https://huggingface.co/OpenGVLab/pvt_v2_b0" rel="nofollow">OpenGVLab/pvt_v2_b0</a> architecture.`,Qe,he,Mt=`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.`,De,k,Le,ne,Xe,V,se,Oe,ue,Vt=`Pvt-v2 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.`,Ke,ge,$t=`This model is a PyTorch <a href="https://pytorch.org/docs/stable/nn.html#torch.nn.Module" rel="nofollow">torch.nn.Module</a> sub-class. Use
it as a regular PyTorch Module and refer to the PyTorch documentation for all matter related to general usage and
behavior.`,et,J,ae,tt,ve,Jt='The <a href="/docs/transformers/main/en/model_doc/pvt_v2#transformers.PvtV2ForImageClassification">PvtV2ForImageClassification</a> forward method, overrides the <code>__call__</code> special method.',ot,x,nt,F,Ye,re,He,P,ie,st,be,jt=`The bare Pvt-v2 encoder 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> sub-class. Use
it as a regular PyTorch Module and refer to the PyTorch documentation for all matter related to general usage and
behavior.`,at,j,le,rt,_e,Pt='The <a href="/docs/transformers/main/en/model_doc/pvt_v2#transformers.PvtV2Model">PvtV2Model</a> forward method, overrides the <code>__call__</code> special method.',it,B,lt,R,qe,de,Ee,ye,Se;return y=new pe({props:{title:"Pyramid Vision Transformer V2 (PVTv2)",local:"pyramid-vision-transformer-v2-pvtv2",headingTag:"h1"}}),T=new pe({props:{title:"Overview",local:"overview",headingTag:"h2"}}),H=new pe({props:{title:"Abstract from the paper:",local:"abstract-from-the-paper",headingTag:"h3"}}),S=new pe({props:{title:"Usage tips",local:"usage-tips",headingTag:"h2"}}),Q=new Te({props:{code:"aW1wb3J0JTIwcmVxdWVzdHMlMEFpbXBvcnQlMjB0b3JjaCUwQSUwQWZyb20lMjB0cmFuc2Zvcm1lcnMlMjBpbXBvcnQlMjBBdXRvTW9kZWxGb3JJbWFnZUNsYXNzaWZpY2F0aW9uJTJDJTIwQXV0b0ltYWdlUHJvY2Vzc29yJTBBZnJvbSUyMFBJTCUyMGltcG9ydCUyMEltYWdlJTBBJTBBbW9kZWwlMjAlM0QlMjBBdXRvTW9kZWxGb3JJbWFnZUNsYXNzaWZpY2F0aW9uLmZyb21fcHJldHJhaW5lZCglMjJPcGVuR1ZMYWIlMkZwdnRfdjJfYjAlMjIpJTBBaW1hZ2VfcHJvY2Vzc29yJTIwJTNEJTIwQXV0b0ltYWdlUHJvY2Vzc29yLmZyb21fcHJldHJhaW5lZCglMjJPcGVuR1ZMYWIlMkZwdnRfdjJfYjAlMjIpJTBBdXJsJTIwJTNEJTIwJTIyaHR0cCUzQSUyRiUyRmltYWdlcy5jb2NvZGF0YXNldC5vcmclMkZ2YWwyMDE3JTJGMDAwMDAwMDM5NzY5LmpwZyUyMiUwQWltYWdlJTIwJTNEJTIwSW1hZ2Uub3BlbihyZXF1ZXN0cy5nZXQodXJsJTJDJTIwc3RyZWFtJTNEVHJ1ZSkucmF3KSUwQXByb2Nlc3NlZCUyMCUzRCUyMGltYWdlX3Byb2Nlc3NvcihpbWFnZSklMEFvdXRwdXRzJTIwJTNEJTIwbW9kZWwodG9yY2gudGVuc29yKHByb2Nlc3NlZCU1QiUyMnBpeGVsX3ZhbHVlcyUyMiU1RCkp",highlighted:`<span class="hljs-keyword">import</span> requests
<span class="hljs-keyword">import</span> torch

<span class="hljs-keyword">from</span> transformers <span class="hljs-keyword">import</span> AutoModelForImageClassification, AutoImageProcessor
<span class="hljs-keyword">from</span> PIL <span class="hljs-keyword">import</span> Image

model = AutoModelForImageClassification.from_pretrained(<span class="hljs-string">&quot;OpenGVLab/pvt_v2_b0&quot;</span>)
image_processor = AutoImageProcessor.from_pretrained(<span class="hljs-string">&quot;OpenGVLab/pvt_v2_b0&quot;</span>)
url = <span class="hljs-string">&quot;http://images.cocodataset.org/val2017/000000039769.jpg&quot;</span>
image = Image.<span class="hljs-built_in">open</span>(requests.get(url, stream=<span class="hljs-literal">True</span>).raw)
processed = image_processor(image)
outputs = model(torch.tensor(processed[<span class="hljs-string">&quot;pixel_values&quot;</span>]))`,wrap:!1}}),O=new Te({props:{code:"aW1wb3J0JTIwcmVxdWVzdHMlMEFpbXBvcnQlMjB0b3JjaCUwQSUwQWZyb20lMjB0cmFuc2Zvcm1lcnMlMjBpbXBvcnQlMjBBdXRvQ29uZmlnJTJDJTIwQXV0b01vZGVsRm9yT2JqZWN0RGV0ZWN0aW9uJTJDJTIwQXV0b0ltYWdlUHJvY2Vzc29yJTBBZnJvbSUyMFBJTCUyMGltcG9ydCUyMEltYWdlJTBBJTBBbW9kZWwlMjAlM0QlMjBBdXRvTW9kZWxGb3JPYmplY3REZXRlY3Rpb24uZnJvbV9jb25maWcoJTBBJTIwJTIwJTIwJTIwY29uZmlnJTNEQXV0b0NvbmZpZy5mcm9tX3ByZXRyYWluZWQoJTBBJTIwJTIwJTIwJTIwJTIwJTIwJTIwJTIwJTIyU2Vuc2VUaW1lJTJGZGVmb3JtYWJsZS1kZXRyJTIyJTJDJTBBJTIwJTIwJTIwJTIwJTIwJTIwJTIwJTIwYmFja2JvbmVfY29uZmlnJTNEQXV0b0NvbmZpZy5mcm9tX3ByZXRyYWluZWQoJTIyT3BlbkdWTGFiJTJGcHZ0X3YyX2I1JTIyKSUyQyUwQSUyMCUyMCUyMCUyMCUyMCUyMCUyMCUyMHVzZV90aW1tX2JhY2tib25lJTNERmFsc2UlMEElMjAlMjAlMjAlMjApJTJDJTBBKSUwQSUwQWltYWdlX3Byb2Nlc3NvciUyMCUzRCUyMEF1dG9JbWFnZVByb2Nlc3Nvci5mcm9tX3ByZXRyYWluZWQoJTIyU2Vuc2VUaW1lJTJGZGVmb3JtYWJsZS1kZXRyJTIyKSUwQXVybCUyMCUzRCUyMCUyMmh0dHAlM0ElMkYlMkZpbWFnZXMuY29jb2RhdGFzZXQub3JnJTJGdmFsMjAxNyUyRjAwMDAwMDAzOTc2OS5qcGclMjIlMEFpbWFnZSUyMCUzRCUyMEltYWdlLm9wZW4ocmVxdWVzdHMuZ2V0KHVybCUyQyUyMHN0cmVhbSUzRFRydWUpLnJhdyklMEFwcm9jZXNzZWQlMjAlM0QlMjBpbWFnZV9wcm9jZXNzb3IoaW1hZ2UpJTBBb3V0cHV0cyUyMCUzRCUyMG1vZGVsKHRvcmNoLnRlbnNvcihwcm9jZXNzZWQlNUIlMjJwaXhlbF92YWx1ZXMlMjIlNUQpKQ==",highlighted:`<span class="hljs-keyword">import</span> requests
<span class="hljs-keyword">import</span> torch

<span class="hljs-keyword">from</span> transformers <span class="hljs-keyword">import</span> AutoConfig, AutoModelForObjectDetection, AutoImageProcessor
<span class="hljs-keyword">from</span> PIL <span class="hljs-keyword">import</span> Image

model = AutoModelForObjectDetection.from_config(
    config=AutoConfig.from_pretrained(
        <span class="hljs-string">&quot;SenseTime/deformable-detr&quot;</span>,
        backbone_config=AutoConfig.from_pretrained(<span class="hljs-string">&quot;OpenGVLab/pvt_v2_b5&quot;</span>),
        use_timm_backbone=<span class="hljs-literal">False</span>
    ),
)

image_processor = AutoImageProcessor.from_pretrained(<span class="hljs-string">&quot;SenseTime/deformable-detr&quot;</span>)
url = <span class="hljs-string">&quot;http://images.cocodataset.org/val2017/000000039769.jpg&quot;</span>
image = Image.<span class="hljs-built_in">open</span>(requests.get(url, stream=<span class="hljs-literal">True</span>).raw)
processed = image_processor(image)
outputs = model(torch.tensor(processed[<span class="hljs-string">&quot;pixel_values&quot;</span>]))`,wrap:!1}}),te=new pe({props:{title:"PvtV2Config",local:"transformers.PvtV2Config",headingTag:"h2"}}),oe=new we({props:{name:"class transformers.PvtV2Config",anchor:"transformers.PvtV2Config",parameters:[{name:"image_size",val:": Union = 224"},{name:"num_channels",val:": int = 3"},{name:"num_encoder_blocks",val:": int = 4"},{name:"depths",val:": List = [2, 2, 2, 2]"},{name:"sr_ratios",val:": List = [8, 4, 2, 1]"},{name:"hidden_sizes",val:": List = [32, 64, 160, 256]"},{name:"patch_sizes",val:": List = [7, 3, 3, 3]"},{name:"strides",val:": List = [4, 2, 2, 2]"},{name:"num_attention_heads",val:": List = [1, 2, 5, 8]"},{name:"mlp_ratios",val:": List = [8, 8, 4, 4]"},{name:"hidden_act",val:": Union = 'gelu'"},{name:"hidden_dropout_prob",val:": float = 0.0"},{name:"attention_probs_dropout_prob",val:": float = 0.0"},{name:"initializer_range",val:": float = 0.02"},{name:"drop_path_rate",val:": float = 0.0"},{name:"layer_norm_eps",val:": float = 1e-06"},{name:"qkv_bias",val:": bool = True"},{name:"linear_attention",val:": bool = False"},{name:"out_features",val:" = None"},{name:"out_indices",val:" = None"},{name:"**kwargs",val:""}],parametersDescription:[{anchor:"transformers.PvtV2Config.image_size",description:`<strong>image_size</strong> (<code>Union[int, Tuple[int, int]]</code>, <em>optional</em>, defaults to 224) &#x2014;
The input image size. Pass int value for square image, or tuple of (height, width).`,name:"image_size"},{anchor:"transformers.PvtV2Config.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.PvtV2Config.num_encoder_blocks",description:`<strong>num_encoder_blocks</strong> (<code>[int]</code>, <em>optional</em>, defaults to 4) &#x2014;
The number of encoder blocks (i.e. stages in the Mix Transformer encoder).`,name:"num_encoder_blocks"},{anchor:"transformers.PvtV2Config.depths",description:`<strong>depths</strong> (<code>List[int]</code>, <em>optional</em>, defaults to <code>[2, 2, 2, 2]</code>) &#x2014;
The number of layers in each encoder block.`,name:"depths"},{anchor:"transformers.PvtV2Config.sr_ratios",description:`<strong>sr_ratios</strong> (<code>List[int]</code>, <em>optional</em>, defaults to <code>[8, 4, 2, 1]</code>) &#x2014;
Spatial reduction ratios in each encoder block.`,name:"sr_ratios"},{anchor:"transformers.PvtV2Config.hidden_sizes",description:`<strong>hidden_sizes</strong> (<code>List[int]</code>, <em>optional</em>, defaults to <code>[32, 64, 160, 256]</code>) &#x2014;
Dimension of each of the encoder blocks.`,name:"hidden_sizes"},{anchor:"transformers.PvtV2Config.patch_sizes",description:`<strong>patch_sizes</strong> (<code>List[int]</code>, <em>optional</em>, defaults to <code>[7, 3, 3, 3]</code>) &#x2014;
Patch size for overlapping patch embedding before each encoder block.`,name:"patch_sizes"},{anchor:"transformers.PvtV2Config.strides",description:`<strong>strides</strong> (<code>List[int]</code>, <em>optional</em>, defaults to <code>[4, 2, 2, 2]</code>) &#x2014;
Stride for overlapping patch embedding before each encoder block.`,name:"strides"},{anchor:"transformers.PvtV2Config.num_attention_heads",description:`<strong>num_attention_heads</strong> (<code>List[int]</code>, <em>optional</em>, defaults to <code>[1, 2, 5, 8]</code>) &#x2014;
Number of attention heads for each attention layer in each block of the Transformer encoder.`,name:"num_attention_heads"},{anchor:"transformers.PvtV2Config.mlp_ratios",description:`<strong>mlp_ratios</strong> (<code>List[int]</code>, <em>optional</em>, defaults to <code>[8, 8, 4, 4]</code>) &#x2014;
Ratio of the size of the hidden layer compared to the size of the input layer of the Mix FFNs in the
encoder blocks.`,name:"mlp_ratios"},{anchor:"transformers.PvtV2Config.hidden_act",description:`<strong>hidden_act</strong> (<code>str</code> or <code>Callable</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.PvtV2Config.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.PvtV2Config.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.PvtV2Config.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.PvtV2Config.drop_path_rate",description:`<strong>drop_path_rate</strong> (<code>float</code>, <em>optional</em>, defaults to 0.0) &#x2014;
The dropout probability for stochastic depth, used in the blocks of the Transformer encoder.`,name:"drop_path_rate"},{anchor:"transformers.PvtV2Config.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.PvtV2Config.qkv_bias",description:`<strong>qkv_bias</strong> (<code>bool</code>, <em>optional</em>, defaults to <code>True</code>) &#x2014;
Whether or not a learnable bias should be added to the queries, keys and values.`,name:"qkv_bias"},{anchor:"transformers.PvtV2Config.linear_attention",description:`<strong>linear_attention</strong> (<code>bool</code>, <em>optional</em>, defaults to <code>False</code>) &#x2014;
Use linear attention complexity. If set to True, <code>sr_ratio</code> is ignored and average pooling is used for
dimensionality reduction in the attention layers rather than strided convolution.`,name:"linear_attention"},{anchor:"transformers.PvtV2Config.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.`,name:"out_features"},{anchor:"transformers.PvtV2Config.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.`,name:"out_indices"}],source:"https://github.com/huggingface/transformers/blob/main/src/transformers/models/pvt_v2/configuration_pvt_v2.py#L29"}}),k=new dt({props:{anchor:"transformers.PvtV2Config.example",$$slots:{default:[Ft]},$$scope:{ctx:$}}}),ne=new pe({props:{title:"PvtForImageClassification",local:"transformers.PvtV2ForImageClassification",headingTag:"h2"}}),se=new we({props:{name:"class transformers.PvtV2ForImageClassification",anchor:"transformers.PvtV2ForImageClassification",parameters:[{name:"config",val:": PvtV2Config"}],parametersDescription:[{anchor:"transformers.PvtV2ForImageClassification.config",description:`<strong>config</strong> (<a href="/docs/transformers/main/en/model_doc/pvt_v2#transformers.PvtV2Config">~PvtV2Config</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/pvt_v2/modeling_pvt_v2.py#L524"}}),ae=new we({props:{name:"forward",anchor:"transformers.PvtV2ForImageClassification.forward",parameters:[{name:"pixel_values",val:": Optional"},{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.PvtV2ForImageClassification.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/fuyu#transformers.FuyuImageProcessor.__call__">PvtImageProcessor.<strong>call</strong>()</a> for details.`,name:"pixel_values"},{anchor:"transformers.PvtV2ForImageClassification.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.PvtV2ForImageClassification.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.PvtV2ForImageClassification.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.PvtV2ForImageClassification.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/pvt_v2/modeling_pvt_v2.py#L546",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/pvt_v2#transformers.PvtV2Config"
>PvtV2Config</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>
`}}),x=new Ct({props:{$$slots:{default:[Bt]},$$scope:{ctx:$}}}),F=new dt({props:{anchor:"transformers.PvtV2ForImageClassification.forward.example",$$slots:{default:[Rt]},$$scope:{ctx:$}}}),re=new pe({props:{title:"PvtModel",local:"transformers.PvtV2Model",headingTag:"h2"}}),ie=new we({props:{name:"class transformers.PvtV2Model",anchor:"transformers.PvtV2Model",parameters:[{name:"config",val:": PvtV2Config"}],parametersDescription:[{anchor:"transformers.PvtV2Model.config",description:`<strong>config</strong> (<a href="/docs/transformers/main/en/model_doc/pvt_v2#transformers.PvtV2Config">~PvtV2Config</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/pvt_v2/modeling_pvt_v2.py#L462"}}),le=new we({props:{name:"forward",anchor:"transformers.PvtV2Model.forward",parameters:[{name:"pixel_values",val:": FloatTensor"},{name:"output_attentions",val:": Optional = None"},{name:"output_hidden_states",val:": Optional = None"},{name:"return_dict",val:": Optional = None"}],parametersDescription:[{anchor:"transformers.PvtV2Model.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/fuyu#transformers.FuyuImageProcessor.__call__">PvtImageProcessor.<strong>call</strong>()</a> for details.`,name:"pixel_values"},{anchor:"transformers.PvtV2Model.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.PvtV2Model.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.PvtV2Model.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/pvt_v2/modeling_pvt_v2.py#L485",returnDescription:`<script context="module">export const metadata = 'undefined';<\/script>


<p>A <a
  href="/docs/transformers/main/en/main_classes/output#transformers.modeling_outputs.BaseModelOutput"
>transformers.modeling_outputs.BaseModelOutput</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/pvt_v2#transformers.PvtV2Config"
>PvtV2Config</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>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.BaseModelOutput"
>transformers.modeling_outputs.BaseModelOutput</a> or <code>tuple(torch.FloatTensor)</code></p>
`}}),B=new Ct({props:{$$slots:{default:[zt]},$$scope:{ctx:$}}}),R=new dt({props:{anchor:"transformers.PvtV2Model.forward.example",$$slots:{default:[Nt]},$$scope:{ctx:$}}}),de=new xt({props:{source:"https://github.com/huggingface/transformers/blob/main/docs/source/en/model_doc/pvt_v2.md"}}),{c(){s=c("meta"),w=r(),l=c("p"),d=r(),h(y.$$.fragment),a=r(),h(T.$$.fragment),Ve=r(),z=c("p"),z.innerHTML=ct,$e=r(),N=c("p"),N.innerHTML=mt,Je=r(),G=c("p"),G.innerHTML=pt,je=r(),L=c("p"),L.textContent=ft,Pe=r(),X=c("p"),X.innerHTML=ht,Ce=r(),Y=c("p"),Y.innerHTML=ut,Ue=r(),h(H.$$.fragment),Ze=r(),q=c("p"),q.innerHTML=gt,Ie=r(),E=c("p"),E.innerHTML=vt,We=r(),h(S.$$.fragment),ke=r(),A=c("ul"),A.innerHTML=bt,xe=r(),h(Q.$$.fragment),Fe=r(),D=c("p"),D.textContent=_t,Be=r(),h(O.$$.fragment),Re=r(),K=c("p"),K.innerHTML=yt,ze=r(),ee=c("table"),ee.innerHTML=wt,Ne=r(),h(te.$$.fragment),Ge=r(),M=c("div"),h(oe.$$.fragment),Ae=r(),fe=c("p"),fe.innerHTML=Tt,Qe=r(),he=c("p"),he.innerHTML=Mt,De=r(),h(k.$$.fragment),Le=r(),h(ne.$$.fragment),Xe=r(),V=c("div"),h(se.$$.fragment),Oe=r(),ue=c("p"),ue.textContent=Vt,Ke=r(),ge=c("p"),ge.innerHTML=$t,et=r(),J=c("div"),h(ae.$$.fragment),tt=r(),ve=c("p"),ve.innerHTML=Jt,ot=r(),h(x.$$.fragment),nt=r(),h(F.$$.fragment),Ye=r(),h(re.$$.fragment),He=r(),P=c("div"),h(ie.$$.fragment),st=r(),be=c("p"),be.innerHTML=jt,at=r(),j=c("div"),h(le.$$.fragment),rt=r(),_e=c("p"),_e.innerHTML=Pt,it=r(),h(B.$$.fragment),lt=r(),h(R.$$.fragment),qe=r(),h(de.$$.fragment),Ee=r(),ye=c("p"),this.h()},l(e){const t=kt("svelte-u9bgzb",document.head);s=m(t,"META",{name:!0,content:!0}),t.forEach(o),w=i(e),l=m(e,"P",{}),ce(l).forEach(o),d=i(e),u(y.$$.fragment,e),a=i(e),u(T.$$.fragment,e),Ve=i(e),z=m(e,"P",{"data-svelte-h":!0}),f(z)!=="svelte-xkmhn4"&&(z.innerHTML=ct),$e=i(e),N=m(e,"P",{"data-svelte-h":!0}),f(N)!=="svelte-1n61c2y"&&(N.innerHTML=mt),Je=i(e),G=m(e,"P",{"data-svelte-h":!0}),f(G)!=="svelte-1ijebus"&&(G.innerHTML=pt),je=i(e),L=m(e,"P",{"data-svelte-h":!0}),f(L)!=="svelte-lqldog"&&(L.textContent=ft),Pe=i(e),X=m(e,"P",{"data-svelte-h":!0}),f(X)!=="svelte-hpdejr"&&(X.innerHTML=ht),Ce=i(e),Y=m(e,"P",{"data-svelte-h":!0}),f(Y)!=="svelte-c9tslx"&&(Y.innerHTML=ut),Ue=i(e),u(H.$$.fragment,e),Ze=i(e),q=m(e,"P",{"data-svelte-h":!0}),f(q)!=="svelte-1mx0m5v"&&(q.innerHTML=gt),Ie=i(e),E=m(e,"P",{"data-svelte-h":!0}),f(E)!=="svelte-9en9f"&&(E.innerHTML=vt),We=i(e),u(S.$$.fragment,e),ke=i(e),A=m(e,"UL",{"data-svelte-h":!0}),f(A)!=="svelte-d1pn32"&&(A.innerHTML=bt),xe=i(e),u(Q.$$.fragment,e),Fe=i(e),D=m(e,"P",{"data-svelte-h":!0}),f(D)!=="svelte-8pq4o0"&&(D.textContent=_t),Be=i(e),u(O.$$.fragment,e),Re=i(e),K=m(e,"P",{"data-svelte-h":!0}),f(K)!=="svelte-sjiatm"&&(K.innerHTML=yt),ze=i(e),ee=m(e,"TABLE",{"data-svelte-h":!0}),f(ee)!=="svelte-qmb8e6"&&(ee.innerHTML=wt),Ne=i(e),u(te.$$.fragment,e),Ge=i(e),M=m(e,"DIV",{class:!0});var C=ce(M);u(oe.$$.fragment,C),Ae=i(C),fe=m(C,"P",{"data-svelte-h":!0}),f(fe)!=="svelte-163d4z6"&&(fe.innerHTML=Tt),Qe=i(C),he=m(C,"P",{"data-svelte-h":!0}),f(he)!=="svelte-o55m63"&&(he.innerHTML=Mt),De=i(C),u(k.$$.fragment,C),C.forEach(o),Le=i(e),u(ne.$$.fragment,e),Xe=i(e),V=m(e,"DIV",{class:!0});var U=ce(V);u(se.$$.fragment,U),Oe=i(U),ue=m(U,"P",{"data-svelte-h":!0}),f(ue)!=="svelte-hqhjf4"&&(ue.textContent=Vt),Ke=i(U),ge=m(U,"P",{"data-svelte-h":!0}),f(ge)!=="svelte-68lg8f"&&(ge.innerHTML=$t),et=i(U),J=m(U,"DIV",{class:!0});var Z=ce(J);u(ae.$$.fragment,Z),tt=i(Z),ve=m(Z,"P",{"data-svelte-h":!0}),f(ve)!=="svelte-1x96dji"&&(ve.innerHTML=Jt),ot=i(Z),u(x.$$.fragment,Z),nt=i(Z),u(F.$$.fragment,Z),Z.forEach(o),U.forEach(o),Ye=i(e),u(re.$$.fragment,e),He=i(e),P=m(e,"DIV",{class:!0});var W=ce(P);u(ie.$$.fragment,W),st=i(W),be=m(W,"P",{"data-svelte-h":!0}),f(be)!=="svelte-3zf12n"&&(be.innerHTML=jt),at=i(W),j=m(W,"DIV",{class:!0});var I=ce(j);u(le.$$.fragment,I),rt=i(I),_e=m(I,"P",{"data-svelte-h":!0}),f(_e)!=="svelte-100rn0"&&(_e.innerHTML=Pt),it=i(I),u(B.$$.fragment,I),lt=i(I),u(R.$$.fragment,I),I.forEach(o),W.forEach(o),qe=i(e),u(de.$$.fragment,e),Ee=i(e),ye=m(e,"P",{}),ce(ye).forEach(o),this.h()},h(){me(s,"name","hf:doc:metadata"),me(s,"content",Lt),me(M,"class","docstring border-l-2 border-t-2 pl-4 pt-3.5 border-gray-100 rounded-tl-xl mb-6 mt-8"),me(J,"class","docstring border-l-2 border-t-2 pl-4 pt-3.5 border-gray-100 rounded-tl-xl mb-6 mt-8"),me(V,"class","docstring border-l-2 border-t-2 pl-4 pt-3.5 border-gray-100 rounded-tl-xl mb-6 mt-8"),me(j,"class","docstring border-l-2 border-t-2 pl-4 pt-3.5 border-gray-100 rounded-tl-xl mb-6 mt-8"),me(P,"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,t){p(document.head,s),n(e,w,t),n(e,l,t),n(e,d,t),g(y,e,t),n(e,a,t),g(T,e,t),n(e,Ve,t),n(e,z,t),n(e,$e,t),n(e,N,t),n(e,Je,t),n(e,G,t),n(e,je,t),n(e,L,t),n(e,Pe,t),n(e,X,t),n(e,Ce,t),n(e,Y,t),n(e,Ue,t),g(H,e,t),n(e,Ze,t),n(e,q,t),n(e,Ie,t),n(e,E,t),n(e,We,t),g(S,e,t),n(e,ke,t),n(e,A,t),n(e,xe,t),g(Q,e,t),n(e,Fe,t),n(e,D,t),n(e,Be,t),g(O,e,t),n(e,Re,t),n(e,K,t),n(e,ze,t),n(e,ee,t),n(e,Ne,t),g(te,e,t),n(e,Ge,t),n(e,M,t),g(oe,M,null),p(M,Ae),p(M,fe),p(M,Qe),p(M,he),p(M,De),g(k,M,null),n(e,Le,t),g(ne,e,t),n(e,Xe,t),n(e,V,t),g(se,V,null),p(V,Oe),p(V,ue),p(V,Ke),p(V,ge),p(V,et),p(V,J),g(ae,J,null),p(J,tt),p(J,ve),p(J,ot),g(x,J,null),p(J,nt),g(F,J,null),n(e,Ye,t),g(re,e,t),n(e,He,t),n(e,P,t),g(ie,P,null),p(P,st),p(P,be),p(P,at),p(P,j),g(le,j,null),p(j,rt),p(j,_e),p(j,it),g(B,j,null),p(j,lt),g(R,j,null),n(e,qe,t),g(de,e,t),n(e,Ee,t),n(e,ye,t),Se=!0},p(e,[t]){const C={};t&2&&(C.$$scope={dirty:t,ctx:e}),k.$set(C);const U={};t&2&&(U.$$scope={dirty:t,ctx:e}),x.$set(U);const Z={};t&2&&(Z.$$scope={dirty:t,ctx:e}),F.$set(Z);const W={};t&2&&(W.$$scope={dirty:t,ctx:e}),B.$set(W);const I={};t&2&&(I.$$scope={dirty:t,ctx:e}),R.$set(I)},i(e){Se||(v(y.$$.fragment,e),v(T.$$.fragment,e),v(H.$$.fragment,e),v(S.$$.fragment,e),v(Q.$$.fragment,e),v(O.$$.fragment,e),v(te.$$.fragment,e),v(oe.$$.fragment,e),v(k.$$.fragment,e),v(ne.$$.fragment,e),v(se.$$.fragment,e),v(ae.$$.fragment,e),v(x.$$.fragment,e),v(F.$$.fragment,e),v(re.$$.fragment,e),v(ie.$$.fragment,e),v(le.$$.fragment,e),v(B.$$.fragment,e),v(R.$$.fragment,e),v(de.$$.fragment,e),Se=!0)},o(e){b(y.$$.fragment,e),b(T.$$.fragment,e),b(H.$$.fragment,e),b(S.$$.fragment,e),b(Q.$$.fragment,e),b(O.$$.fragment,e),b(te.$$.fragment,e),b(oe.$$.fragment,e),b(k.$$.fragment,e),b(ne.$$.fragment,e),b(se.$$.fragment,e),b(ae.$$.fragment,e),b(x.$$.fragment,e),b(F.$$.fragment,e),b(re.$$.fragment,e),b(ie.$$.fragment,e),b(le.$$.fragment,e),b(B.$$.fragment,e),b(R.$$.fragment,e),b(de.$$.fragment,e),Se=!1},d(e){e&&(o(w),o(l),o(d),o(a),o(Ve),o(z),o($e),o(N),o(Je),o(G),o(je),o(L),o(Pe),o(X),o(Ce),o(Y),o(Ue),o(Ze),o(q),o(Ie),o(E),o(We),o(ke),o(A),o(xe),o(Fe),o(D),o(Be),o(Re),o(K),o(ze),o(ee),o(Ne),o(Ge),o(M),o(Le),o(Xe),o(V),o(Ye),o(He),o(P),o(qe),o(Ee),o(ye)),o(s),_(y,e),_(T,e),_(H,e),_(S,e),_(Q,e),_(O,e),_(te,e),_(oe),_(k),_(ne,e),_(se),_(ae),_(x),_(F),_(re,e),_(ie),_(le),_(B),_(R),_(de,e)}}}const Lt='{"title":"Pyramid Vision Transformer V2 (PVTv2)","local":"pyramid-vision-transformer-v2-pvtv2","sections":[{"title":"Overview","local":"overview","sections":[{"title":"Abstract from the paper:","local":"abstract-from-the-paper","sections":[],"depth":3}],"depth":2},{"title":"Usage tips","local":"usage-tips","sections":[],"depth":2},{"title":"PvtV2Config","local":"transformers.PvtV2Config","sections":[],"depth":2},{"title":"PvtForImageClassification","local":"transformers.PvtV2ForImageClassification","sections":[],"depth":2},{"title":"PvtModel","local":"transformers.PvtV2Model","sections":[],"depth":2}],"depth":1}';function Xt($){return Zt(()=>{new URLSearchParams(window.location.search).get("fw")}),[]}class Dt extends It{constructor(s){super(),Wt(this,s,Xt,Gt,Ut,{})}}export{Dt as component};
