import{s as jt,o as Ct,n as L}from"../chunks/scheduler.25b97de1.js";import{S as Ut,i as xt,g as m,s as l,r as u,A as Zt,h as p,f as n,c as i,j as G,u as g,x as F,k as V,y as d,a as c,v as _,d as b,t as M,w as y}from"../chunks/index.d9030fc9.js";import{T as Xe}from"../chunks/Tip.baa67368.js";import{D as me}from"../chunks/Docstring.ffac8efa.js";import{C as Ye}from"../chunks/CodeBlock.e6cd0d95.js";import{E as Be}from"../chunks/ExampleCodeBlock.22dfe688.js";import{H as ve,E as It}from"../chunks/EditOnGithub.91d95064.js";function kt(v){let t,f="Example:",s,r,h;return r=new Ye({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`,wrap:!1}}),{c(){t=m("p"),t.textContent=f,s=l(),u(r.$$.fragment)},l(o){t=p(o,"P",{"data-svelte-h":!0}),F(t)!=="svelte-11lpom8"&&(t.textContent=f),s=i(o),g(r.$$.fragment,o)},m(o,w){c(o,t,w),c(o,s,w),_(r,o,w),h=!0},p:L,i(o){h||(b(r.$$.fragment,o),h=!0)},o(o){M(r.$$.fragment,o),h=!1},d(o){o&&(n(t),n(s)),y(r,o)}}}function Wt(v){let t,f=`Although the recipe for forward pass needs to be defined within this function, one should call the <code>Module</code>
instance afterwards instead of this since the former takes care of running the pre and post processing steps while
the latter silently ignores them.`;return{c(){t=m("p"),t.innerHTML=f},l(s){t=p(s,"P",{"data-svelte-h":!0}),F(t)!=="svelte-fincs2"&&(t.innerHTML=f)},m(s,r){c(s,t,r)},p:L,d(s){s&&n(t)}}}function zt(v){let t,f="Example:",s,r,h;return r=new Ye({props:{code:"ZnJvbSUyMHRyYW5zZm9ybWVycyUyMGltcG9ydCUyMEF1dG9JbWFnZVByb2Nlc3NvciUyQyUyMEZvY2FsTmV0TW9kZWwlMEFpbXBvcnQlMjB0b3JjaCUwQWZyb20lMjBkYXRhc2V0cyUyMGltcG9ydCUyMGxvYWRfZGF0YXNldCUwQSUwQWRhdGFzZXQlMjAlM0QlMjBsb2FkX2RhdGFzZXQoJTIyaHVnZ2luZ2ZhY2UlMkZjYXRzLWltYWdlJTIyJTJDJTIwdHJ1c3RfcmVtb3RlX2NvZGUlM0RUcnVlKSUwQWltYWdlJTIwJTNEJTIwZGF0YXNldCU1QiUyMnRlc3QlMjIlNUQlNUIlMjJpbWFnZSUyMiU1RCU1QjAlNUQlMEElMEFpbWFnZV9wcm9jZXNzb3IlMjAlM0QlMjBBdXRvSW1hZ2VQcm9jZXNzb3IuZnJvbV9wcmV0cmFpbmVkKCUyMm1pY3Jvc29mdCUyRmZvY2FsbmV0LXRpbnklMjIpJTBBbW9kZWwlMjAlM0QlMjBGb2NhbE5ldE1vZGVsLmZyb21fcHJldHJhaW5lZCglMjJtaWNyb3NvZnQlMkZmb2NhbG5ldC10aW55JTIyKSUwQSUwQWlucHV0cyUyMCUzRCUyMGltYWdlX3Byb2Nlc3NvcihpbWFnZSUyQyUyMHJldHVybl90ZW5zb3JzJTNEJTIycHQlMjIpJTBBJTBBd2l0aCUyMHRvcmNoLm5vX2dyYWQoKSUzQSUwQSUyMCUyMCUyMCUyMG91dHB1dHMlMjAlM0QlMjBtb2RlbCgqKmlucHV0cyklMEElMEFsYXN0X2hpZGRlbl9zdGF0ZXMlMjAlM0QlMjBvdXRwdXRzLmxhc3RfaGlkZGVuX3N0YXRlJTBBbGlzdChsYXN0X2hpZGRlbl9zdGF0ZXMuc2hhcGUp",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>, trust_remote_code=<span class="hljs-literal">True</span>)
<span class="hljs-meta">&gt;&gt;&gt; </span>image = dataset[<span class="hljs-string">&quot;test&quot;</span>][<span class="hljs-string">&quot;image&quot;</span>][<span class="hljs-number">0</span>]

<span class="hljs-meta">&gt;&gt;&gt; </span>image_processor = AutoImageProcessor.from_pretrained(<span class="hljs-string">&quot;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>]`,wrap:!1}}),{c(){t=m("p"),t.textContent=f,s=l(),u(r.$$.fragment)},l(o){t=p(o,"P",{"data-svelte-h":!0}),F(t)!=="svelte-11lpom8"&&(t.textContent=f),s=i(o),g(r.$$.fragment,o)},m(o,w){c(o,t,w),c(o,s,w),_(r,o,w),h=!0},p:L,i(o){h||(b(r.$$.fragment,o),h=!0)},o(o){M(r.$$.fragment,o),h=!1},d(o){o&&(n(t),n(s)),y(r,o)}}}function Jt(v){let t,f=`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=m("p"),t.innerHTML=f},l(s){t=p(s,"P",{"data-svelte-h":!0}),F(t)!=="svelte-7i3y9o"&&(t.innerHTML=f)},m(s,r){c(s,t,r)},p:L,d(s){s&&n(t)}}}function Rt(v){let t,f=`Although the recipe for forward pass needs to be defined within this function, one should call the <code>Module</code>
instance afterwards instead of this since the former takes care of running the pre and post processing steps while
the latter silently ignores them.`;return{c(){t=m("p"),t.innerHTML=f},l(s){t=p(s,"P",{"data-svelte-h":!0}),F(t)!=="svelte-fincs2"&&(t.innerHTML=f)},m(s,r){c(s,t,r)},p:L,d(s){s&&n(t)}}}function Gt(v){let t,f="Examples:",s,r,h;return r=new Ye({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>]`,wrap:!1}}),{c(){t=m("p"),t.textContent=f,s=l(),u(r.$$.fragment)},l(o){t=p(o,"P",{"data-svelte-h":!0}),F(t)!=="svelte-kvfsh7"&&(t.textContent=f),s=i(o),g(r.$$.fragment,o)},m(o,w){c(o,t,w),c(o,s,w),_(r,o,w),h=!0},p:L,i(o){h||(b(r.$$.fragment,o),h=!0)},o(o){M(r.$$.fragment,o),h=!1},d(o){o&&(n(t),n(s)),y(r,o)}}}function Vt(v){let t,f=`Although the recipe for forward pass needs to be defined within this function, one should call the <code>Module</code>
instance afterwards instead of this since the former takes care of running the pre and post processing steps while
the latter silently ignores them.`;return{c(){t=m("p"),t.innerHTML=f},l(s){t=p(s,"P",{"data-svelte-h":!0}),F(t)!=="svelte-fincs2"&&(t.innerHTML=f)},m(s,r){c(s,t,r)},p:L,d(s){s&&n(t)}}}function Xt(v){let t,f="Example:",s,r,h;return r=new Ye({props:{code:"ZnJvbSUyMHRyYW5zZm9ybWVycyUyMGltcG9ydCUyMEF1dG9JbWFnZVByb2Nlc3NvciUyQyUyMEZvY2FsTmV0Rm9ySW1hZ2VDbGFzc2lmaWNhdGlvbiUwQWltcG9ydCUyMHRvcmNoJTBBZnJvbSUyMGRhdGFzZXRzJTIwaW1wb3J0JTIwbG9hZF9kYXRhc2V0JTBBJTBBZGF0YXNldCUyMCUzRCUyMGxvYWRfZGF0YXNldCglMjJodWdnaW5nZmFjZSUyRmNhdHMtaW1hZ2UlMjIlMkMlMjB0cnVzdF9yZW1vdGVfY29kZSUzRFRydWUpJTBBaW1hZ2UlMjAlM0QlMjBkYXRhc2V0JTVCJTIydGVzdCUyMiU1RCU1QiUyMmltYWdlJTIyJTVEJTVCMCU1RCUwQSUwQWltYWdlX3Byb2Nlc3NvciUyMCUzRCUyMEF1dG9JbWFnZVByb2Nlc3Nvci5mcm9tX3ByZXRyYWluZWQoJTIybWljcm9zb2Z0JTJGZm9jYWxuZXQtdGlueSUyMiklMEFtb2RlbCUyMCUzRCUyMEZvY2FsTmV0Rm9ySW1hZ2VDbGFzc2lmaWNhdGlvbi5mcm9tX3ByZXRyYWluZWQoJTIybWljcm9zb2Z0JTJGZm9jYWxuZXQtdGlueSUyMiklMEElMEFpbnB1dHMlMjAlM0QlMjBpbWFnZV9wcm9jZXNzb3IoaW1hZ2UlMkMlMjByZXR1cm5fdGVuc29ycyUzRCUyMnB0JTIyKSUwQSUwQXdpdGglMjB0b3JjaC5ub19ncmFkKCklM0ElMEElMjAlMjAlMjAlMjBsb2dpdHMlMjAlM0QlMjBtb2RlbCgqKmlucHV0cykubG9naXRzJTBBJTBBJTIzJTIwbW9kZWwlMjBwcmVkaWN0cyUyMG9uZSUyMG9mJTIwdGhlJTIwMTAwMCUyMEltYWdlTmV0JTIwY2xhc3NlcyUwQXByZWRpY3RlZF9sYWJlbCUyMCUzRCUyMGxvZ2l0cy5hcmdtYXgoLTEpLml0ZW0oKSUwQXByaW50KG1vZGVsLmNvbmZpZy5pZDJsYWJlbCU1QnByZWRpY3RlZF9sYWJlbCU1RCk=",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>, trust_remote_code=<span class="hljs-literal">True</span>)
<span class="hljs-meta">&gt;&gt;&gt; </span>image = dataset[<span class="hljs-string">&quot;test&quot;</span>][<span class="hljs-string">&quot;image&quot;</span>][<span class="hljs-number">0</span>]

<span class="hljs-meta">&gt;&gt;&gt; </span>image_processor = AutoImageProcessor.from_pretrained(<span class="hljs-string">&quot;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`,wrap:!1}}),{c(){t=m("p"),t.textContent=f,s=l(),u(r.$$.fragment)},l(o){t=p(o,"P",{"data-svelte-h":!0}),F(t)!=="svelte-11lpom8"&&(t.textContent=f),s=i(o),g(r.$$.fragment,o)},m(o,w){c(o,t,w),c(o,s,w),_(r,o,w),h=!0},p:L,i(o){h||(b(r.$$.fragment,o),h=!0)},o(o){M(r.$$.fragment,o),h=!1},d(o){o&&(n(t),n(s)),y(r,o)}}}function Bt(v){let t,f,s,r,h,o,w,Te,q,mt=`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.`,Ne,A,pt="The abstract from the paper is the following:",je,D,ft=`<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>`,Ce,O,ht=`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>.`,Ue,K,xe,N,ee,Ee,pe,ut=`This is the configuration class to store the configuration of a <a href="/docs/transformers/main/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.`,Se,fe,gt=`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.`,Qe,X,Ze,te,Ie,Z,oe,He,he,_t=`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.`,Pe,C,ae,Le,ue,bt='The <a href="/docs/transformers/main/en/model_doc/focalnet#transformers.FocalNetModel">FocalNetModel</a> forward method, overrides the <code>__call__</code> special method.',qe,B,Ae,Y,ke,ne,We,$,se,De,ge,Mt="FocalNet Model with a decoder on top for masked image modeling.",Oe,_e,yt='This follows the same implementation as in <a href="https://arxiv.org/abs/2111.09886" rel="nofollow">SimMIM</a>.',Ke,E,et,be,wt=`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.`,tt,U,re,ot,Me,Ft='The <a href="/docs/transformers/main/en/model_doc/focalnet#transformers.FocalNetForMaskedImageModeling">FocalNetForMaskedImageModeling</a> forward method, overrides the <code>__call__</code> special method.',at,S,nt,Q,ze,le,Je,j,ie,st,ye,vt=`FocalNet Model with an image classification head on top (a linear layer on top of the pooled output) e.g. for
ImageNet.`,rt,we,$t=`This model is a PyTorch <a href="https://pytorch.org/docs/stable/nn.html#torch.nn.Module" rel="nofollow">torch.nn.Module</a> sub-class. Use
it as a regular PyTorch Module and refer to the PyTorch documentation for all matter related to general usage and
behavior.`,lt,x,ce,it,Fe,Tt='The <a href="/docs/transformers/main/en/model_doc/focalnet#transformers.FocalNetForImageClassification">FocalNetForImageClassification</a> forward method, overrides the <code>__call__</code> special method.',ct,H,dt,P,Re,de,Ge,$e,Ve;return h=new ve({props:{title:"FocalNet",local:"focalnet",headingTag:"h1"}}),w=new ve({props:{title:"Overview",local:"overview",headingTag:"h2"}}),K=new ve({props:{title:"FocalNetConfig",local:"transformers.FocalNetConfig",headingTag:"h2"}}),ee=new me({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 0.0001) &#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-05) &#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>, <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.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. Must be in the
same order as defined in the <code>stage_names</code> attribute.`,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. Must be in the
same order as defined in the <code>stage_names</code> attribute.`,name:"out_indices"}],source:"https://github.com/huggingface/transformers/blob/main/src/transformers/models/focalnet/configuration_focalnet.py#L25"}}),X=new Be({props:{anchor:"transformers.FocalNetConfig.example",$$slots:{default:[kt]},$$scope:{ctx:v}}}),te=new ve({props:{title:"FocalNetModel",local:"transformers.FocalNetModel",headingTag:"h2"}}),oe=new me({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/main/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/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/focalnet/modeling_focalnet.py#L675"}}),ae=new me({props:{name:"forward",anchor:"transformers.FocalNetModel.forward",parameters:[{name:"pixel_values",val:": Optional = None"},{name:"bool_masked_pos",val:": Optional = None"},{name:"output_hidden_states",val:": Optional = None"},{name:"return_dict",val:": Optional = 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/main/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/main/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/main/src/transformers/models/focalnet/modeling_focalnet.py#L698",returnDescription:`<script context="module">export const metadata = 'undefined';<\/script>


<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/main/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:`<script context="module">export const metadata = 'undefined';<\/script>


<p><code>transformers.models.focalnet.modeling_focalnet.FocalNetModelOutput</code> or <code>tuple(torch.FloatTensor)</code></p>
`}}),B=new Xe({props:{$$slots:{default:[Wt]},$$scope:{ctx:v}}}),Y=new Be({props:{anchor:"transformers.FocalNetModel.forward.example",$$slots:{default:[zt]},$$scope:{ctx:v}}}),ne=new ve({props:{title:"FocalNetForMaskedImageModeling",local:"transformers.FocalNetForMaskedImageModeling",headingTag:"h2"}}),se=new me({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/main/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/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/focalnet/modeling_focalnet.py#L755"}}),E=new Xe({props:{$$slots:{default:[Jt]},$$scope:{ctx:v}}}),re=new me({props:{name:"forward",anchor:"transformers.FocalNetForMaskedImageModeling.forward",parameters:[{name:"pixel_values",val:": Optional = None"},{name:"bool_masked_pos",val:": Optional = None"},{name:"output_hidden_states",val:": Optional = None"},{name:"return_dict",val:": Optional = 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/main/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/main/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/main/src/transformers/models/focalnet/modeling_focalnet.py#L787",returnDescription:`<script context="module">export const metadata = 'undefined';<\/script>


<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/main/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:`<script context="module">export const metadata = 'undefined';<\/script>


<p><code>transformers.models.focalnet.modeling_focalnet.FocalNetMaskedImageModelingOutput</code> or <code>tuple(torch.FloatTensor)</code></p>
`}}),S=new Xe({props:{$$slots:{default:[Rt]},$$scope:{ctx:v}}}),Q=new Be({props:{anchor:"transformers.FocalNetForMaskedImageModeling.forward.example",$$slots:{default:[Gt]},$$scope:{ctx:v}}}),le=new ve({props:{title:"FocalNetForImageClassification",local:"transformers.FocalNetForImageClassification",headingTag:"h2"}}),ie=new me({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/main/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/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/focalnet/modeling_focalnet.py#L870"}}),ce=new me({props:{name:"forward",anchor:"transformers.FocalNetForImageClassification.forward",parameters:[{name:"pixel_values",val:": Optional = None"},{name:"labels",val:": Optional = None"},{name:"output_hidden_states",val:": Optional = None"},{name:"return_dict",val:": Optional = 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/main/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/main/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/main/src/transformers/models/focalnet/modeling_focalnet.py#L893",returnDescription:`<script context="module">export const metadata = 'undefined';<\/script>


<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/main/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:`<script context="module">export const metadata = 'undefined';<\/script>


<p><code>transformers.models.focalnet.modeling_focalnet.FocalNetImageClassifierOutput</code> or <code>tuple(torch.FloatTensor)</code></p>
`}}),H=new Xe({props:{$$slots:{default:[Vt]},$$scope:{ctx:v}}}),P=new Be({props:{anchor:"transformers.FocalNetForImageClassification.forward.example",$$slots:{default:[Xt]},$$scope:{ctx:v}}}),de=new It({props:{source:"https://github.com/huggingface/transformers/blob/main/docs/source/en/model_doc/focalnet.md"}}),{c(){t=m("meta"),f=l(),s=m("p"),r=l(),u(h.$$.fragment),o=l(),u(w.$$.fragment),Te=l(),q=m("p"),q.innerHTML=mt,Ne=l(),A=m("p"),A.textContent=pt,je=l(),D=m("p"),D.innerHTML=ft,Ce=l(),O=m("p"),O.innerHTML=ht,Ue=l(),u(K.$$.fragment),xe=l(),N=m("div"),u(ee.$$.fragment),Ee=l(),pe=m("p"),pe.innerHTML=ut,Se=l(),fe=m("p"),fe.innerHTML=gt,Qe=l(),u(X.$$.fragment),Ze=l(),u(te.$$.fragment),Ie=l(),Z=m("div"),u(oe.$$.fragment),He=l(),he=m("p"),he.innerHTML=_t,Pe=l(),C=m("div"),u(ae.$$.fragment),Le=l(),ue=m("p"),ue.innerHTML=bt,qe=l(),u(B.$$.fragment),Ae=l(),u(Y.$$.fragment),ke=l(),u(ne.$$.fragment),We=l(),$=m("div"),u(se.$$.fragment),De=l(),ge=m("p"),ge.textContent=Mt,Oe=l(),_e=m("p"),_e.innerHTML=yt,Ke=l(),u(E.$$.fragment),et=l(),be=m("p"),be.innerHTML=wt,tt=l(),U=m("div"),u(re.$$.fragment),ot=l(),Me=m("p"),Me.innerHTML=Ft,at=l(),u(S.$$.fragment),nt=l(),u(Q.$$.fragment),ze=l(),u(le.$$.fragment),Je=l(),j=m("div"),u(ie.$$.fragment),st=l(),ye=m("p"),ye.textContent=vt,rt=l(),we=m("p"),we.innerHTML=$t,lt=l(),x=m("div"),u(ce.$$.fragment),it=l(),Fe=m("p"),Fe.innerHTML=Tt,ct=l(),u(H.$$.fragment),dt=l(),u(P.$$.fragment),Re=l(),u(de.$$.fragment),Ge=l(),$e=m("p"),this.h()},l(e){const a=Zt("svelte-u9bgzb",document.head);t=p(a,"META",{name:!0,content:!0}),a.forEach(n),f=i(e),s=p(e,"P",{}),G(s).forEach(n),r=i(e),g(h.$$.fragment,e),o=i(e),g(w.$$.fragment,e),Te=i(e),q=p(e,"P",{"data-svelte-h":!0}),F(q)!=="svelte-84c53e"&&(q.innerHTML=mt),Ne=i(e),A=p(e,"P",{"data-svelte-h":!0}),F(A)!=="svelte-vfdo9a"&&(A.textContent=pt),je=i(e),D=p(e,"P",{"data-svelte-h":!0}),F(D)!=="svelte-1uz33aa"&&(D.innerHTML=ft),Ce=i(e),O=p(e,"P",{"data-svelte-h":!0}),F(O)!=="svelte-dxae3d"&&(O.innerHTML=ht),Ue=i(e),g(K.$$.fragment,e),xe=i(e),N=p(e,"DIV",{class:!0});var I=G(N);g(ee.$$.fragment,I),Ee=i(I),pe=p(I,"P",{"data-svelte-h":!0}),F(pe)!=="svelte-1pfic19"&&(pe.innerHTML=ut),Se=i(I),fe=p(I,"P",{"data-svelte-h":!0}),F(fe)!=="svelte-o55m63"&&(fe.innerHTML=gt),Qe=i(I),g(X.$$.fragment,I),I.forEach(n),Ze=i(e),g(te.$$.fragment,e),Ie=i(e),Z=p(e,"DIV",{class:!0});var R=G(Z);g(oe.$$.fragment,R),He=i(R),he=p(R,"P",{"data-svelte-h":!0}),F(he)!=="svelte-9um4dr"&&(he.innerHTML=_t),Pe=i(R),C=p(R,"DIV",{class:!0});var k=G(C);g(ae.$$.fragment,k),Le=i(k),ue=p(k,"P",{"data-svelte-h":!0}),F(ue)!=="svelte-7tya37"&&(ue.innerHTML=bt),qe=i(k),g(B.$$.fragment,k),Ae=i(k),g(Y.$$.fragment,k),k.forEach(n),R.forEach(n),ke=i(e),g(ne.$$.fragment,e),We=i(e),$=p(e,"DIV",{class:!0});var T=G($);g(se.$$.fragment,T),De=i(T),ge=p(T,"P",{"data-svelte-h":!0}),F(ge)!=="svelte-1082wlw"&&(ge.textContent=Mt),Oe=i(T),_e=p(T,"P",{"data-svelte-h":!0}),F(_e)!=="svelte-muou64"&&(_e.innerHTML=yt),Ke=i(T),g(E.$$.fragment,T),et=i(T),be=p(T,"P",{"data-svelte-h":!0}),F(be)!=="svelte-68lg8f"&&(be.innerHTML=wt),tt=i(T),U=p(T,"DIV",{class:!0});var W=G(U);g(re.$$.fragment,W),ot=i(W),Me=p(W,"P",{"data-svelte-h":!0}),F(Me)!=="svelte-zo6p8f"&&(Me.innerHTML=Ft),at=i(W),g(S.$$.fragment,W),nt=i(W),g(Q.$$.fragment,W),W.forEach(n),T.forEach(n),ze=i(e),g(le.$$.fragment,e),Je=i(e),j=p(e,"DIV",{class:!0});var z=G(j);g(ie.$$.fragment,z),st=i(z),ye=p(z,"P",{"data-svelte-h":!0}),F(ye)!=="svelte-mhgt84"&&(ye.textContent=vt),rt=i(z),we=p(z,"P",{"data-svelte-h":!0}),F(we)!=="svelte-68lg8f"&&(we.innerHTML=$t),lt=i(z),x=p(z,"DIV",{class:!0});var J=G(x);g(ce.$$.fragment,J),it=i(J),Fe=p(J,"P",{"data-svelte-h":!0}),F(Fe)!=="svelte-3q1uz3"&&(Fe.innerHTML=Tt),ct=i(J),g(H.$$.fragment,J),dt=i(J),g(P.$$.fragment,J),J.forEach(n),z.forEach(n),Re=i(e),g(de.$$.fragment,e),Ge=i(e),$e=p(e,"P",{}),G($e).forEach(n),this.h()},h(){V(t,"name","hf:doc:metadata"),V(t,"content",Yt),V(N,"class","docstring border-l-2 border-t-2 pl-4 pt-3.5 border-gray-100 rounded-tl-xl mb-6 mt-8"),V(C,"class","docstring border-l-2 border-t-2 pl-4 pt-3.5 border-gray-100 rounded-tl-xl mb-6 mt-8"),V(Z,"class","docstring border-l-2 border-t-2 pl-4 pt-3.5 border-gray-100 rounded-tl-xl mb-6 mt-8"),V(U,"class","docstring border-l-2 border-t-2 pl-4 pt-3.5 border-gray-100 rounded-tl-xl mb-6 mt-8"),V($,"class","docstring border-l-2 border-t-2 pl-4 pt-3.5 border-gray-100 rounded-tl-xl mb-6 mt-8"),V(x,"class","docstring border-l-2 border-t-2 pl-4 pt-3.5 border-gray-100 rounded-tl-xl mb-6 mt-8"),V(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,a){d(document.head,t),c(e,f,a),c(e,s,a),c(e,r,a),_(h,e,a),c(e,o,a),_(w,e,a),c(e,Te,a),c(e,q,a),c(e,Ne,a),c(e,A,a),c(e,je,a),c(e,D,a),c(e,Ce,a),c(e,O,a),c(e,Ue,a),_(K,e,a),c(e,xe,a),c(e,N,a),_(ee,N,null),d(N,Ee),d(N,pe),d(N,Se),d(N,fe),d(N,Qe),_(X,N,null),c(e,Ze,a),_(te,e,a),c(e,Ie,a),c(e,Z,a),_(oe,Z,null),d(Z,He),d(Z,he),d(Z,Pe),d(Z,C),_(ae,C,null),d(C,Le),d(C,ue),d(C,qe),_(B,C,null),d(C,Ae),_(Y,C,null),c(e,ke,a),_(ne,e,a),c(e,We,a),c(e,$,a),_(se,$,null),d($,De),d($,ge),d($,Oe),d($,_e),d($,Ke),_(E,$,null),d($,et),d($,be),d($,tt),d($,U),_(re,U,null),d(U,ot),d(U,Me),d(U,at),_(S,U,null),d(U,nt),_(Q,U,null),c(e,ze,a),_(le,e,a),c(e,Je,a),c(e,j,a),_(ie,j,null),d(j,st),d(j,ye),d(j,rt),d(j,we),d(j,lt),d(j,x),_(ce,x,null),d(x,it),d(x,Fe),d(x,ct),_(H,x,null),d(x,dt),_(P,x,null),c(e,Re,a),_(de,e,a),c(e,Ge,a),c(e,$e,a),Ve=!0},p(e,[a]){const I={};a&2&&(I.$$scope={dirty:a,ctx:e}),X.$set(I);const R={};a&2&&(R.$$scope={dirty:a,ctx:e}),B.$set(R);const k={};a&2&&(k.$$scope={dirty:a,ctx:e}),Y.$set(k);const T={};a&2&&(T.$$scope={dirty:a,ctx:e}),E.$set(T);const W={};a&2&&(W.$$scope={dirty:a,ctx:e}),S.$set(W);const z={};a&2&&(z.$$scope={dirty:a,ctx:e}),Q.$set(z);const J={};a&2&&(J.$$scope={dirty:a,ctx:e}),H.$set(J);const Nt={};a&2&&(Nt.$$scope={dirty:a,ctx:e}),P.$set(Nt)},i(e){Ve||(b(h.$$.fragment,e),b(w.$$.fragment,e),b(K.$$.fragment,e),b(ee.$$.fragment,e),b(X.$$.fragment,e),b(te.$$.fragment,e),b(oe.$$.fragment,e),b(ae.$$.fragment,e),b(B.$$.fragment,e),b(Y.$$.fragment,e),b(ne.$$.fragment,e),b(se.$$.fragment,e),b(E.$$.fragment,e),b(re.$$.fragment,e),b(S.$$.fragment,e),b(Q.$$.fragment,e),b(le.$$.fragment,e),b(ie.$$.fragment,e),b(ce.$$.fragment,e),b(H.$$.fragment,e),b(P.$$.fragment,e),b(de.$$.fragment,e),Ve=!0)},o(e){M(h.$$.fragment,e),M(w.$$.fragment,e),M(K.$$.fragment,e),M(ee.$$.fragment,e),M(X.$$.fragment,e),M(te.$$.fragment,e),M(oe.$$.fragment,e),M(ae.$$.fragment,e),M(B.$$.fragment,e),M(Y.$$.fragment,e),M(ne.$$.fragment,e),M(se.$$.fragment,e),M(E.$$.fragment,e),M(re.$$.fragment,e),M(S.$$.fragment,e),M(Q.$$.fragment,e),M(le.$$.fragment,e),M(ie.$$.fragment,e),M(ce.$$.fragment,e),M(H.$$.fragment,e),M(P.$$.fragment,e),M(de.$$.fragment,e),Ve=!1},d(e){e&&(n(f),n(s),n(r),n(o),n(Te),n(q),n(Ne),n(A),n(je),n(D),n(Ce),n(O),n(Ue),n(xe),n(N),n(Ze),n(Ie),n(Z),n(ke),n(We),n($),n(ze),n(Je),n(j),n(Re),n(Ge),n($e)),n(t),y(h,e),y(w,e),y(K,e),y(ee),y(X),y(te,e),y(oe),y(ae),y(B),y(Y),y(ne,e),y(se),y(E),y(re),y(S),y(Q),y(le,e),y(ie),y(ce),y(H),y(P),y(de,e)}}}const Yt='{"title":"FocalNet","local":"focalnet","sections":[{"title":"Overview","local":"overview","sections":[],"depth":2},{"title":"FocalNetConfig","local":"transformers.FocalNetConfig","sections":[],"depth":2},{"title":"FocalNetModel","local":"transformers.FocalNetModel","sections":[],"depth":2},{"title":"FocalNetForMaskedImageModeling","local":"transformers.FocalNetForMaskedImageModeling","sections":[],"depth":2},{"title":"FocalNetForImageClassification","local":"transformers.FocalNetForImageClassification","sections":[],"depth":2}],"depth":1}';function Et(v){return Ct(()=>{new URLSearchParams(window.location.search).get("fw")}),[]}class Dt extends Ut{constructor(t){super(),xt(this,t,Et,Bt,jt,{})}}export{Dt as component};
