import{s as ko,o as Zo,n as ae}from"../chunks/scheduler.9bc65507.js";import{S as Io,i as Wo,g as n,s as i,u as b,A as zo,h as r,f as t,c,j as _,v,y as f,k as h,o as s,a as m,w as y,d as M,t as w,x as F}from"../chunks/index.78c82d43.js";import{T as Ft}from"../chunks/Tip.87d55b76.js";import{D as Ce}from"../chunks/Docstring.f3d04bd2.js";import{C as Nt}from"../chunks/CodeBlock.48618ec2.js";import{I as Ye}from"../chunks/IconCopyLink.bedaa44d.js";import{E as $t}from"../chunks/ExampleCodeBlock.872b014d.js";function Jo(N){let o,g="Example:",d,p,u;return p=new Nt({props:{code:"ZnJvbSUyMHRyYW5zZm9ybWVycyUyMGltcG9ydCUyMEZvY2FsTmV0Q29uZmlnJTJDJTIwRm9jYWxOZXRNb2RlbCUwQSUwQSUyMyUyMEluaXRpYWxpemluZyUyMGElMjBGb2NhbE5ldCUyMG1pY3Jvc29mdCUyRmZvY2FsbmV0LXRpbnklMjBzdHlsZSUyMGNvbmZpZ3VyYXRpb24lMEFjb25maWd1cmF0aW9uJTIwJTNEJTIwRm9jYWxOZXRDb25maWcoKSUwQSUwQSUyMyUyMEluaXRpYWxpemluZyUyMGElMjBtb2RlbCUyMCh3aXRoJTIwcmFuZG9tJTIwd2VpZ2h0cyklMjBmcm9tJTIwdGhlJTIwbWljcm9zb2Z0JTJGZm9jYWxuZXQtdGlueSUyMHN0eWxlJTIwY29uZmlndXJhdGlvbiUwQW1vZGVsJTIwJTNEJTIwRm9jYWxOZXRNb2RlbChjb25maWd1cmF0aW9uKSUwQSUwQSUyMyUyMEFjY2Vzc2luZyUyMHRoZSUyMG1vZGVsJTIwY29uZmlndXJhdGlvbiUwQWNvbmZpZ3VyYXRpb24lMjAlM0QlMjBtb2RlbC5jb25maWc=",highlighted:`<span class="hljs-meta">&gt;&gt;&gt; </span><span class="hljs-keyword">from</span> transformers <span class="hljs-keyword">import</span> FocalNetConfig, FocalNetModel

<span class="hljs-meta">&gt;&gt;&gt; </span><span class="hljs-comment"># Initializing a FocalNet microsoft/focalnet-tiny style configuration</span>
<span class="hljs-meta">&gt;&gt;&gt; </span>configuration = FocalNetConfig()

<span class="hljs-meta">&gt;&gt;&gt; </span><span class="hljs-comment"># Initializing a model (with random weights) from the microsoft/focalnet-tiny style configuration</span>
<span class="hljs-meta">&gt;&gt;&gt; </span>model = FocalNetModel(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`}}),{c(){o=n("p"),o.textContent=g,d=i(),b(p.$$.fragment)},l(a){o=r(a,"P",{"data-svelte-h":!0}),f(o)!=="svelte-11lpom8"&&(o.textContent=g),d=c(a),v(p.$$.fragment,a)},m(a,$){m(a,o,$),m(a,d,$),y(p,a,$),u=!0},p:ae,i(a){u||(M(p.$$.fragment,a),u=!0)},o(a){w(p.$$.fragment,a),u=!1},d(a){a&&(t(o),t(d)),F(p,a)}}}function Go(N){let o,g=`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(){o=n("p"),o.innerHTML=g},l(d){o=r(d,"P",{"data-svelte-h":!0}),f(o)!=="svelte-fincs2"&&(o.innerHTML=g)},m(d,p){m(d,o,p)},p:ae,d(d){d&&t(o)}}}function Ro(N){let o,g="Example:",d,p,u;return p=new Nt({props:{code:"ZnJvbSUyMHRyYW5zZm9ybWVycyUyMGltcG9ydCUyMEF1dG9JbWFnZVByb2Nlc3NvciUyQyUyMEZvY2FsTmV0TW9kZWwlMEFpbXBvcnQlMjB0b3JjaCUwQWZyb20lMjBkYXRhc2V0cyUyMGltcG9ydCUyMGxvYWRfZGF0YXNldCUwQSUwQWRhdGFzZXQlMjAlM0QlMjBsb2FkX2RhdGFzZXQoJTIyaHVnZ2luZ2ZhY2UlMkZjYXRzLWltYWdlJTIyKSUwQWltYWdlJTIwJTNEJTIwZGF0YXNldCU1QiUyMnRlc3QlMjIlNUQlNUIlMjJpbWFnZSUyMiU1RCU1QjAlNUQlMEElMEFpbWFnZV9wcm9jZXNzb3IlMjAlM0QlMjBBdXRvSW1hZ2VQcm9jZXNzb3IuZnJvbV9wcmV0cmFpbmVkKCUyMm1pY3Jvc29mdCUyRmZvY2FsbmV0LXRpbnklMjIpJTBBbW9kZWwlMjAlM0QlMjBGb2NhbE5ldE1vZGVsLmZyb21fcHJldHJhaW5lZCglMjJtaWNyb3NvZnQlMkZmb2NhbG5ldC10aW55JTIyKSUwQSUwQWlucHV0cyUyMCUzRCUyMGltYWdlX3Byb2Nlc3NvcihpbWFnZSUyQyUyMHJldHVybl90ZW5zb3JzJTNEJTIycHQlMjIpJTBBJTBBd2l0aCUyMHRvcmNoLm5vX2dyYWQoKSUzQSUwQSUyMCUyMCUyMCUyMG91dHB1dHMlMjAlM0QlMjBtb2RlbCgqKmlucHV0cyklMEElMEFsYXN0X2hpZGRlbl9zdGF0ZXMlMjAlM0QlMjBvdXRwdXRzLmxhc3RfaGlkZGVuX3N0YXRlJTBBbGlzdChsYXN0X2hpZGRlbl9zdGF0ZXMuc2hhcGUp",highlighted:`<span class="hljs-meta">&gt;&gt;&gt; </span><span class="hljs-keyword">from</span> transformers <span class="hljs-keyword">import</span> AutoImageProcessor, FocalNetModel
<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/focalnet-tiny&quot;</span>)
<span class="hljs-meta">&gt;&gt;&gt; </span>model = FocalNetModel.from_pretrained(<span class="hljs-string">&quot;microsoft/focalnet-tiny&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">49</span>, <span class="hljs-number">768</span>]`}}),{c(){o=n("p"),o.textContent=g,d=i(),b(p.$$.fragment)},l(a){o=r(a,"P",{"data-svelte-h":!0}),f(o)!=="svelte-11lpom8"&&(o.textContent=g),d=c(a),v(p.$$.fragment,a)},m(a,$){m(a,o,$),m(a,d,$),y(p,a,$),u=!0},p:ae,i(a){u||(M(p.$$.fragment,a),u=!0)},o(a){w(p.$$.fragment,a),u=!1},d(a){a&&(t(o),t(d)),F(p,a)}}}function Eo(N){let o,g=`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(){o=n("p"),o.innerHTML=g},l(d){o=r(d,"P",{"data-svelte-h":!0}),f(o)!=="svelte-7i3y9o"&&(o.innerHTML=g)},m(d,p){m(d,o,p)},p:ae,d(d){d&&t(o)}}}function Bo(N){let o,g=`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(){o=n("p"),o.innerHTML=g},l(d){o=r(d,"P",{"data-svelte-h":!0}),f(o)!=="svelte-fincs2"&&(o.innerHTML=g)},m(d,p){m(d,o,p)},p:ae,d(d){d&&t(o)}}}function So(N){let o,g="Examples:",d,p,u;return p=new Nt({props:{code:"ZnJvbSUyMHRyYW5zZm9ybWVycyUyMGltcG9ydCUyMEF1dG9JbWFnZVByb2Nlc3NvciUyQyUyMEZvY2FsTmV0Q29uZmlnJTJDJTIwRm9jYWxOZXRGb3JNYXNrZWRJbWFnZU1vZGVsaW5nJTBBaW1wb3J0JTIwdG9yY2glMEFmcm9tJTIwUElMJTIwaW1wb3J0JTIwSW1hZ2UlMEFpbXBvcnQlMjByZXF1ZXN0cyUwQSUwQXVybCUyMCUzRCUyMCUyMmh0dHAlM0ElMkYlMkZpbWFnZXMuY29jb2RhdGFzZXQub3JnJTJGdmFsMjAxNyUyRjAwMDAwMDAzOTc2OS5qcGclMjIlMEFpbWFnZSUyMCUzRCUyMEltYWdlLm9wZW4ocmVxdWVzdHMuZ2V0KHVybCUyQyUyMHN0cmVhbSUzRFRydWUpLnJhdyklMEElMEFpbWFnZV9wcm9jZXNzb3IlMjAlM0QlMjBBdXRvSW1hZ2VQcm9jZXNzb3IuZnJvbV9wcmV0cmFpbmVkKCUyMm1pY3Jvc29mdCUyRmZvY2FsbmV0LWJhc2Utc2ltbWltLXdpbmRvdzYtMTkyJTIyKSUwQWNvbmZpZyUyMCUzRCUyMEZvY2FsTmV0Q29uZmlnKCklMEFtb2RlbCUyMCUzRCUyMEZvY2FsTmV0Rm9yTWFza2VkSW1hZ2VNb2RlbGluZyhjb25maWcpJTBBJTBBbnVtX3BhdGNoZXMlMjAlM0QlMjAobW9kZWwuY29uZmlnLmltYWdlX3NpemUlMjAlMkYlMkYlMjBtb2RlbC5jb25maWcucGF0Y2hfc2l6ZSklMjAqKiUyMDIlMEFwaXhlbF92YWx1ZXMlMjAlM0QlMjBpbWFnZV9wcm9jZXNzb3IoaW1hZ2VzJTNEaW1hZ2UlMkMlMjByZXR1cm5fdGVuc29ycyUzRCUyMnB0JTIyKS5waXhlbF92YWx1ZXMlMEElMjMlMjBjcmVhdGUlMjByYW5kb20lMjBib29sZWFuJTIwbWFzayUyMG9mJTIwc2hhcGUlMjAoYmF0Y2hfc2l6ZSUyQyUyMG51bV9wYXRjaGVzKSUwQWJvb2xfbWFza2VkX3BvcyUyMCUzRCUyMHRvcmNoLnJhbmRpbnQobG93JTNEMCUyQyUyMGhpZ2glM0QyJTJDJTIwc2l6ZSUzRCgxJTJDJTIwbnVtX3BhdGNoZXMpKS5ib29sKCklMEElMEFvdXRwdXRzJTIwJTNEJTIwbW9kZWwocGl4ZWxfdmFsdWVzJTJDJTIwYm9vbF9tYXNrZWRfcG9zJTNEYm9vbF9tYXNrZWRfcG9zKSUwQWxvc3MlMkMlMjByZWNvbnN0cnVjdGVkX3BpeGVsX3ZhbHVlcyUyMCUzRCUyMG91dHB1dHMubG9zcyUyQyUyMG91dHB1dHMubG9naXRzJTBBbGlzdChyZWNvbnN0cnVjdGVkX3BpeGVsX3ZhbHVlcy5zaGFwZSk=",highlighted:`<span class="hljs-meta">&gt;&gt;&gt; </span><span class="hljs-keyword">from</span> transformers <span class="hljs-keyword">import</span> AutoImageProcessor, FocalNetConfig, FocalNetForMaskedImageModeling
<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/focalnet-base-simmim-window6-192&quot;</span>)
<span class="hljs-meta">&gt;&gt;&gt; </span>config = FocalNetConfig()
<span class="hljs-meta">&gt;&gt;&gt; </span>model = FocalNetForMaskedImageModeling(config)

<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.logits
<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">192</span>, <span class="hljs-number">192</span>]`}}),{c(){o=n("p"),o.textContent=g,d=i(),b(p.$$.fragment)},l(a){o=r(a,"P",{"data-svelte-h":!0}),f(o)!=="svelte-kvfsh7"&&(o.textContent=g),d=c(a),v(p.$$.fragment,a)},m(a,$){m(a,o,$),m(a,d,$),y(p,a,$),u=!0},p:ae,i(a){u||(M(p.$$.fragment,a),u=!0)},o(a){w(p.$$.fragment,a),u=!1},d(a){a&&(t(o),t(d)),F(p,a)}}}function Vo(N){let o,g=`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(){o=n("p"),o.innerHTML=g},l(d){o=r(d,"P",{"data-svelte-h":!0}),f(o)!=="svelte-fincs2"&&(o.innerHTML=g)},m(d,p){m(d,o,p)},p:ae,d(d){d&&t(o)}}}function Xo(N){let o,g="Example:",d,p,u;return p=new Nt({props:{code:"ZnJvbSUyMHRyYW5zZm9ybWVycyUyMGltcG9ydCUyMEF1dG9JbWFnZVByb2Nlc3NvciUyQyUyMEZvY2FsTmV0Rm9ySW1hZ2VDbGFzc2lmaWNhdGlvbiUwQWltcG9ydCUyMHRvcmNoJTBBZnJvbSUyMGRhdGFzZXRzJTIwaW1wb3J0JTIwbG9hZF9kYXRhc2V0JTBBJTBBZGF0YXNldCUyMCUzRCUyMGxvYWRfZGF0YXNldCglMjJodWdnaW5nZmFjZSUyRmNhdHMtaW1hZ2UlMjIpJTBBaW1hZ2UlMjAlM0QlMjBkYXRhc2V0JTVCJTIydGVzdCUyMiU1RCU1QiUyMmltYWdlJTIyJTVEJTVCMCU1RCUwQSUwQWltYWdlX3Byb2Nlc3NvciUyMCUzRCUyMEF1dG9JbWFnZVByb2Nlc3Nvci5mcm9tX3ByZXRyYWluZWQoJTIybWljcm9zb2Z0JTJGZm9jYWxuZXQtdGlueSUyMiklMEFtb2RlbCUyMCUzRCUyMEZvY2FsTmV0Rm9ySW1hZ2VDbGFzc2lmaWNhdGlvbi5mcm9tX3ByZXRyYWluZWQoJTIybWljcm9zb2Z0JTJGZm9jYWxuZXQtdGlueSUyMiklMEElMEFpbnB1dHMlMjAlM0QlMjBpbWFnZV9wcm9jZXNzb3IoaW1hZ2UlMkMlMjByZXR1cm5fdGVuc29ycyUzRCUyMnB0JTIyKSUwQSUwQXdpdGglMjB0b3JjaC5ub19ncmFkKCklM0ElMEElMjAlMjAlMjAlMjBsb2dpdHMlMjAlM0QlMjBtb2RlbCgqKmlucHV0cykubG9naXRzJTBBJTBBJTIzJTIwbW9kZWwlMjBwcmVkaWN0cyUyMG9uZSUyMG9mJTIwdGhlJTIwMTAwMCUyMEltYWdlTmV0JTIwY2xhc3NlcyUwQXByZWRpY3RlZF9sYWJlbCUyMCUzRCUyMGxvZ2l0cy5hcmdtYXgoLTEpLml0ZW0oKSUwQXByaW50KG1vZGVsLmNvbmZpZy5pZDJsYWJlbCU1QnByZWRpY3RlZF9sYWJlbCU1RCk=",highlighted:`<span class="hljs-meta">&gt;&gt;&gt; </span><span class="hljs-keyword">from</span> transformers <span class="hljs-keyword">import</span> AutoImageProcessor, FocalNetForImageClassification
<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/focalnet-tiny&quot;</span>)
<span class="hljs-meta">&gt;&gt;&gt; </span>model = FocalNetForImageClassification.from_pretrained(<span class="hljs-string">&quot;microsoft/focalnet-tiny&quot;</span>)

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

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

<span class="hljs-meta">&gt;&gt;&gt; </span><span class="hljs-comment"># model predicts one of the 1000 ImageNet classes</span>
<span class="hljs-meta">&gt;&gt;&gt; </span>predicted_label = logits.argmax(-<span class="hljs-number">1</span>).item()
<span class="hljs-meta">&gt;&gt;&gt; </span><span class="hljs-built_in">print</span>(model.config.id2label[predicted_label])
tabby, tabby cat`}}),{c(){o=n("p"),o.textContent=g,d=i(),b(p.$$.fragment)},l(a){o=r(a,"P",{"data-svelte-h":!0}),f(o)!=="svelte-11lpom8"&&(o.textContent=g),d=c(a),v(p.$$.fragment,a)},m(a,$){m(a,o,$),m(a,d,$),y(p,a,$),u=!0},p:ae,i(a){u||(M(p.$$.fragment,a),u=!0)},o(a){w(p.$$.fragment,a),u=!1},d(a){a&&(t(o),t(d)),F(p,a)}}}function Po(N){let o,g,d,p,u,a,$,se,Ct,Te,eo="FocalNet",at,W,E,He,ne,Tt,je,to="Overview",st,re,oo=`The FocalNet model was proposed in <a href="https://arxiv.org/abs/2203.11926" rel="nofollow">Focal Modulation Networks</a> by Jianwei Yang, Chunyuan Li, Xiyang Dai, Lu Yuan, Jianfeng Gao.
FocalNets completely replace self-attention (used in models like <a href="vit">ViT</a> and <a href="swin">Swin</a>) by a focal modulation mechanism for modeling token interactions in vision.
The authors claim that FocalNets outperform self-attention based models with similar computational costs on the tasks of image classification, object detection, and segmentation.`,nt,le,ao="The abstract from the paper is the following:",rt,ie,so=`<em>We propose focal modulation networks (FocalNets in short), where self-attention (SA) is completely replaced by a focal modulation mechanism for modeling token interactions in vision. Focal modulation comprises three components: (i) hierarchical contextualization, implemented using a stack of depth-wise convolutional layers, to encode visual contexts from short to long ranges, (ii) gated aggregation to selectively gather contexts for each query token based on its
content, and (iii) element-wise modulation or affine transformation to inject the aggregated context into the query. Extensive experiments show FocalNets outperform the state-of-the-art SA counterparts (e.g., Swin and Focal Transformers) with similar computational costs on the tasks of image classification, object detection, and segmentation. Specifically, FocalNets with tiny and base size achieve 82.3% and 83.9% top-1 accuracy on ImageNet-1K. After pretrained on ImageNet-22K in 224 resolution, it attains 86.5% and 87.3% top-1 accuracy when finetuned with resolution 224 and 384, respectively. When transferred to downstream tasks, FocalNets exhibit clear superiority. For object detection with Mask R-CNN, FocalNet base trained with 1\\times outperforms the Swin counterpart by 2.1 points and already surpasses Swin trained with 3\\times schedule (49.0 v.s. 48.5). For semantic segmentation with UPerNet, FocalNet base at single-scale outperforms Swin by 2.4, and beats Swin at multi-scale (50.5 v.s. 49.7). Using large FocalNet and Mask2former, we achieve 58.5 mIoU for ADE20K semantic segmentation, and 57.9 PQ for COCO Panoptic Segmentation. Using huge FocalNet and DINO, we achieved 64.3 and 64.4 mAP on COCO minival and test-dev, respectively, establishing new SoTA on top of much larger attention-based models like Swinv2-G and BEIT-3.</em>`,lt,ce,no="Tips:",it,de,ro='<li>One can use the <a href="/docs/transformers/v4.33.3/en/model_doc/auto#transformers.AutoImageProcessor">AutoImageProcessor</a> class to prepare images for the model.</li>',ct,me,lo=`This model was contributed by <a href="https://huggingface.co/nielsr" rel="nofollow">nielsr</a>.
The original code can be found <a href="https://github.com/microsoft/FocalNet" rel="nofollow">here</a>.`,dt,z,B,Ae,pe,jt,xe,io="FocalNetConfig",mt,T,he,xt,Ue,co=`This is the configuration class to store the configuration of a <a href="/docs/transformers/v4.33.3/en/model_doc/focalnet#transformers.FocalNetModel">FocalNetModel</a>. It is used to instantiate a
FocalNet 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 FocalNet
<a href="https://huggingface.co/microsoft/focalnet-tiny" rel="nofollow">microsoft/focalnet-tiny</a> architecture.`,Ut,ke,mo=`Configuration objects inherit from <a href="/docs/transformers/v4.33.3/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/v4.33.3/en/main_classes/configuration#transformers.PretrainedConfig">PretrainedConfig</a> for more information.`,kt,S,pt,J,V,Qe,fe,Zt,Ze,po="FocalNetModel",ht,I,ue,It,Ie,ho=`The bare FocalNet Model 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.`,Wt,x,ge,zt,We,fo='The <a href="/docs/transformers/v4.33.3/en/model_doc/focalnet#transformers.FocalNetModel">FocalNetModel</a> forward method, overrides the <code>__call__</code> special method.',Jt,X,Gt,P,ft,G,Y,Le,_e,Rt,ze,uo="FocalNetForMaskedImageModeling",ut,C,be,Et,Je,go="FocalNet Model with a decoder on top for masked image modeling.",Bt,Ge,_o='This follows the same implementation as in <a href="https://arxiv.org/abs/2111.09886" rel="nofollow">SimMIM</a>.',St,H,Vt,Re,bo=`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.`,Xt,U,ve,Pt,Ee,vo='The <a href="/docs/transformers/v4.33.3/en/model_doc/focalnet#transformers.FocalNetForMaskedImageModeling">FocalNetForMaskedImageModeling</a> forward method, overrides the <code>__call__</code> special method.',Yt,A,Ht,Q,gt,R,L,qe,ye,At,Be,yo="FocalNetForImageClassification",_t,j,Me,Qt,Se,Mo=`FocalNet Model with an image classification head on top (a linear layer on top of the pooled output) e.g. for
ImageNet.`,Lt,Ve,wo=`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.`,qt,k,we,Ot,Xe,Fo='The <a href="/docs/transformers/v4.33.3/en/model_doc/focalnet#transformers.FocalNetForImageClassification">FocalNetForImageClassification</a> forward method, overrides the <code>__call__</code> special method.',Dt,q,Kt,O,bt,Oe,vt;return se=new Ye({}),ne=new Ye({}),pe=new Ye({}),he=new Ce({props:{name:"class transformers.FocalNetConfig",anchor:"transformers.FocalNetConfig",parameters:[{name:"image_size",val:" = 224"},{name:"patch_size",val:" = 4"},{name:"num_channels",val:" = 3"},{name:"embed_dim",val:" = 96"},{name:"use_conv_embed",val:" = False"},{name:"hidden_sizes",val:" = [192, 384, 768, 768]"},{name:"depths",val:" = [2, 2, 6, 2]"},{name:"focal_levels",val:" = [2, 2, 2, 2]"},{name:"focal_windows",val:" = [3, 3, 3, 3]"},{name:"hidden_act",val:" = 'gelu'"},{name:"mlp_ratio",val:" = 4.0"},{name:"hidden_dropout_prob",val:" = 0.0"},{name:"drop_path_rate",val:" = 0.1"},{name:"use_layerscale",val:" = False"},{name:"layerscale_value",val:" = 0.0001"},{name:"use_post_layernorm",val:" = False"},{name:"use_post_layernorm_in_modulation",val:" = False"},{name:"normalize_modulator",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.FocalNetConfig.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.FocalNetConfig.patch_size",description:`<strong>patch_size</strong> (<code>int</code>, <em>optional</em>, defaults to 4) &#x2014;
The size (resolution) of each patch in the embeddings layer.`,name:"patch_size"},{anchor:"transformers.FocalNetConfig.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.FocalNetConfig.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.FocalNetConfig.use_conv_embed",description:`<strong>use_conv_embed</strong> (<code>bool</code>, <em>optional</em>, defaults to <code>False</code>) &#x2014;
Whether to use convolutional embedding. The authors noted that using convolutional embedding usually
improve the performance, but it&#x2019;s not used by default.`,name:"use_conv_embed"},{anchor:"transformers.FocalNetConfig.hidden_sizes",description:`<strong>hidden_sizes</strong> (<code>List[int]</code>, <em>optional</em>, defaults to <code>[192, 384, 768, 768]</code>) &#x2014;
Dimensionality (hidden size) at each stage.`,name:"hidden_sizes"},{anchor:"transformers.FocalNetConfig.depths",description:`<strong>depths</strong> (<code>list(int)</code>, <em>optional</em>, defaults to <code>[2, 2, 6, 2]</code>) &#x2014;
Depth (number of layers) of each stage in the encoder.`,name:"depths"},{anchor:"transformers.FocalNetConfig.focal_levels",description:`<strong>focal_levels</strong> (<code>list(int)</code>, <em>optional</em>, defaults to <code>[2, 2, 2, 2]</code>) &#x2014;
Number of focal levels in each layer of the respective stages in the encoder.`,name:"focal_levels"},{anchor:"transformers.FocalNetConfig.focal_windows",description:`<strong>focal_windows</strong> (<code>list(int)</code>, <em>optional</em>, defaults to <code>[3, 3, 3, 3]</code>) &#x2014;
Focal window size in each layer of the respective stages in the encoder.`,name:"focal_windows"},{anchor:"transformers.FocalNetConfig.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.FocalNetConfig.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.FocalNetConfig.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.FocalNetConfig.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.FocalNetConfig.use_layerscale",description:`<strong>use_layerscale</strong> (<code>bool</code>, <em>optional</em>, defaults to <code>False</code>) &#x2014;
Whether to use layer scale in the encoder.`,name:"use_layerscale"},{anchor:"transformers.FocalNetConfig.layerscale_value",description:`<strong>layerscale_value</strong> (<code>float</code>, <em>optional</em>, defaults to 1e-4) &#x2014;
The initial value of the layer scale.`,name:"layerscale_value"},{anchor:"transformers.FocalNetConfig.use_post_layernorm",description:`<strong>use_post_layernorm</strong> (<code>bool</code>, <em>optional</em>, defaults to <code>False</code>) &#x2014;
Whether to use post layer normalization in the encoder.`,name:"use_post_layernorm"},{anchor:"transformers.FocalNetConfig.use_post_layernorm_in_modulation",description:`<strong>use_post_layernorm_in_modulation</strong> (<code>bool</code>, <em>optional</em>, defaults to <code>False</code>) &#x2014;
Whether to use post layer normalization in the modulation layer.`,name:"use_post_layernorm_in_modulation"},{anchor:"transformers.FocalNetConfig.normalize_modulator",description:`<strong>normalize_modulator</strong> (<code>bool</code>, <em>optional</em>, defaults to <code>False</code>) &#x2014;
Whether to normalize the modulator.`,name:"normalize_modulator"},{anchor:"transformers.FocalNetConfig.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.FocalNetConfig.layer_norm_eps",description:`<strong>layer_norm_eps</strong> (<code>float</code>, <em>optional</em>, defaults to 1e-5) &#x2014;
The epsilon used by the layer normalization layers.`,name:"layer_norm_eps"},{anchor:"transformers.FocalNetConfig.encoder_stride",description:`<strong>encoder_stride</strong> (<code>int</code>, <code>optional</code>, defaults to 32) &#x2014;
Factor to increase the spatial resolution by in the decoder head for masked image modeling.`,name:"encoder_stride"},{anchor:"transformers.FocalNetConfig.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.FocalNetConfig.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/v4.33.3/src/transformers/models/focalnet/configuration_focalnet.py#L29"}}),S=new $t({props:{anchor:"transformers.FocalNetConfig.example",$$slots:{default:[Jo]},$$scope:{ctx:N}}}),fe=new Ye({}),ue=new Ce({props:{name:"class transformers.FocalNetModel",anchor:"transformers.FocalNetModel",parameters:[{name:"config",val:""},{name:"add_pooling_layer",val:" = True"},{name:"use_mask_token",val:" = False"}],parametersDescription:[{anchor:"transformers.FocalNetModel.config",description:`<strong>config</strong> (<a href="/docs/transformers/v4.33.3/en/model_doc/focalnet#transformers.FocalNetConfig">FocalNetConfig</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/v4.33.3/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/v4.33.3/src/transformers/models/focalnet/modeling_focalnet.py#L696"}}),ge=new Ce({props:{name:"forward",anchor:"transformers.FocalNetModel.forward",parameters:[{name:"pixel_values",val:": typing.Optional[torch.FloatTensor] = None"},{name:"bool_masked_pos",val:": typing.Optional[torch.BoolTensor] = None"},{name:"output_hidden_states",val:": typing.Optional[bool] = None"},{name:"return_dict",val:": typing.Optional[bool] = None"}],parametersDescription:[{anchor:"transformers.FocalNetModel.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/v4.33.3/en/model_doc/auto#transformers.AutoImageProcessor">AutoImageProcessor</a>. See
<code>AutoImageProcessor.__call__()</code> for details.`,name:"pixel_values"},{anchor:"transformers.FocalNetModel.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.FocalNetModel.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/v4.33.3/en/main_classes/output#transformers.utils.ModelOutput">ModelOutput</a> instead of a plain tuple.`,name:"return_dict"},{anchor:"transformers.FocalNetModel.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/v4.33.3/src/transformers/models/focalnet/modeling_focalnet.py#L715",returnDescription:`
<p>A <code>transformers.models.focalnet.modeling_focalnet.FocalNetModelOutput</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/v4.33.3/en/model_doc/focalnet#transformers.FocalNetConfig"
>FocalNetConfig</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>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:`
<p><code>transformers.models.focalnet.modeling_focalnet.FocalNetModelOutput</code> or <code>tuple(torch.FloatTensor)</code></p>
`}}),X=new Ft({props:{$$slots:{default:[Go]},$$scope:{ctx:N}}}),P=new $t({props:{anchor:"transformers.FocalNetModel.forward.example",$$slots:{default:[Ro]},$$scope:{ctx:N}}}),_e=new Ye({}),be=new Ce({props:{name:"class transformers.FocalNetForMaskedImageModeling",anchor:"transformers.FocalNetForMaskedImageModeling",parameters:[{name:"config",val:""}],parametersDescription:[{anchor:"transformers.FocalNetForMaskedImageModeling.config",description:`<strong>config</strong> (<a href="/docs/transformers/v4.33.3/en/model_doc/focalnet#transformers.FocalNetConfig">FocalNetConfig</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/v4.33.3/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/v4.33.3/src/transformers/models/focalnet/modeling_focalnet.py#L786"}}),H=new Ft({props:{$$slots:{default:[Eo]},$$scope:{ctx:N}}}),ve=new Ce({props:{name:"forward",anchor:"transformers.FocalNetForMaskedImageModeling.forward",parameters:[{name:"pixel_values",val:": typing.Optional[torch.FloatTensor] = None"},{name:"bool_masked_pos",val:": typing.Optional[torch.BoolTensor] = None"},{name:"output_hidden_states",val:": typing.Optional[bool] = None"},{name:"return_dict",val:": typing.Optional[bool] = None"}],parametersDescription:[{anchor:"transformers.FocalNetForMaskedImageModeling.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/v4.33.3/en/model_doc/auto#transformers.AutoImageProcessor">AutoImageProcessor</a>. See
<code>AutoImageProcessor.__call__()</code> for details.`,name:"pixel_values"},{anchor:"transformers.FocalNetForMaskedImageModeling.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.FocalNetForMaskedImageModeling.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/v4.33.3/en/main_classes/output#transformers.utils.ModelOutput">ModelOutput</a> instead of a plain tuple.`,name:"return_dict"},{anchor:"transformers.FocalNetForMaskedImageModeling.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/v4.33.3/src/transformers/models/focalnet/modeling_focalnet.py#L804",returnDescription:`
<p>A <code>transformers.models.focalnet.modeling_focalnet.FocalNetMaskedImageModelingOutput</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/v4.33.3/en/model_doc/focalnet#transformers.FocalNetConfig"
>FocalNetConfig</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>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:`
<p><code>transformers.models.focalnet.modeling_focalnet.FocalNetMaskedImageModelingOutput</code> or <code>tuple(torch.FloatTensor)</code></p>
`}}),A=new Ft({props:{$$slots:{default:[Bo]},$$scope:{ctx:N}}}),Q=new $t({props:{anchor:"transformers.FocalNetForMaskedImageModeling.forward.example",$$slots:{default:[So]},$$scope:{ctx:N}}}),ye=new Ye({}),Me=new Ce({props:{name:"class transformers.FocalNetForImageClassification",anchor:"transformers.FocalNetForImageClassification",parameters:[{name:"config",val:""}],parametersDescription:[{anchor:"transformers.FocalNetForImageClassification.config",description:`<strong>config</strong> (<a href="/docs/transformers/v4.33.3/en/model_doc/focalnet#transformers.FocalNetConfig">FocalNetConfig</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/v4.33.3/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/v4.33.3/src/transformers/models/focalnet/modeling_focalnet.py#L894"}}),we=new Ce({props:{name:"forward",anchor:"transformers.FocalNetForImageClassification.forward",parameters:[{name:"pixel_values",val:": typing.Optional[torch.FloatTensor] = None"},{name:"labels",val:": typing.Optional[torch.LongTensor] = None"},{name:"output_hidden_states",val:": typing.Optional[bool] = None"},{name:"return_dict",val:": typing.Optional[bool] = None"}],parametersDescription:[{anchor:"transformers.FocalNetForImageClassification.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/v4.33.3/en/model_doc/auto#transformers.AutoImageProcessor">AutoImageProcessor</a>. See
<code>AutoImageProcessor.__call__()</code> for details.`,name:"pixel_values"},{anchor:"transformers.FocalNetForImageClassification.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.FocalNetForImageClassification.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/v4.33.3/en/main_classes/output#transformers.utils.ModelOutput">ModelOutput</a> instead of a plain tuple.`,name:"return_dict"},{anchor:"transformers.FocalNetForImageClassification.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/v4.33.3/src/transformers/models/focalnet/modeling_focalnet.py#L910",returnDescription:`
<p>A <code>transformers.models.focalnet.modeling_focalnet.FocalNetImageClassifierOutput</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/v4.33.3/en/model_doc/focalnet#transformers.FocalNetConfig"
>FocalNetConfig</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>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:`
<p><code>transformers.models.focalnet.modeling_focalnet.FocalNetImageClassifierOutput</code> or <code>tuple(torch.FloatTensor)</code></p>
`}}),q=new Ft({props:{$$slots:{default:[Vo]},$$scope:{ctx:N}}}),O=new $t({props:{anchor:"transformers.FocalNetForImageClassification.forward.example",$$slots:{default:[Xo]},$$scope:{ctx:N}}}),{c(){o=n("meta"),g=i(),d=n("p"),p=i(),u=n("h1"),a=n("a"),$=n("span"),b(se.$$.fragment),Ct=i(),Te=n("span"),Te.textContent=eo,at=i(),W=n("h2"),E=n("a"),He=n("span"),b(ne.$$.fragment),Tt=i(),je=n("span"),je.textContent=to,st=i(),re=n("p"),re.innerHTML=oo,nt=i(),le=n("p"),le.textContent=ao,rt=i(),ie=n("p"),ie.innerHTML=so,lt=i(),ce=n("p"),ce.textContent=no,it=i(),de=n("ul"),de.innerHTML=ro,ct=i(),me=n("p"),me.innerHTML=lo,dt=i(),z=n("h2"),B=n("a"),Ae=n("span"),b(pe.$$.fragment),jt=i(),xe=n("span"),xe.textContent=io,mt=i(),T=n("div"),b(he.$$.fragment),xt=i(),Ue=n("p"),Ue.innerHTML=co,Ut=i(),ke=n("p"),ke.innerHTML=mo,kt=i(),b(S.$$.fragment),pt=i(),J=n("h2"),V=n("a"),Qe=n("span"),b(fe.$$.fragment),Zt=i(),Ze=n("span"),Ze.textContent=po,ht=i(),I=n("div"),b(ue.$$.fragment),It=i(),Ie=n("p"),Ie.innerHTML=ho,Wt=i(),x=n("div"),b(ge.$$.fragment),zt=i(),We=n("p"),We.innerHTML=fo,Jt=i(),b(X.$$.fragment),Gt=i(),b(P.$$.fragment),ft=i(),G=n("h2"),Y=n("a"),Le=n("span"),b(_e.$$.fragment),Rt=i(),ze=n("span"),ze.textContent=uo,ut=i(),C=n("div"),b(be.$$.fragment),Et=i(),Je=n("p"),Je.textContent=go,Bt=i(),Ge=n("p"),Ge.innerHTML=_o,St=i(),b(H.$$.fragment),Vt=i(),Re=n("p"),Re.innerHTML=bo,Xt=i(),U=n("div"),b(ve.$$.fragment),Pt=i(),Ee=n("p"),Ee.innerHTML=vo,Yt=i(),b(A.$$.fragment),Ht=i(),b(Q.$$.fragment),gt=i(),R=n("h2"),L=n("a"),qe=n("span"),b(ye.$$.fragment),At=i(),Be=n("span"),Be.textContent=yo,_t=i(),j=n("div"),b(Me.$$.fragment),Qt=i(),Se=n("p"),Se.textContent=Mo,Lt=i(),Ve=n("p"),Ve.innerHTML=wo,qt=i(),k=n("div"),b(we.$$.fragment),Ot=i(),Xe=n("p"),Xe.innerHTML=Fo,Dt=i(),b(q.$$.fragment),Kt=i(),b(O.$$.fragment),bt=i(),Oe=n("p"),this.h()},l(e){const l=zo("svelte-1phssyn",document.head);o=r(l,"META",{name:!0,content:!0}),l.forEach(t),g=c(e),d=r(e,"P",{}),_(d).forEach(t),p=c(e),u=r(e,"H1",{class:!0});var Fe=_(u);a=r(Fe,"A",{id:!0,class:!0,href:!0});var De=_(a);$=r(De,"SPAN",{});var Ke=_($);v(se.$$.fragment,Ke),Ke.forEach(t),De.forEach(t),Ct=c(Fe),Te=r(Fe,"SPAN",{"data-svelte-h":!0}),f(Te)!=="svelte-1mj83l9"&&(Te.textContent=eo),Fe.forEach(t),at=c(e),W=r(e,"H2",{class:!0});var $e=_(W);E=r($e,"A",{id:!0,class:!0,href:!0});var et=_(E);He=r(et,"SPAN",{});var tt=_(He);v(ne.$$.fragment,tt),tt.forEach(t),et.forEach(t),Tt=c($e),je=r($e,"SPAN",{"data-svelte-h":!0}),f(je)!=="svelte-1jsw1pg"&&(je.textContent=to),$e.forEach(t),st=c(e),re=r(e,"P",{"data-svelte-h":!0}),f(re)!=="svelte-84c53e"&&(re.innerHTML=oo),nt=c(e),le=r(e,"P",{"data-svelte-h":!0}),f(le)!=="svelte-vfdo9a"&&(le.textContent=ao),rt=c(e),ie=r(e,"P",{"data-svelte-h":!0}),f(ie)!=="svelte-1uz33aa"&&(ie.innerHTML=so),lt=c(e),ce=r(e,"P",{"data-svelte-h":!0}),f(ce)!=="svelte-axv494"&&(ce.textContent=no),it=c(e),de=r(e,"UL",{"data-svelte-h":!0}),f(de)!=="svelte-1todjce"&&(de.innerHTML=ro),ct=c(e),me=r(e,"P",{"data-svelte-h":!0}),f(me)!=="svelte-dxae3d"&&(me.innerHTML=lo),dt=c(e),z=r(e,"H2",{class:!0});var Ne=_(z);B=r(Ne,"A",{id:!0,class:!0,href:!0});var ot=_(B);Ae=r(ot,"SPAN",{});var $o=_(Ae);v(pe.$$.fragment,$o),$o.forEach(t),ot.forEach(t),jt=c(Ne),xe=r(Ne,"SPAN",{"data-svelte-h":!0}),f(xe)!=="svelte-1276cvn"&&(xe.textContent=io),Ne.forEach(t),mt=c(e),T=r(e,"DIV",{class:!0});var D=_(T);v(he.$$.fragment,D),xt=c(D),Ue=r(D,"P",{"data-svelte-h":!0}),f(Ue)!=="svelte-11rqu9t"&&(Ue.innerHTML=co),Ut=c(D),ke=r(D,"P",{"data-svelte-h":!0}),f(ke)!=="svelte-cfh5wl"&&(ke.innerHTML=mo),kt=c(D),v(S.$$.fragment,D),D.forEach(t),pt=c(e),J=r(e,"H2",{class:!0});var yt=_(J);V=r(yt,"A",{id:!0,class:!0,href:!0});var No=_(V);Qe=r(No,"SPAN",{});var Co=_(Qe);v(fe.$$.fragment,Co),Co.forEach(t),No.forEach(t),Zt=c(yt),Ze=r(yt,"SPAN",{"data-svelte-h":!0}),f(Ze)!=="svelte-hkia96"&&(Ze.textContent=po),yt.forEach(t),ht=c(e),I=r(e,"DIV",{class:!0});var Pe=_(I);v(ue.$$.fragment,Pe),It=c(Pe),Ie=r(Pe,"P",{"data-svelte-h":!0}),f(Ie)!=="svelte-9um4dr"&&(Ie.innerHTML=ho),Wt=c(Pe),x=r(Pe,"DIV",{class:!0});var K=_(x);v(ge.$$.fragment,K),zt=c(K),We=r(K,"P",{"data-svelte-h":!0}),f(We)!=="svelte-1upwbh1"&&(We.innerHTML=fo),Jt=c(K),v(X.$$.fragment,K),Gt=c(K),v(P.$$.fragment,K),K.forEach(t),Pe.forEach(t),ft=c(e),G=r(e,"H2",{class:!0});var Mt=_(G);Y=r(Mt,"A",{id:!0,class:!0,href:!0});var To=_(Y);Le=r(To,"SPAN",{});var jo=_(Le);v(_e.$$.fragment,jo),jo.forEach(t),To.forEach(t),Rt=c(Mt),ze=r(Mt,"SPAN",{"data-svelte-h":!0}),f(ze)!=="svelte-w62juh"&&(ze.textContent=uo),Mt.forEach(t),ut=c(e),C=r(e,"DIV",{class:!0});var Z=_(C);v(be.$$.fragment,Z),Et=c(Z),Je=r(Z,"P",{"data-svelte-h":!0}),f(Je)!=="svelte-1082wlw"&&(Je.textContent=go),Bt=c(Z),Ge=r(Z,"P",{"data-svelte-h":!0}),f(Ge)!=="svelte-muou64"&&(Ge.innerHTML=_o),St=c(Z),v(H.$$.fragment,Z),Vt=c(Z),Re=r(Z,"P",{"data-svelte-h":!0}),f(Re)!=="svelte-68lg8f"&&(Re.innerHTML=bo),Xt=c(Z),U=r(Z,"DIV",{class:!0});var ee=_(U);v(ve.$$.fragment,ee),Pt=c(ee),Ee=r(ee,"P",{"data-svelte-h":!0}),f(Ee)!=="svelte-xh4fm1"&&(Ee.innerHTML=vo),Yt=c(ee),v(A.$$.fragment,ee),Ht=c(ee),v(Q.$$.fragment,ee),ee.forEach(t),Z.forEach(t),gt=c(e),R=r(e,"H2",{class:!0});var wt=_(R);L=r(wt,"A",{id:!0,class:!0,href:!0});var xo=_(L);qe=r(xo,"SPAN",{});var Uo=_(qe);v(ye.$$.fragment,Uo),Uo.forEach(t),xo.forEach(t),At=c(wt),Be=r(wt,"SPAN",{"data-svelte-h":!0}),f(Be)!=="svelte-1yeij1"&&(Be.textContent=yo),wt.forEach(t),_t=c(e),j=r(e,"DIV",{class:!0});var te=_(j);v(Me.$$.fragment,te),Qt=c(te),Se=r(te,"P",{"data-svelte-h":!0}),f(Se)!=="svelte-mhgt84"&&(Se.textContent=Mo),Lt=c(te),Ve=r(te,"P",{"data-svelte-h":!0}),f(Ve)!=="svelte-68lg8f"&&(Ve.innerHTML=wo),qt=c(te),k=r(te,"DIV",{class:!0});var oe=_(k);v(we.$$.fragment,oe),Ot=c(oe),Xe=r(oe,"P",{"data-svelte-h":!0}),f(Xe)!=="svelte-bpi389"&&(Xe.innerHTML=Fo),Dt=c(oe),v(q.$$.fragment,oe),Kt=c(oe),v(O.$$.fragment,oe),oe.forEach(t),te.forEach(t),bt=c(e),Oe=r(e,"P",{}),_(Oe).forEach(t),this.h()},h(){h(o,"name","hf:doc:metadata"),h(o,"content",JSON.stringify(Yo)),h(a,"id","focalnet"),h(a,"class","header-link block pr-1.5 text-lg no-hover:hidden with-hover:absolute with-hover:p-1.5 with-hover:opacity-0 with-hover:group-hover:opacity-100 with-hover:right-full"),h(a,"href","#focalnet"),h(u,"class","relative group"),h(E,"id","overview"),h(E,"class","header-link block pr-1.5 text-lg no-hover:hidden with-hover:absolute with-hover:p-1.5 with-hover:opacity-0 with-hover:group-hover:opacity-100 with-hover:right-full"),h(E,"href","#overview"),h(W,"class","relative group"),h(B,"id","transformers.FocalNetConfig"),h(B,"class","header-link block pr-1.5 text-lg no-hover:hidden with-hover:absolute with-hover:p-1.5 with-hover:opacity-0 with-hover:group-hover:opacity-100 with-hover:right-full"),h(B,"href","#transformers.FocalNetConfig"),h(z,"class","relative group"),h(T,"class","docstring border-l-2 border-t-2 pl-4 pt-3.5 border-gray-100 rounded-tl-xl mb-6 mt-8"),h(V,"id","transformers.FocalNetModel"),h(V,"class","header-link block pr-1.5 text-lg no-hover:hidden with-hover:absolute with-hover:p-1.5 with-hover:opacity-0 with-hover:group-hover:opacity-100 with-hover:right-full"),h(V,"href","#transformers.FocalNetModel"),h(J,"class","relative group"),h(x,"class","docstring border-l-2 border-t-2 pl-4 pt-3.5 border-gray-100 rounded-tl-xl mb-6 mt-8"),h(I,"class","docstring border-l-2 border-t-2 pl-4 pt-3.5 border-gray-100 rounded-tl-xl mb-6 mt-8"),h(Y,"id","transformers.FocalNetForMaskedImageModeling"),h(Y,"class","header-link block pr-1.5 text-lg no-hover:hidden with-hover:absolute with-hover:p-1.5 with-hover:opacity-0 with-hover:group-hover:opacity-100 with-hover:right-full"),h(Y,"href","#transformers.FocalNetForMaskedImageModeling"),h(G,"class","relative group"),h(U,"class","docstring border-l-2 border-t-2 pl-4 pt-3.5 border-gray-100 rounded-tl-xl mb-6 mt-8"),h(C,"class","docstring border-l-2 border-t-2 pl-4 pt-3.5 border-gray-100 rounded-tl-xl mb-6 mt-8"),h(L,"id","transformers.FocalNetForImageClassification"),h(L,"class","header-link block pr-1.5 text-lg no-hover:hidden with-hover:absolute with-hover:p-1.5 with-hover:opacity-0 with-hover:group-hover:opacity-100 with-hover:right-full"),h(L,"href","#transformers.FocalNetForImageClassification"),h(R,"class","relative group"),h(k,"class","docstring border-l-2 border-t-2 pl-4 pt-3.5 border-gray-100 rounded-tl-xl mb-6 mt-8"),h(j,"class","docstring border-l-2 border-t-2 pl-4 pt-3.5 border-gray-100 rounded-tl-xl mb-6 mt-8")},m(e,l){s(document.head,o),m(e,g,l),m(e,d,l),m(e,p,l),m(e,u,l),s(u,a),s(a,$),y(se,$,null),s(u,Ct),s(u,Te),m(e,at,l),m(e,W,l),s(W,E),s(E,He),y(ne,He,null),s(W,Tt),s(W,je),m(e,st,l),m(e,re,l),m(e,nt,l),m(e,le,l),m(e,rt,l),m(e,ie,l),m(e,lt,l),m(e,ce,l),m(e,it,l),m(e,de,l),m(e,ct,l),m(e,me,l),m(e,dt,l),m(e,z,l),s(z,B),s(B,Ae),y(pe,Ae,null),s(z,jt),s(z,xe),m(e,mt,l),m(e,T,l),y(he,T,null),s(T,xt),s(T,Ue),s(T,Ut),s(T,ke),s(T,kt),y(S,T,null),m(e,pt,l),m(e,J,l),s(J,V),s(V,Qe),y(fe,Qe,null),s(J,Zt),s(J,Ze),m(e,ht,l),m(e,I,l),y(ue,I,null),s(I,It),s(I,Ie),s(I,Wt),s(I,x),y(ge,x,null),s(x,zt),s(x,We),s(x,Jt),y(X,x,null),s(x,Gt),y(P,x,null),m(e,ft,l),m(e,G,l),s(G,Y),s(Y,Le),y(_e,Le,null),s(G,Rt),s(G,ze),m(e,ut,l),m(e,C,l),y(be,C,null),s(C,Et),s(C,Je),s(C,Bt),s(C,Ge),s(C,St),y(H,C,null),s(C,Vt),s(C,Re),s(C,Xt),s(C,U),y(ve,U,null),s(U,Pt),s(U,Ee),s(U,Yt),y(A,U,null),s(U,Ht),y(Q,U,null),m(e,gt,l),m(e,R,l),s(R,L),s(L,qe),y(ye,qe,null),s(R,At),s(R,Be),m(e,_t,l),m(e,j,l),y(Me,j,null),s(j,Qt),s(j,Se),s(j,Lt),s(j,Ve),s(j,qt),s(j,k),y(we,k,null),s(k,Ot),s(k,Xe),s(k,Dt),y(q,k,null),s(k,Kt),y(O,k,null),m(e,bt,l),m(e,Oe,l),vt=!0},p(e,[l]){const Fe={};l&2&&(Fe.$$scope={dirty:l,ctx:e}),S.$set(Fe);const De={};l&2&&(De.$$scope={dirty:l,ctx:e}),X.$set(De);const Ke={};l&2&&(Ke.$$scope={dirty:l,ctx:e}),P.$set(Ke);const $e={};l&2&&($e.$$scope={dirty:l,ctx:e}),H.$set($e);const et={};l&2&&(et.$$scope={dirty:l,ctx:e}),A.$set(et);const tt={};l&2&&(tt.$$scope={dirty:l,ctx:e}),Q.$set(tt);const Ne={};l&2&&(Ne.$$scope={dirty:l,ctx:e}),q.$set(Ne);const ot={};l&2&&(ot.$$scope={dirty:l,ctx:e}),O.$set(ot)},i(e){vt||(M(se.$$.fragment,e),M(ne.$$.fragment,e),M(pe.$$.fragment,e),M(he.$$.fragment,e),M(S.$$.fragment,e),M(fe.$$.fragment,e),M(ue.$$.fragment,e),M(ge.$$.fragment,e),M(X.$$.fragment,e),M(P.$$.fragment,e),M(_e.$$.fragment,e),M(be.$$.fragment,e),M(H.$$.fragment,e),M(ve.$$.fragment,e),M(A.$$.fragment,e),M(Q.$$.fragment,e),M(ye.$$.fragment,e),M(Me.$$.fragment,e),M(we.$$.fragment,e),M(q.$$.fragment,e),M(O.$$.fragment,e),vt=!0)},o(e){w(se.$$.fragment,e),w(ne.$$.fragment,e),w(pe.$$.fragment,e),w(he.$$.fragment,e),w(S.$$.fragment,e),w(fe.$$.fragment,e),w(ue.$$.fragment,e),w(ge.$$.fragment,e),w(X.$$.fragment,e),w(P.$$.fragment,e),w(_e.$$.fragment,e),w(be.$$.fragment,e),w(H.$$.fragment,e),w(ve.$$.fragment,e),w(A.$$.fragment,e),w(Q.$$.fragment,e),w(ye.$$.fragment,e),w(Me.$$.fragment,e),w(we.$$.fragment,e),w(q.$$.fragment,e),w(O.$$.fragment,e),vt=!1},d(e){e&&(t(g),t(d),t(p),t(u),t(at),t(W),t(st),t(re),t(nt),t(le),t(rt),t(ie),t(lt),t(ce),t(it),t(de),t(ct),t(me),t(dt),t(z),t(mt),t(T),t(pt),t(J),t(ht),t(I),t(ft),t(G),t(ut),t(C),t(gt),t(R),t(_t),t(j),t(bt),t(Oe)),t(o),F(se),F(ne),F(pe),F(he),F(S),F(fe),F(ue),F(ge),F(X),F(P),F(_e),F(be),F(H),F(ve),F(A),F(Q),F(ye),F(Me),F(we),F(q),F(O)}}}const Yo={local:"focalnet",sections:[{local:"overview",title:"Overview"},{local:"transformers.FocalNetConfig",title:"FocalNetConfig"},{local:"transformers.FocalNetModel",title:"FocalNetModel"},{local:"transformers.FocalNetForMaskedImageModeling",title:"FocalNetForMaskedImageModeling"},{local:"transformers.FocalNetForImageClassification",title:"FocalNetForImageClassification"}],title:"FocalNet"};function Ho(N){return Zo(()=>{new URLSearchParams(window.location.search).get("fw")}),[]}class ea extends Io{constructor(o){super(),Wo(this,o,Ho,Po,ko,{})}}export{ea as component};
