import{s as Yt,o as Lt,n as q}from"../chunks/scheduler.25b97de1.js";import{S as Ht,i as Pt,g as c,s as i,r as u,A as Qt,h as m,f as s,c as l,j as B,u as f,x as M,k as G,y as p,a,v as g,d as w,t as _,w as v}from"../chunks/index.d9030fc9.js";import{T as Ke}from"../chunks/Tip.baa67368.js";import{D as _e}from"../chunks/Docstring.ffac8efa.js";import{C as tt}from"../chunks/CodeBlock.e6cd0d95.js";import{E as et}from"../chunks/ExampleCodeBlock.22dfe688.js";import{P as qt}from"../chunks/PipelineTag.5f100392.js";import{H as ve,E as Et}from"../chunks/EditOnGithub.91d95064.js";function At(T){let t,h="Example:",r,d,b;return d=new tt({props:{code:"ZnJvbSUyMHRyYW5zZm9ybWVycyUyMGltcG9ydCUyMFN3aW52MkNvbmZpZyUyQyUyMFN3aW52Mk1vZGVsJTBBJTBBJTIzJTIwSW5pdGlhbGl6aW5nJTIwYSUyMFN3aW52MiUyMG1pY3Jvc29mdCUyRnN3aW52Mi10aW55LXBhdGNoNC13aW5kb3c4LTI1NiUyMHN0eWxlJTIwY29uZmlndXJhdGlvbiUwQWNvbmZpZ3VyYXRpb24lMjAlM0QlMjBTd2ludjJDb25maWcoKSUwQSUwQSUyMyUyMEluaXRpYWxpemluZyUyMGElMjBtb2RlbCUyMCh3aXRoJTIwcmFuZG9tJTIwd2VpZ2h0cyklMjBmcm9tJTIwdGhlJTIwbWljcm9zb2Z0JTJGc3dpbnYyLXRpbnktcGF0Y2g0LXdpbmRvdzgtMjU2JTIwc3R5bGUlMjBjb25maWd1cmF0aW9uJTBBbW9kZWwlMjAlM0QlMjBTd2ludjJNb2RlbChjb25maWd1cmF0aW9uKSUwQSUwQSUyMyUyMEFjY2Vzc2luZyUyMHRoZSUyMG1vZGVsJTIwY29uZmlndXJhdGlvbiUwQWNvbmZpZ3VyYXRpb24lMjAlM0QlMjBtb2RlbC5jb25maWc=",highlighted:`<span class="hljs-meta">&gt;&gt;&gt; </span><span class="hljs-keyword">from</span> transformers <span class="hljs-keyword">import</span> Swinv2Config, Swinv2Model

<span class="hljs-meta">&gt;&gt;&gt; </span><span class="hljs-comment"># Initializing a Swinv2 microsoft/swinv2-tiny-patch4-window8-256 style configuration</span>
<span class="hljs-meta">&gt;&gt;&gt; </span>configuration = Swinv2Config()

<span class="hljs-meta">&gt;&gt;&gt; </span><span class="hljs-comment"># Initializing a model (with random weights) from the microsoft/swinv2-tiny-patch4-window8-256 style configuration</span>
<span class="hljs-meta">&gt;&gt;&gt; </span>model = Swinv2Model(configuration)

<span class="hljs-meta">&gt;&gt;&gt; </span><span class="hljs-comment"># Accessing the model configuration</span>
<span class="hljs-meta">&gt;&gt;&gt; </span>configuration = model.config`,wrap:!1}}),{c(){t=c("p"),t.textContent=h,r=i(),u(d.$$.fragment)},l(o){t=m(o,"P",{"data-svelte-h":!0}),M(t)!=="svelte-11lpom8"&&(t.textContent=h),r=l(o),f(d.$$.fragment,o)},m(o,y){a(o,t,y),a(o,r,y),g(d,o,y),b=!0},p:q,i(o){b||(w(d.$$.fragment,o),b=!0)},o(o){_(d.$$.fragment,o),b=!1},d(o){o&&(s(t),s(r)),v(d,o)}}}function Ot(T){let t,h=`Although the recipe for forward pass needs to be defined within this function, one should call the <code>Module</code>
instance afterwards instead of this since the former takes care of running the pre and post processing steps while
the latter silently ignores them.`;return{c(){t=c("p"),t.innerHTML=h},l(r){t=m(r,"P",{"data-svelte-h":!0}),M(t)!=="svelte-fincs2"&&(t.innerHTML=h)},m(r,d){a(r,t,d)},p:q,d(r){r&&s(t)}}}function Dt(T){let t,h="Example:",r,d,b;return d=new tt({props:{code:"ZnJvbSUyMHRyYW5zZm9ybWVycyUyMGltcG9ydCUyMEF1dG9JbWFnZVByb2Nlc3NvciUyQyUyMFN3aW52Mk1vZGVsJTBBaW1wb3J0JTIwdG9yY2glMEFmcm9tJTIwZGF0YXNldHMlMjBpbXBvcnQlMjBsb2FkX2RhdGFzZXQlMEElMEFkYXRhc2V0JTIwJTNEJTIwbG9hZF9kYXRhc2V0KCUyMmh1Z2dpbmdmYWNlJTJGY2F0cy1pbWFnZSUyMiklMEFpbWFnZSUyMCUzRCUyMGRhdGFzZXQlNUIlMjJ0ZXN0JTIyJTVEJTVCJTIyaW1hZ2UlMjIlNUQlNUIwJTVEJTBBJTBBaW1hZ2VfcHJvY2Vzc29yJTIwJTNEJTIwQXV0b0ltYWdlUHJvY2Vzc29yLmZyb21fcHJldHJhaW5lZCglMjJtaWNyb3NvZnQlMkZzd2ludjItdGlueS1wYXRjaDQtd2luZG93OC0yNTYlMjIpJTBBbW9kZWwlMjAlM0QlMjBTd2ludjJNb2RlbC5mcm9tX3ByZXRyYWluZWQoJTIybWljcm9zb2Z0JTJGc3dpbnYyLXRpbnktcGF0Y2g0LXdpbmRvdzgtMjU2JTIyKSUwQSUwQWlucHV0cyUyMCUzRCUyMGltYWdlX3Byb2Nlc3NvcihpbWFnZSUyQyUyMHJldHVybl90ZW5zb3JzJTNEJTIycHQlMjIpJTBBJTBBd2l0aCUyMHRvcmNoLm5vX2dyYWQoKSUzQSUwQSUyMCUyMCUyMCUyMG91dHB1dHMlMjAlM0QlMjBtb2RlbCgqKmlucHV0cyklMEElMEFsYXN0X2hpZGRlbl9zdGF0ZXMlMjAlM0QlMjBvdXRwdXRzLmxhc3RfaGlkZGVuX3N0YXRlJTBBbGlzdChsYXN0X2hpZGRlbl9zdGF0ZXMuc2hhcGUp",highlighted:`<span class="hljs-meta">&gt;&gt;&gt; </span><span class="hljs-keyword">from</span> transformers <span class="hljs-keyword">import</span> AutoImageProcessor, Swinv2Model
<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;microsoft/swinv2-tiny-patch4-window8-256&quot;</span>)
<span class="hljs-meta">&gt;&gt;&gt; </span>model = Swinv2Model.from_pretrained(<span class="hljs-string">&quot;microsoft/swinv2-tiny-patch4-window8-256&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">64</span>, <span class="hljs-number">768</span>]`,wrap:!1}}),{c(){t=c("p"),t.textContent=h,r=i(),u(d.$$.fragment)},l(o){t=m(o,"P",{"data-svelte-h":!0}),M(t)!=="svelte-11lpom8"&&(t.textContent=h),r=l(o),f(d.$$.fragment,o)},m(o,y){a(o,t,y),a(o,r,y),g(d,o,y),b=!0},p:q,i(o){b||(w(d.$$.fragment,o),b=!0)},o(o){_(d.$$.fragment,o),b=!1},d(o){o&&(s(t),s(r)),v(d,o)}}}function Kt(T){let t,h=`Note that we provide a script to pre-train this model on custom data in our <a href="https://github.com/huggingface/transformers/tree/main/examples/pytorch/image-pretraining" rel="nofollow">examples
directory</a>.`;return{c(){t=c("p"),t.innerHTML=h},l(r){t=m(r,"P",{"data-svelte-h":!0}),M(t)!=="svelte-7i3y9o"&&(t.innerHTML=h)},m(r,d){a(r,t,d)},p:q,d(r){r&&s(t)}}}function en(T){let t,h=`Although the recipe for forward pass needs to be defined within this function, one should call the <code>Module</code>
instance afterwards instead of this since the former takes care of running the pre and post processing steps while
the latter silently ignores them.`;return{c(){t=c("p"),t.innerHTML=h},l(r){t=m(r,"P",{"data-svelte-h":!0}),M(t)!=="svelte-fincs2"&&(t.innerHTML=h)},m(r,d){a(r,t,d)},p:q,d(r){r&&s(t)}}}function tn(T){let t,h="Examples:",r,d,b;return d=new tt({props:{code:"ZnJvbSUyMHRyYW5zZm9ybWVycyUyMGltcG9ydCUyMEF1dG9JbWFnZVByb2Nlc3NvciUyQyUyMFN3aW52MkZvck1hc2tlZEltYWdlTW9kZWxpbmclMEFpbXBvcnQlMjB0b3JjaCUwQWZyb20lMjBQSUwlMjBpbXBvcnQlMjBJbWFnZSUwQWltcG9ydCUyMHJlcXVlc3RzJTBBJTBBdXJsJTIwJTNEJTIwJTIyaHR0cCUzQSUyRiUyRmltYWdlcy5jb2NvZGF0YXNldC5vcmclMkZ2YWwyMDE3JTJGMDAwMDAwMDM5NzY5LmpwZyUyMiUwQWltYWdlJTIwJTNEJTIwSW1hZ2Uub3BlbihyZXF1ZXN0cy5nZXQodXJsJTJDJTIwc3RyZWFtJTNEVHJ1ZSkucmF3KSUwQSUwQWltYWdlX3Byb2Nlc3NvciUyMCUzRCUyMEF1dG9JbWFnZVByb2Nlc3Nvci5mcm9tX3ByZXRyYWluZWQoJTIybWljcm9zb2Z0JTJGc3dpbnYyLXRpbnktcGF0Y2g0LXdpbmRvdzgtMjU2JTIyKSUwQW1vZGVsJTIwJTNEJTIwU3dpbnYyRm9yTWFza2VkSW1hZ2VNb2RlbGluZy5mcm9tX3ByZXRyYWluZWQoJTIybWljcm9zb2Z0JTJGc3dpbnYyLXRpbnktcGF0Y2g0LXdpbmRvdzgtMjU2JTIyKSUwQSUwQW51bV9wYXRjaGVzJTIwJTNEJTIwKG1vZGVsLmNvbmZpZy5pbWFnZV9zaXplJTIwJTJGJTJGJTIwbW9kZWwuY29uZmlnLnBhdGNoX3NpemUpJTIwKiolMjAyJTBBcGl4ZWxfdmFsdWVzJTIwJTNEJTIwaW1hZ2VfcHJvY2Vzc29yKGltYWdlcyUzRGltYWdlJTJDJTIwcmV0dXJuX3RlbnNvcnMlM0QlMjJwdCUyMikucGl4ZWxfdmFsdWVzJTBBJTIzJTIwY3JlYXRlJTIwcmFuZG9tJTIwYm9vbGVhbiUyMG1hc2slMjBvZiUyMHNoYXBlJTIwKGJhdGNoX3NpemUlMkMlMjBudW1fcGF0Y2hlcyklMEFib29sX21hc2tlZF9wb3MlMjAlM0QlMjB0b3JjaC5yYW5kaW50KGxvdyUzRDAlMkMlMjBoaWdoJTNEMiUyQyUyMHNpemUlM0QoMSUyQyUyMG51bV9wYXRjaGVzKSkuYm9vbCgpJTBBJTBBb3V0cHV0cyUyMCUzRCUyMG1vZGVsKHBpeGVsX3ZhbHVlcyUyQyUyMGJvb2xfbWFza2VkX3BvcyUzRGJvb2xfbWFza2VkX3BvcyklMEFsb3NzJTJDJTIwcmVjb25zdHJ1Y3RlZF9waXhlbF92YWx1ZXMlMjAlM0QlMjBvdXRwdXRzLmxvc3MlMkMlMjBvdXRwdXRzLnJlY29uc3RydWN0aW9uJTBBbGlzdChyZWNvbnN0cnVjdGVkX3BpeGVsX3ZhbHVlcy5zaGFwZSk=",highlighted:`<span class="hljs-meta">&gt;&gt;&gt; </span><span class="hljs-keyword">from</span> transformers <span class="hljs-keyword">import</span> AutoImageProcessor, Swinv2ForMaskedImageModeling
<span class="hljs-meta">&gt;&gt;&gt; </span><span class="hljs-keyword">import</span> torch
<span class="hljs-meta">&gt;&gt;&gt; </span><span class="hljs-keyword">from</span> PIL <span class="hljs-keyword">import</span> Image
<span class="hljs-meta">&gt;&gt;&gt; </span><span class="hljs-keyword">import</span> requests

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

<span class="hljs-meta">&gt;&gt;&gt; </span>image_processor = AutoImageProcessor.from_pretrained(<span class="hljs-string">&quot;microsoft/swinv2-tiny-patch4-window8-256&quot;</span>)
<span class="hljs-meta">&gt;&gt;&gt; </span>model = Swinv2ForMaskedImageModeling.from_pretrained(<span class="hljs-string">&quot;microsoft/swinv2-tiny-patch4-window8-256&quot;</span>)

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

<span class="hljs-meta">&gt;&gt;&gt; </span>outputs = model(pixel_values, bool_masked_pos=bool_masked_pos)
<span class="hljs-meta">&gt;&gt;&gt; </span>loss, reconstructed_pixel_values = outputs.loss, outputs.reconstruction
<span class="hljs-meta">&gt;&gt;&gt; </span><span class="hljs-built_in">list</span>(reconstructed_pixel_values.shape)
[<span class="hljs-number">1</span>, <span class="hljs-number">3</span>, <span class="hljs-number">256</span>, <span class="hljs-number">256</span>]`,wrap:!1}}),{c(){t=c("p"),t.textContent=h,r=i(),u(d.$$.fragment)},l(o){t=m(o,"P",{"data-svelte-h":!0}),M(t)!=="svelte-kvfsh7"&&(t.textContent=h),r=l(o),f(d.$$.fragment,o)},m(o,y){a(o,t,y),a(o,r,y),g(d,o,y),b=!0},p:q,i(o){b||(w(d.$$.fragment,o),b=!0)},o(o){_(d.$$.fragment,o),b=!1},d(o){o&&(s(t),s(r)),v(d,o)}}}function nn(T){let t,h=`Although the recipe for forward pass needs to be defined within this function, one should call the <code>Module</code>
instance afterwards instead of this since the former takes care of running the pre and post processing steps while
the latter silently ignores them.`;return{c(){t=c("p"),t.innerHTML=h},l(r){t=m(r,"P",{"data-svelte-h":!0}),M(t)!=="svelte-fincs2"&&(t.innerHTML=h)},m(r,d){a(r,t,d)},p:q,d(r){r&&s(t)}}}function on(T){let t,h="Example:",r,d,b;return d=new tt({props:{code:"ZnJvbSUyMHRyYW5zZm9ybWVycyUyMGltcG9ydCUyMEF1dG9JbWFnZVByb2Nlc3NvciUyQyUyMFN3aW52MkZvckltYWdlQ2xhc3NpZmljYXRpb24lMEFpbXBvcnQlMjB0b3JjaCUwQWZyb20lMjBkYXRhc2V0cyUyMGltcG9ydCUyMGxvYWRfZGF0YXNldCUwQSUwQWRhdGFzZXQlMjAlM0QlMjBsb2FkX2RhdGFzZXQoJTIyaHVnZ2luZ2ZhY2UlMkZjYXRzLWltYWdlJTIyKSUwQWltYWdlJTIwJTNEJTIwZGF0YXNldCU1QiUyMnRlc3QlMjIlNUQlNUIlMjJpbWFnZSUyMiU1RCU1QjAlNUQlMEElMEFpbWFnZV9wcm9jZXNzb3IlMjAlM0QlMjBBdXRvSW1hZ2VQcm9jZXNzb3IuZnJvbV9wcmV0cmFpbmVkKCUyMm1pY3Jvc29mdCUyRnN3aW52Mi10aW55LXBhdGNoNC13aW5kb3c4LTI1NiUyMiklMEFtb2RlbCUyMCUzRCUyMFN3aW52MkZvckltYWdlQ2xhc3NpZmljYXRpb24uZnJvbV9wcmV0cmFpbmVkKCUyMm1pY3Jvc29mdCUyRnN3aW52Mi10aW55LXBhdGNoNC13aW5kb3c4LTI1NiUyMiklMEElMEFpbnB1dHMlMjAlM0QlMjBpbWFnZV9wcm9jZXNzb3IoaW1hZ2UlMkMlMjByZXR1cm5fdGVuc29ycyUzRCUyMnB0JTIyKSUwQSUwQXdpdGglMjB0b3JjaC5ub19ncmFkKCklM0ElMEElMjAlMjAlMjAlMjBsb2dpdHMlMjAlM0QlMjBtb2RlbCgqKmlucHV0cykubG9naXRzJTBBJTBBJTIzJTIwbW9kZWwlMjBwcmVkaWN0cyUyMG9uZSUyMG9mJTIwdGhlJTIwMTAwMCUyMEltYWdlTmV0JTIwY2xhc3NlcyUwQXByZWRpY3RlZF9sYWJlbCUyMCUzRCUyMGxvZ2l0cy5hcmdtYXgoLTEpLml0ZW0oKSUwQXByaW50KG1vZGVsLmNvbmZpZy5pZDJsYWJlbCU1QnByZWRpY3RlZF9sYWJlbCU1RCk=",highlighted:`<span class="hljs-meta">&gt;&gt;&gt; </span><span class="hljs-keyword">from</span> transformers <span class="hljs-keyword">import</span> AutoImageProcessor, Swinv2ForImageClassification
<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;microsoft/swinv2-tiny-patch4-window8-256&quot;</span>)
<span class="hljs-meta">&gt;&gt;&gt; </span>model = Swinv2ForImageClassification.from_pretrained(<span class="hljs-string">&quot;microsoft/swinv2-tiny-patch4-window8-256&quot;</span>)

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

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

<span class="hljs-meta">&gt;&gt;&gt; </span><span class="hljs-comment"># model predicts one of the 1000 ImageNet classes</span>
<span class="hljs-meta">&gt;&gt;&gt; </span>predicted_label = logits.argmax(-<span class="hljs-number">1</span>).item()
<span class="hljs-meta">&gt;&gt;&gt; </span><span class="hljs-built_in">print</span>(model.config.id2label[predicted_label])
Egyptian cat`,wrap:!1}}),{c(){t=c("p"),t.textContent=h,r=i(),u(d.$$.fragment)},l(o){t=m(o,"P",{"data-svelte-h":!0}),M(t)!=="svelte-11lpom8"&&(t.textContent=h),r=l(o),f(d.$$.fragment,o)},m(o,y){a(o,t,y),a(o,r,y),g(d,o,y),b=!0},p:q,i(o){b||(w(d.$$.fragment,o),b=!0)},o(o){_(d.$$.fragment,o),b=!1},d(o){o&&(s(t),s(r)),v(d,o)}}}function sn(T){let t,h,r,d,b,o,y,Fe,E,Tt='The Swin Transformer V2 model was proposed in <a href="https://arxiv.org/abs/2111.09883" rel="nofollow">Swin Transformer V2: Scaling Up Capacity and Resolution</a> by Ze Liu, Han Hu, Yutong Lin, Zhuliang Yao, Zhenda Xie, Yixuan Wei, Jia Ning, Yue Cao, Zheng Zhang, Li Dong, Furu Wei, Baining Guo.',Je,A,$t="The abstract from the paper is the following:",Ue,O,jt="<em>Large-scale NLP models have been shown to significantly improve the performance on language tasks with no signs of saturation. They also demonstrate amazing few-shot capabilities like that of human beings. This paper aims to explore large-scale models in computer vision. We tackle three major issues in training and application of large vision models, including training instability, resolution gaps between pre-training and fine-tuning, and hunger on labelled data. Three main techniques are proposed: 1) a residual-post-norm method combined with cosine attention to improve training stability; 2) A log-spaced continuous position bias method to effectively transfer models pre-trained using low-resolution images to downstream tasks with high-resolution inputs; 3) A self-supervised pre-training method, SimMIM, to reduce the needs of vast labeled images. Through these techniques, this paper successfully trained a 3 billion-parameter Swin Transformer V2 model, which is the largest dense vision model to date, and makes it capable of training with images of up to 1,536×1,536 resolution. It set new performance records on 4 representative vision tasks, including ImageNet-V2 image classification, COCO object detection, ADE20K semantic segmentation, and Kinetics-400 video action classification. Also note our training is much more efficient than that in Google’s billion-level visual models, which consumes 40 times less labelled data and 40 times less training time.</em>",We,D,Ct=`This model was contributed by <a href="https://huggingface.co/nandwalritik" rel="nofollow">nandwalritik</a>.
The original code can be found <a href="https://github.com/microsoft/Swin-Transformer" rel="nofollow">here</a>.`,Ze,K,ze,ee,kt="A list of official Hugging Face and community (indicated by 🌎) resources to help you get started with Swin Transformer v2.",Ne,te,Be,ne,St='<li><a href="/docs/transformers/main/en/model_doc/swinv2#transformers.Swinv2ForImageClassification">Swinv2ForImageClassification</a> is supported by this <a href="https://github.com/huggingface/transformers/tree/main/examples/pytorch/image-classification" rel="nofollow">example script</a> and <a href="https://colab.research.google.com/github/huggingface/notebooks/blob/main/examples/image_classification.ipynb" rel="nofollow">notebook</a>.</li> <li>See also: <a href="../tasks/image_classification">Image classification task guide</a></li>',Ge,oe,xt="Besides that:",Xe,se,It='<li><a href="/docs/transformers/main/en/model_doc/swinv2#transformers.Swinv2ForMaskedImageModeling">Swinv2ForMaskedImageModeling</a> is supported by this <a href="https://github.com/huggingface/transformers/tree/main/examples/pytorch/image-pretraining" rel="nofollow">example script</a>.</li>',Re,ae,Ft="If you’re interested in submitting a resource to be included here, please feel free to open a Pull Request and we’ll review it! The resource should ideally demonstrate something new instead of duplicating an existing resource.",Ve,re,Ye,j,ie,nt,be,Jt=`This is the configuration class to store the configuration of a <a href="/docs/transformers/main/en/model_doc/swinv2#transformers.Swinv2Model">Swinv2Model</a>. It is used to instantiate a Swin
Transformer 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 Swin Transformer v2
<a href="https://huggingface.co/microsoft/swinv2-tiny-patch4-window8-256" rel="nofollow">microsoft/swinv2-tiny-patch4-window8-256</a>
architecture.`,ot,Me,Ut=`Configuration objects inherit from <a href="/docs/transformers/main/en/main_classes/configuration#transformers.PretrainedConfig">PretrainedConfig</a> and can be used to control the model outputs. Read the
documentation from <a href="/docs/transformers/main/en/main_classes/configuration#transformers.PretrainedConfig">PretrainedConfig</a> for more information.`,st,X,Le,le,He,F,de,at,ye,Wt=`The bare Swinv2 Model transformer outputting raw hidden-states without any specific head on top.
This model is a PyTorch <a href="https://pytorch.org/docs/stable/nn.html#torch.nn.Module" rel="nofollow">torch.nn.Module</a> sub-class. Use
it as a regular PyTorch Module and refer to the PyTorch documentation for all matter related to general usage and
behavior.`,rt,S,ce,it,Te,Zt='The <a href="/docs/transformers/main/en/model_doc/swinv2#transformers.Swinv2Model">Swinv2Model</a> forward method, overrides the <code>__call__</code> special method.',lt,R,dt,V,Pe,me,Qe,$,pe,ct,$e,zt=`Swinv2 Model with a decoder on top for masked image modeling, as proposed in
<a href="https://arxiv.org/abs/2111.09886" rel="nofollow">SimMIM</a>.`,mt,Y,pt,je,Nt=`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.`,ht,x,he,ut,Ce,Bt='The <a href="/docs/transformers/main/en/model_doc/swinv2#transformers.Swinv2ForMaskedImageModeling">Swinv2ForMaskedImageModeling</a> forward method, overrides the <code>__call__</code> special method.',ft,L,gt,H,qe,ue,Ee,C,fe,wt,ke,Gt=`Swinv2 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.`,_t,Se,Xt=`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.`,vt,I,ge,bt,xe,Rt='The <a href="/docs/transformers/main/en/model_doc/swinv2#transformers.Swinv2ForImageClassification">Swinv2ForImageClassification</a> forward method, overrides the <code>__call__</code> special method.',Mt,P,yt,Q,Ae,we,Oe,Ie,De;return b=new ve({props:{title:"Swin Transformer V2",local:"swin-transformer-v2",headingTag:"h1"}}),y=new ve({props:{title:"Overview",local:"overview",headingTag:"h2"}}),K=new ve({props:{title:"Resources",local:"resources",headingTag:"h2"}}),te=new qt({props:{pipeline:"image-classification"}}),re=new ve({props:{title:"Swinv2Config",local:"transformers.Swinv2Config",headingTag:"h2"}}),ie=new _e({props:{name:"class transformers.Swinv2Config",anchor:"transformers.Swinv2Config",parameters:[{name:"image_size",val:" = 224"},{name:"patch_size",val:" = 4"},{name:"num_channels",val:" = 3"},{name:"embed_dim",val:" = 96"},{name:"depths",val:" = [2, 2, 6, 2]"},{name:"num_heads",val:" = [3, 6, 12, 24]"},{name:"window_size",val:" = 7"},{name:"pretrained_window_sizes",val:" = [0, 0, 0, 0]"},{name:"mlp_ratio",val:" = 4.0"},{name:"qkv_bias",val:" = True"},{name:"hidden_dropout_prob",val:" = 0.0"},{name:"attention_probs_dropout_prob",val:" = 0.0"},{name:"drop_path_rate",val:" = 0.1"},{name:"hidden_act",val:" = 'gelu'"},{name:"use_absolute_embeddings",val:" = False"},{name:"initializer_range",val:" = 0.02"},{name:"layer_norm_eps",val:" = 1e-05"},{name:"encoder_stride",val:" = 32"},{name:"out_features",val:" = None"},{name:"out_indices",val:" = None"},{name:"**kwargs",val:""}],parametersDescription:[{anchor:"transformers.Swinv2Config.image_size",description:`<strong>image_size</strong> (<code>int</code>, <em>optional</em>, defaults to 224) &#x2014;
The size (resolution) of each image.`,name:"image_size"},{anchor:"transformers.Swinv2Config.patch_size",description:`<strong>patch_size</strong> (<code>int</code>, <em>optional</em>, defaults to 4) &#x2014;
The size (resolution) of each patch.`,name:"patch_size"},{anchor:"transformers.Swinv2Config.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.Swinv2Config.embed_dim",description:`<strong>embed_dim</strong> (<code>int</code>, <em>optional</em>, defaults to 96) &#x2014;
Dimensionality of patch embedding.`,name:"embed_dim"},{anchor:"transformers.Swinv2Config.depths",description:`<strong>depths</strong> (<code>list(int)</code>, <em>optional</em>, defaults to <code>[2, 2, 6, 2]</code>) &#x2014;
Depth of each layer in the Transformer encoder.`,name:"depths"},{anchor:"transformers.Swinv2Config.num_heads",description:`<strong>num_heads</strong> (<code>list(int)</code>, <em>optional</em>, defaults to <code>[3, 6, 12, 24]</code>) &#x2014;
Number of attention heads in each layer of the Transformer encoder.`,name:"num_heads"},{anchor:"transformers.Swinv2Config.window_size",description:`<strong>window_size</strong> (<code>int</code>, <em>optional</em>, defaults to 7) &#x2014;
Size of windows.`,name:"window_size"},{anchor:"transformers.Swinv2Config.pretrained_window_sizes",description:`<strong>pretrained_window_sizes</strong> (<code>list(int)</code>, <em>optional</em>, defaults to <code>[0, 0, 0, 0]</code>) &#x2014;
Size of windows during pretraining.`,name:"pretrained_window_sizes"},{anchor:"transformers.Swinv2Config.mlp_ratio",description:`<strong>mlp_ratio</strong> (<code>float</code>, <em>optional</em>, defaults to 4.0) &#x2014;
Ratio of MLP hidden dimensionality to embedding dimensionality.`,name:"mlp_ratio"},{anchor:"transformers.Swinv2Config.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.Swinv2Config.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 and encoder.`,name:"hidden_dropout_prob"},{anchor:"transformers.Swinv2Config.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.Swinv2Config.drop_path_rate",description:`<strong>drop_path_rate</strong> (<code>float</code>, <em>optional</em>, defaults to 0.1) &#x2014;
Stochastic depth rate.`,name:"drop_path_rate"},{anchor:"transformers.Swinv2Config.hidden_act",description:`<strong>hidden_act</strong> (<code>str</code> or <code>function</code>, <em>optional</em>, defaults to <code>&quot;gelu&quot;</code>) &#x2014;
The non-linear activation function (function or string) in the encoder. 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.Swinv2Config.use_absolute_embeddings",description:`<strong>use_absolute_embeddings</strong> (<code>bool</code>, <em>optional</em>, defaults to <code>False</code>) &#x2014;
Whether or not to add absolute position embeddings to the patch embeddings.`,name:"use_absolute_embeddings"},{anchor:"transformers.Swinv2Config.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.Swinv2Config.layer_norm_eps",description:`<strong>layer_norm_eps</strong> (<code>float</code>, <em>optional</em>, defaults to 1e-05) &#x2014;
The epsilon used by the layer normalization layers.`,name:"layer_norm_eps"},{anchor:"transformers.Swinv2Config.encoder_stride",description:`<strong>encoder_stride</strong> (<code>int</code>, <em>optional</em>, defaults to 32) &#x2014;
Factor to increase the spatial resolution by in the decoder head for masked image modeling.`,name:"encoder_stride"},{anchor:"transformers.Swinv2Config.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.Swinv2Config.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/swinv2/configuration_swinv2.py#L25"}}),X=new et({props:{anchor:"transformers.Swinv2Config.example",$$slots:{default:[At]},$$scope:{ctx:T}}}),le=new ve({props:{title:"Swinv2Model",local:"transformers.Swinv2Model",headingTag:"h2"}}),de=new _e({props:{name:"class transformers.Swinv2Model",anchor:"transformers.Swinv2Model",parameters:[{name:"config",val:""},{name:"add_pooling_layer",val:" = True"},{name:"use_mask_token",val:" = False"}],parametersDescription:[{anchor:"transformers.Swinv2Model.config",description:`<strong>config</strong> (<a href="/docs/transformers/main/en/model_doc/swinv2#transformers.Swinv2Config">Swinv2Config</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/swinv2/modeling_swinv2.py#L987"}}),ce=new _e({props:{name:"forward",anchor:"transformers.Swinv2Model.forward",parameters:[{name:"pixel_values",val:": Optional = None"},{name:"bool_masked_pos",val:": Optional = None"},{name:"head_mask",val:": Optional = None"},{name:"output_attentions",val:": Optional = None"},{name:"output_hidden_states",val:": Optional = None"},{name:"return_dict",val:": Optional = None"}],parametersDescription:[{anchor:"transformers.Swinv2Model.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__">ViTImageProcessor.<strong>call</strong>()</a>
for details.`,name:"pixel_values"},{anchor:"transformers.Swinv2Model.forward.head_mask",description:`<strong>head_mask</strong> (<code>torch.FloatTensor</code> of shape <code>(num_heads,)</code> or <code>(num_layers, num_heads)</code>, <em>optional</em>) &#x2014;
Mask to nullify selected heads of the self-attention modules. Mask values selected in <code>[0, 1]</code>:</p>
<ul>
<li>1 indicates the head is <strong>not masked</strong>,</li>
<li>0 indicates the head is <strong>masked</strong>.</li>
</ul>`,name:"head_mask"},{anchor:"transformers.Swinv2Model.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.Swinv2Model.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.Swinv2Model.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.Swinv2Model.forward.bool_masked_pos",description:`<strong>bool_masked_pos</strong> (<code>torch.BoolTensor</code> of shape <code>(batch_size, num_patches)</code>, <em>optional</em>) &#x2014;
Boolean masked positions. Indicates which patches are masked (1) and which aren&#x2019;t (0).`,name:"bool_masked_pos"}],source:"https://github.com/huggingface/transformers/blob/main/src/transformers/models/swinv2/modeling_swinv2.py#L1019",returnDescription:`<script context="module">export const metadata = 'undefined';<\/script>


<p>A <code>transformers.models.swinv2.modeling_swinv2.Swinv2ModelOutput</code> or a tuple of
<code>torch.FloatTensor</code> (if <code>return_dict=False</code> is passed or when <code>config.return_dict=False</code>) comprising various
elements depending on the configuration (<a
  href="/docs/transformers/main/en/model_doc/swinv2#transformers.Swinv2Config"
>Swinv2Config</a>) and inputs.</p>
<ul>
<li>
<p><strong>last_hidden_state</strong> (<code>torch.FloatTensor</code> of shape <code>(batch_size, sequence_length, hidden_size)</code>) — Sequence of hidden-states at the output of the last layer of the model.</p>
</li>
<li>
<p><strong>pooler_output</strong> (<code>torch.FloatTensor</code> of shape <code>(batch_size, hidden_size)</code>, <em>optional</em>, returned when <code>add_pooling_layer=True</code> is passed) — Average pooling of the last layer hidden-state.</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 + one for the output of each stage) of
shape <code>(batch_size, sequence_length, hidden_size)</code>.</p>
<p>Hidden-states of the model at the output of each layer plus the initial embedding outputs.</p>
</li>
<li>
<p><strong>attentions</strong> (<code>tuple(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 stage) 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>
<li>
<p><strong>reshaped_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 + one for the output of each stage) of
shape <code>(batch_size, hidden_size, height, width)</code>.</p>
<p>Hidden-states of the model at the output of each layer plus the initial embedding outputs reshaped to
include the spatial dimensions.</p>
</li>
</ul>
`,returnType:`<script context="module">export const metadata = 'undefined';<\/script>


<p><code>transformers.models.swinv2.modeling_swinv2.Swinv2ModelOutput</code> or <code>tuple(torch.FloatTensor)</code></p>
`}}),R=new Ke({props:{$$slots:{default:[Ot]},$$scope:{ctx:T}}}),V=new et({props:{anchor:"transformers.Swinv2Model.forward.example",$$slots:{default:[Dt]},$$scope:{ctx:T}}}),me=new ve({props:{title:"Swinv2ForMaskedImageModeling",local:"transformers.Swinv2ForMaskedImageModeling",headingTag:"h2"}}),pe=new _e({props:{name:"class transformers.Swinv2ForMaskedImageModeling",anchor:"transformers.Swinv2ForMaskedImageModeling",parameters:[{name:"config",val:""}],parametersDescription:[{anchor:"transformers.Swinv2ForMaskedImageModeling.config",description:`<strong>config</strong> (<a href="/docs/transformers/main/en/model_doc/swinv2#transformers.Swinv2Config">Swinv2Config</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/swinv2/modeling_swinv2.py#L1089"}}),Y=new Ke({props:{$$slots:{default:[Kt]},$$scope:{ctx:T}}}),he=new _e({props:{name:"forward",anchor:"transformers.Swinv2ForMaskedImageModeling.forward",parameters:[{name:"pixel_values",val:": Optional = None"},{name:"bool_masked_pos",val:": Optional = None"},{name:"head_mask",val:": Optional = None"},{name:"output_attentions",val:": Optional = None"},{name:"output_hidden_states",val:": Optional = None"},{name:"return_dict",val:": Optional = None"}],parametersDescription:[{anchor:"transformers.Swinv2ForMaskedImageModeling.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__">ViTImageProcessor.<strong>call</strong>()</a>
for details.`,name:"pixel_values"},{anchor:"transformers.Swinv2ForMaskedImageModeling.forward.head_mask",description:`<strong>head_mask</strong> (<code>torch.FloatTensor</code> of shape <code>(num_heads,)</code> or <code>(num_layers, num_heads)</code>, <em>optional</em>) &#x2014;
Mask to nullify selected heads of the self-attention modules. Mask values selected in <code>[0, 1]</code>:</p>
<ul>
<li>1 indicates the head is <strong>not masked</strong>,</li>
<li>0 indicates the head is <strong>masked</strong>.</li>
</ul>`,name:"head_mask"},{anchor:"transformers.Swinv2ForMaskedImageModeling.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.Swinv2ForMaskedImageModeling.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.Swinv2ForMaskedImageModeling.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.Swinv2ForMaskedImageModeling.forward.bool_masked_pos",description:`<strong>bool_masked_pos</strong> (<code>torch.BoolTensor</code> of shape <code>(batch_size, num_patches)</code>) &#x2014;
Boolean masked positions. Indicates which patches are masked (1) and which aren&#x2019;t (0).`,name:"bool_masked_pos"}],source:"https://github.com/huggingface/transformers/blob/main/src/transformers/models/swinv2/modeling_swinv2.py#L1120",returnDescription:`<script context="module">export const metadata = 'undefined';<\/script>


<p>A <code>transformers.models.swinv2.modeling_swinv2.Swinv2MaskedImageModelingOutput</code> or a tuple of
<code>torch.FloatTensor</code> (if <code>return_dict=False</code> is passed or when <code>config.return_dict=False</code>) comprising various
elements depending on the configuration (<a
  href="/docs/transformers/main/en/model_doc/swinv2#transformers.Swinv2Config"
>Swinv2Config</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>bool_masked_pos</code> is provided) — Masked image modeling (MLM) loss.</p>
</li>
<li>
<p><strong>reconstruction</strong> (<code>torch.FloatTensor</code> of shape <code>(batch_size, num_channels, height, width)</code>) — Reconstructed pixel values.</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 + one for the output of each stage) of
shape <code>(batch_size, sequence_length, hidden_size)</code>.</p>
<p>Hidden-states of the model at the output of each layer plus the initial embedding outputs.</p>
</li>
<li>
<p><strong>attentions</strong> (<code>tuple(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 stage) 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>
<li>
<p><strong>reshaped_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 + one for the output of each stage) of
shape <code>(batch_size, hidden_size, height, width)</code>.</p>
<p>Hidden-states of the model at the output of each layer plus the initial embedding outputs reshaped to
include the spatial dimensions.</p>
</li>
</ul>
`,returnType:`<script context="module">export const metadata = 'undefined';<\/script>


<p><code>transformers.models.swinv2.modeling_swinv2.Swinv2MaskedImageModelingOutput</code> or <code>tuple(torch.FloatTensor)</code></p>
`}}),L=new Ke({props:{$$slots:{default:[en]},$$scope:{ctx:T}}}),H=new et({props:{anchor:"transformers.Swinv2ForMaskedImageModeling.forward.example",$$slots:{default:[tn]},$$scope:{ctx:T}}}),ue=new ve({props:{title:"Swinv2ForImageClassification",local:"transformers.Swinv2ForImageClassification",headingTag:"h2"}}),fe=new _e({props:{name:"class transformers.Swinv2ForImageClassification",anchor:"transformers.Swinv2ForImageClassification",parameters:[{name:"config",val:""}],parametersDescription:[{anchor:"transformers.Swinv2ForImageClassification.config",description:`<strong>config</strong> (<a href="/docs/transformers/main/en/model_doc/swinv2#transformers.Swinv2Config">Swinv2Config</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/swinv2/modeling_swinv2.py#L1207"}}),ge=new _e({props:{name:"forward",anchor:"transformers.Swinv2ForImageClassification.forward",parameters:[{name:"pixel_values",val:": Optional = None"},{name:"head_mask",val:": Optional = None"},{name:"labels",val:": Optional = None"},{name:"output_attentions",val:": Optional = None"},{name:"output_hidden_states",val:": Optional = None"},{name:"return_dict",val:": Optional = None"}],parametersDescription:[{anchor:"transformers.Swinv2ForImageClassification.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__">ViTImageProcessor.<strong>call</strong>()</a>
for details.`,name:"pixel_values"},{anchor:"transformers.Swinv2ForImageClassification.forward.head_mask",description:`<strong>head_mask</strong> (<code>torch.FloatTensor</code> of shape <code>(num_heads,)</code> or <code>(num_layers, num_heads)</code>, <em>optional</em>) &#x2014;
Mask to nullify selected heads of the self-attention modules. Mask values selected in <code>[0, 1]</code>:</p>
<ul>
<li>1 indicates the head is <strong>not masked</strong>,</li>
<li>0 indicates the head is <strong>masked</strong>.</li>
</ul>`,name:"head_mask"},{anchor:"transformers.Swinv2ForImageClassification.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.Swinv2ForImageClassification.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.Swinv2ForImageClassification.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.Swinv2ForImageClassification.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/swinv2/modeling_swinv2.py#L1230",returnDescription:`<script context="module">export const metadata = 'undefined';<\/script>


<p>A <code>transformers.models.swinv2.modeling_swinv2.Swinv2ImageClassifierOutput</code> or a tuple of
<code>torch.FloatTensor</code> (if <code>return_dict=False</code> is passed or when <code>config.return_dict=False</code>) comprising various
elements depending on the configuration (<a
  href="/docs/transformers/main/en/model_doc/swinv2#transformers.Swinv2Config"
>Swinv2Config</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 + one for the output of each stage) of
shape <code>(batch_size, sequence_length, hidden_size)</code>.</p>
<p>Hidden-states of the model at the output of each layer plus the initial embedding outputs.</p>
</li>
<li>
<p><strong>attentions</strong> (<code>tuple(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 stage) 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>
<li>
<p><strong>reshaped_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 + one for the output of each stage) of
shape <code>(batch_size, hidden_size, height, width)</code>.</p>
<p>Hidden-states of the model at the output of each layer plus the initial embedding outputs reshaped to
include the spatial dimensions.</p>
</li>
</ul>
`,returnType:`<script context="module">export const metadata = 'undefined';<\/script>


<p><code>transformers.models.swinv2.modeling_swinv2.Swinv2ImageClassifierOutput</code> or <code>tuple(torch.FloatTensor)</code></p>
`}}),P=new Ke({props:{$$slots:{default:[nn]},$$scope:{ctx:T}}}),Q=new et({props:{anchor:"transformers.Swinv2ForImageClassification.forward.example",$$slots:{default:[on]},$$scope:{ctx:T}}}),we=new Et({props:{source:"https://github.com/huggingface/transformers/blob/main/docs/source/en/model_doc/swinv2.md"}}),{c(){t=c("meta"),h=i(),r=c("p"),d=i(),u(b.$$.fragment),o=i(),u(y.$$.fragment),Fe=i(),E=c("p"),E.innerHTML=Tt,Je=i(),A=c("p"),A.textContent=$t,Ue=i(),O=c("p"),O.innerHTML=jt,We=i(),D=c("p"),D.innerHTML=Ct,Ze=i(),u(K.$$.fragment),ze=i(),ee=c("p"),ee.textContent=kt,Ne=i(),u(te.$$.fragment),Be=i(),ne=c("ul"),ne.innerHTML=St,Ge=i(),oe=c("p"),oe.textContent=xt,Xe=i(),se=c("ul"),se.innerHTML=It,Re=i(),ae=c("p"),ae.textContent=Ft,Ve=i(),u(re.$$.fragment),Ye=i(),j=c("div"),u(ie.$$.fragment),nt=i(),be=c("p"),be.innerHTML=Jt,ot=i(),Me=c("p"),Me.innerHTML=Ut,st=i(),u(X.$$.fragment),Le=i(),u(le.$$.fragment),He=i(),F=c("div"),u(de.$$.fragment),at=i(),ye=c("p"),ye.innerHTML=Wt,rt=i(),S=c("div"),u(ce.$$.fragment),it=i(),Te=c("p"),Te.innerHTML=Zt,lt=i(),u(R.$$.fragment),dt=i(),u(V.$$.fragment),Pe=i(),u(me.$$.fragment),Qe=i(),$=c("div"),u(pe.$$.fragment),ct=i(),$e=c("p"),$e.innerHTML=zt,mt=i(),u(Y.$$.fragment),pt=i(),je=c("p"),je.innerHTML=Nt,ht=i(),x=c("div"),u(he.$$.fragment),ut=i(),Ce=c("p"),Ce.innerHTML=Bt,ft=i(),u(L.$$.fragment),gt=i(),u(H.$$.fragment),qe=i(),u(ue.$$.fragment),Ee=i(),C=c("div"),u(fe.$$.fragment),wt=i(),ke=c("p"),ke.textContent=Gt,_t=i(),Se=c("p"),Se.innerHTML=Xt,vt=i(),I=c("div"),u(ge.$$.fragment),bt=i(),xe=c("p"),xe.innerHTML=Rt,Mt=i(),u(P.$$.fragment),yt=i(),u(Q.$$.fragment),Ae=i(),u(we.$$.fragment),Oe=i(),Ie=c("p"),this.h()},l(e){const n=Qt("svelte-u9bgzb",document.head);t=m(n,"META",{name:!0,content:!0}),n.forEach(s),h=l(e),r=m(e,"P",{}),B(r).forEach(s),d=l(e),f(b.$$.fragment,e),o=l(e),f(y.$$.fragment,e),Fe=l(e),E=m(e,"P",{"data-svelte-h":!0}),M(E)!=="svelte-vxlvb8"&&(E.innerHTML=Tt),Je=l(e),A=m(e,"P",{"data-svelte-h":!0}),M(A)!=="svelte-vfdo9a"&&(A.textContent=$t),Ue=l(e),O=m(e,"P",{"data-svelte-h":!0}),M(O)!=="svelte-11y9zge"&&(O.innerHTML=jt),We=l(e),D=m(e,"P",{"data-svelte-h":!0}),M(D)!=="svelte-1ifw3nq"&&(D.innerHTML=Ct),Ze=l(e),f(K.$$.fragment,e),ze=l(e),ee=m(e,"P",{"data-svelte-h":!0}),M(ee)!=="svelte-1p7rh05"&&(ee.textContent=kt),Ne=l(e),f(te.$$.fragment,e),Be=l(e),ne=m(e,"UL",{"data-svelte-h":!0}),M(ne)!=="svelte-1jjmjpo"&&(ne.innerHTML=St),Ge=l(e),oe=m(e,"P",{"data-svelte-h":!0}),M(oe)!=="svelte-1k821ua"&&(oe.textContent=xt),Xe=l(e),se=m(e,"UL",{"data-svelte-h":!0}),M(se)!=="svelte-1cxkcry"&&(se.innerHTML=It),Re=l(e),ae=m(e,"P",{"data-svelte-h":!0}),M(ae)!=="svelte-1xesile"&&(ae.textContent=Ft),Ve=l(e),f(re.$$.fragment,e),Ye=l(e),j=m(e,"DIV",{class:!0});var J=B(j);f(ie.$$.fragment,J),nt=l(J),be=m(J,"P",{"data-svelte-h":!0}),M(be)!=="svelte-hnd3qk"&&(be.innerHTML=Jt),ot=l(J),Me=m(J,"P",{"data-svelte-h":!0}),M(Me)!=="svelte-o55m63"&&(Me.innerHTML=Ut),st=l(J),f(X.$$.fragment,J),J.forEach(s),Le=l(e),f(le.$$.fragment,e),He=l(e),F=m(e,"DIV",{class:!0});var N=B(F);f(de.$$.fragment,N),at=l(N),ye=m(N,"P",{"data-svelte-h":!0}),M(ye)!=="svelte-24f4e1"&&(ye.innerHTML=Wt),rt=l(N),S=m(N,"DIV",{class:!0});var U=B(S);f(ce.$$.fragment,U),it=l(U),Te=m(U,"P",{"data-svelte-h":!0}),M(Te)!=="svelte-png4t4"&&(Te.innerHTML=Zt),lt=l(U),f(R.$$.fragment,U),dt=l(U),f(V.$$.fragment,U),U.forEach(s),N.forEach(s),Pe=l(e),f(me.$$.fragment,e),Qe=l(e),$=m(e,"DIV",{class:!0});var k=B($);f(pe.$$.fragment,k),ct=l(k),$e=m(k,"P",{"data-svelte-h":!0}),M($e)!=="svelte-npirve"&&($e.innerHTML=zt),mt=l(k),f(Y.$$.fragment,k),pt=l(k),je=m(k,"P",{"data-svelte-h":!0}),M(je)!=="svelte-68lg8f"&&(je.innerHTML=Nt),ht=l(k),x=m(k,"DIV",{class:!0});var W=B(x);f(he.$$.fragment,W),ut=l(W),Ce=m(W,"P",{"data-svelte-h":!0}),M(Ce)!=="svelte-1uczwda"&&(Ce.innerHTML=Bt),ft=l(W),f(L.$$.fragment,W),gt=l(W),f(H.$$.fragment,W),W.forEach(s),k.forEach(s),qe=l(e),f(ue.$$.fragment,e),Ee=l(e),C=m(e,"DIV",{class:!0});var Z=B(C);f(fe.$$.fragment,Z),wt=l(Z),ke=m(Z,"P",{"data-svelte-h":!0}),M(ke)!=="svelte-13r27gg"&&(ke.textContent=Gt),_t=l(Z),Se=m(Z,"P",{"data-svelte-h":!0}),M(Se)!=="svelte-68lg8f"&&(Se.innerHTML=Xt),vt=l(Z),I=m(Z,"DIV",{class:!0});var z=B(I);f(ge.$$.fragment,z),bt=l(z),xe=m(z,"P",{"data-svelte-h":!0}),M(xe)!=="svelte-e8d70y"&&(xe.innerHTML=Rt),Mt=l(z),f(P.$$.fragment,z),yt=l(z),f(Q.$$.fragment,z),z.forEach(s),Z.forEach(s),Ae=l(e),f(we.$$.fragment,e),Oe=l(e),Ie=m(e,"P",{}),B(Ie).forEach(s),this.h()},h(){G(t,"name","hf:doc:metadata"),G(t,"content",an),G(j,"class","docstring border-l-2 border-t-2 pl-4 pt-3.5 border-gray-100 rounded-tl-xl mb-6 mt-8"),G(S,"class","docstring border-l-2 border-t-2 pl-4 pt-3.5 border-gray-100 rounded-tl-xl mb-6 mt-8"),G(F,"class","docstring border-l-2 border-t-2 pl-4 pt-3.5 border-gray-100 rounded-tl-xl mb-6 mt-8"),G(x,"class","docstring border-l-2 border-t-2 pl-4 pt-3.5 border-gray-100 rounded-tl-xl mb-6 mt-8"),G($,"class","docstring border-l-2 border-t-2 pl-4 pt-3.5 border-gray-100 rounded-tl-xl mb-6 mt-8"),G(I,"class","docstring border-l-2 border-t-2 pl-4 pt-3.5 border-gray-100 rounded-tl-xl mb-6 mt-8"),G(C,"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,n){p(document.head,t),a(e,h,n),a(e,r,n),a(e,d,n),g(b,e,n),a(e,o,n),g(y,e,n),a(e,Fe,n),a(e,E,n),a(e,Je,n),a(e,A,n),a(e,Ue,n),a(e,O,n),a(e,We,n),a(e,D,n),a(e,Ze,n),g(K,e,n),a(e,ze,n),a(e,ee,n),a(e,Ne,n),g(te,e,n),a(e,Be,n),a(e,ne,n),a(e,Ge,n),a(e,oe,n),a(e,Xe,n),a(e,se,n),a(e,Re,n),a(e,ae,n),a(e,Ve,n),g(re,e,n),a(e,Ye,n),a(e,j,n),g(ie,j,null),p(j,nt),p(j,be),p(j,ot),p(j,Me),p(j,st),g(X,j,null),a(e,Le,n),g(le,e,n),a(e,He,n),a(e,F,n),g(de,F,null),p(F,at),p(F,ye),p(F,rt),p(F,S),g(ce,S,null),p(S,it),p(S,Te),p(S,lt),g(R,S,null),p(S,dt),g(V,S,null),a(e,Pe,n),g(me,e,n),a(e,Qe,n),a(e,$,n),g(pe,$,null),p($,ct),p($,$e),p($,mt),g(Y,$,null),p($,pt),p($,je),p($,ht),p($,x),g(he,x,null),p(x,ut),p(x,Ce),p(x,ft),g(L,x,null),p(x,gt),g(H,x,null),a(e,qe,n),g(ue,e,n),a(e,Ee,n),a(e,C,n),g(fe,C,null),p(C,wt),p(C,ke),p(C,_t),p(C,Se),p(C,vt),p(C,I),g(ge,I,null),p(I,bt),p(I,xe),p(I,Mt),g(P,I,null),p(I,yt),g(Q,I,null),a(e,Ae,n),g(we,e,n),a(e,Oe,n),a(e,Ie,n),De=!0},p(e,[n]){const J={};n&2&&(J.$$scope={dirty:n,ctx:e}),X.$set(J);const N={};n&2&&(N.$$scope={dirty:n,ctx:e}),R.$set(N);const U={};n&2&&(U.$$scope={dirty:n,ctx:e}),V.$set(U);const k={};n&2&&(k.$$scope={dirty:n,ctx:e}),Y.$set(k);const W={};n&2&&(W.$$scope={dirty:n,ctx:e}),L.$set(W);const Z={};n&2&&(Z.$$scope={dirty:n,ctx:e}),H.$set(Z);const z={};n&2&&(z.$$scope={dirty:n,ctx:e}),P.$set(z);const Vt={};n&2&&(Vt.$$scope={dirty:n,ctx:e}),Q.$set(Vt)},i(e){De||(w(b.$$.fragment,e),w(y.$$.fragment,e),w(K.$$.fragment,e),w(te.$$.fragment,e),w(re.$$.fragment,e),w(ie.$$.fragment,e),w(X.$$.fragment,e),w(le.$$.fragment,e),w(de.$$.fragment,e),w(ce.$$.fragment,e),w(R.$$.fragment,e),w(V.$$.fragment,e),w(me.$$.fragment,e),w(pe.$$.fragment,e),w(Y.$$.fragment,e),w(he.$$.fragment,e),w(L.$$.fragment,e),w(H.$$.fragment,e),w(ue.$$.fragment,e),w(fe.$$.fragment,e),w(ge.$$.fragment,e),w(P.$$.fragment,e),w(Q.$$.fragment,e),w(we.$$.fragment,e),De=!0)},o(e){_(b.$$.fragment,e),_(y.$$.fragment,e),_(K.$$.fragment,e),_(te.$$.fragment,e),_(re.$$.fragment,e),_(ie.$$.fragment,e),_(X.$$.fragment,e),_(le.$$.fragment,e),_(de.$$.fragment,e),_(ce.$$.fragment,e),_(R.$$.fragment,e),_(V.$$.fragment,e),_(me.$$.fragment,e),_(pe.$$.fragment,e),_(Y.$$.fragment,e),_(he.$$.fragment,e),_(L.$$.fragment,e),_(H.$$.fragment,e),_(ue.$$.fragment,e),_(fe.$$.fragment,e),_(ge.$$.fragment,e),_(P.$$.fragment,e),_(Q.$$.fragment,e),_(we.$$.fragment,e),De=!1},d(e){e&&(s(h),s(r),s(d),s(o),s(Fe),s(E),s(Je),s(A),s(Ue),s(O),s(We),s(D),s(Ze),s(ze),s(ee),s(Ne),s(Be),s(ne),s(Ge),s(oe),s(Xe),s(se),s(Re),s(ae),s(Ve),s(Ye),s(j),s(Le),s(He),s(F),s(Pe),s(Qe),s($),s(qe),s(Ee),s(C),s(Ae),s(Oe),s(Ie)),s(t),v(b,e),v(y,e),v(K,e),v(te,e),v(re,e),v(ie),v(X),v(le,e),v(de),v(ce),v(R),v(V),v(me,e),v(pe),v(Y),v(he),v(L),v(H),v(ue,e),v(fe),v(ge),v(P),v(Q),v(we,e)}}}const an='{"title":"Swin Transformer V2","local":"swin-transformer-v2","sections":[{"title":"Overview","local":"overview","sections":[],"depth":2},{"title":"Resources","local":"resources","sections":[],"depth":2},{"title":"Swinv2Config","local":"transformers.Swinv2Config","sections":[],"depth":2},{"title":"Swinv2Model","local":"transformers.Swinv2Model","sections":[],"depth":2},{"title":"Swinv2ForMaskedImageModeling","local":"transformers.Swinv2ForMaskedImageModeling","sections":[],"depth":2},{"title":"Swinv2ForImageClassification","local":"transformers.Swinv2ForImageClassification","sections":[],"depth":2}],"depth":1}';function rn(T){return Lt(()=>{new URLSearchParams(window.location.search).get("fw")}),[]}class gn extends Ht{constructor(t){super(),Pt(this,t,rn,sn,Yt,{})}}export{gn as component};
