import{s as nt,o as rt,n as fe}from"../chunks/scheduler.9bc65507.js";import{S as it,i as lt,g as c,s as r,r as w,A as mt,h as d,f as a,c as i,j as ee,u as _,x as g,k as te,y as f,a as n,v as b,d as y,t as M,w as v}from"../chunks/index.707bf1b6.js";import{T as at}from"../chunks/Tip.c2ecdbf4.js";import{D as ce}from"../chunks/Docstring.17db21ae.js";import{C as He}from"../chunks/CodeBlock.54a9f38d.js";import{E as Pe}from"../chunks/ExampleCodeBlock.4f515aa9.js";import{H as de}from"../chunks/Heading.342b1fa6.js";function ct(F){let t,h="Example:",l,m,p;return m=new He({props:{code:"ZnJvbSUyMHRyYW5zZm9ybWVycyUyMGltcG9ydCUyMFN3aWZ0Rm9ybWVyQ29uZmlnJTJDJTIwU3dpZnRGb3JtZXJNb2RlbCUwQSUwQSUyMyUyMEluaXRpYWxpemluZyUyMGElMjBTd2lmdEZvcm1lciUyMHN3aWZ0Zm9ybWVyLWJhc2UtcGF0Y2gxNi0yMjQlMjBzdHlsZSUyMGNvbmZpZ3VyYXRpb24lMEFjb25maWd1cmF0aW9uJTIwJTNEJTIwU3dpZnRGb3JtZXJDb25maWcoKSUwQSUwQSUyMyUyMEluaXRpYWxpemluZyUyMGElMjBtb2RlbCUyMCh3aXRoJTIwcmFuZG9tJTIwd2VpZ2h0cyklMjBmcm9tJTIwdGhlJTIwc3dpZnRmb3JtZXItYmFzZS1wYXRjaDE2LTIyNCUyMHN0eWxlJTIwY29uZmlndXJhdGlvbiUwQW1vZGVsJTIwJTNEJTIwU3dpZnRGb3JtZXJNb2RlbChjb25maWd1cmF0aW9uKSUwQSUwQSUyMyUyMEFjY2Vzc2luZyUyMHRoZSUyMG1vZGVsJTIwY29uZmlndXJhdGlvbiUwQWNvbmZpZ3VyYXRpb24lMjAlM0QlMjBtb2RlbC5jb25maWc=",highlighted:`<span class="hljs-meta">&gt;&gt;&gt; </span><span class="hljs-keyword">from</span> transformers <span class="hljs-keyword">import</span> SwiftFormerConfig, SwiftFormerModel

<span class="hljs-meta">&gt;&gt;&gt; </span><span class="hljs-comment"># Initializing a SwiftFormer swiftformer-base-patch16-224 style configuration</span>
<span class="hljs-meta">&gt;&gt;&gt; </span>configuration = SwiftFormerConfig()

<span class="hljs-meta">&gt;&gt;&gt; </span><span class="hljs-comment"># Initializing a model (with random weights) from the swiftformer-base-patch16-224 style configuration</span>
<span class="hljs-meta">&gt;&gt;&gt; </span>model = SwiftFormerModel(configuration)

<span class="hljs-meta">&gt;&gt;&gt; </span><span class="hljs-comment"># Accessing the model configuration</span>
<span class="hljs-meta">&gt;&gt;&gt; </span>configuration = model.config`,wrap:!1}}),{c(){t=c("p"),t.textContent=h,l=r(),w(m.$$.fragment)},l(o){t=d(o,"P",{"data-svelte-h":!0}),g(t)!=="svelte-11lpom8"&&(t.textContent=h),l=i(o),_(m.$$.fragment,o)},m(o,u){n(o,t,u),n(o,l,u),b(m,o,u),p=!0},p:fe,i(o){p||(y(m.$$.fragment,o),p=!0)},o(o){M(m.$$.fragment,o),p=!1},d(o){o&&(a(t),a(l)),v(m,o)}}}function dt(F){let t,h=`Although the recipe for forward pass needs to be defined within this function, one should call the <code>Module</code>
instance afterwards instead of this since the former takes care of running the pre and post processing steps while
the latter silently ignores them.`;return{c(){t=c("p"),t.innerHTML=h},l(l){t=d(l,"P",{"data-svelte-h":!0}),g(t)!=="svelte-fincs2"&&(t.innerHTML=h)},m(l,m){n(l,t,m)},p:fe,d(l){l&&a(t)}}}function ft(F){let t,h="Example:",l,m,p;return m=new He({props:{code:"ZnJvbSUyMHRyYW5zZm9ybWVycyUyMGltcG9ydCUyMEF1dG9JbWFnZVByb2Nlc3NvciUyQyUyMFN3aWZ0Rm9ybWVyTW9kZWwlMEFpbXBvcnQlMjB0b3JjaCUwQWZyb20lMjBkYXRhc2V0cyUyMGltcG9ydCUyMGxvYWRfZGF0YXNldCUwQSUwQWRhdGFzZXQlMjAlM0QlMjBsb2FkX2RhdGFzZXQoJTIyaHVnZ2luZ2ZhY2UlMkZjYXRzLWltYWdlJTIyKSUwQWltYWdlJTIwJTNEJTIwZGF0YXNldCU1QiUyMnRlc3QlMjIlNUQlNUIlMjJpbWFnZSUyMiU1RCU1QjAlNUQlMEElMEFpbWFnZV9wcm9jZXNzb3IlMjAlM0QlMjBBdXRvSW1hZ2VQcm9jZXNzb3IuZnJvbV9wcmV0cmFpbmVkKCUyMk1CWlVBSSUyRnN3aWZ0Zm9ybWVyLXhzJTIyKSUwQW1vZGVsJTIwJTNEJTIwU3dpZnRGb3JtZXJNb2RlbC5mcm9tX3ByZXRyYWluZWQoJTIyTUJaVUFJJTJGc3dpZnRmb3JtZXIteHMlMjIpJTBBJTBBaW5wdXRzJTIwJTNEJTIwaW1hZ2VfcHJvY2Vzc29yKGltYWdlJTJDJTIwcmV0dXJuX3RlbnNvcnMlM0QlMjJwdCUyMiklMEElMEF3aXRoJTIwdG9yY2gubm9fZ3JhZCgpJTNBJTBBJTIwJTIwJTIwJTIwb3V0cHV0cyUyMCUzRCUyMG1vZGVsKCoqaW5wdXRzKSUwQSUwQWxhc3RfaGlkZGVuX3N0YXRlcyUyMCUzRCUyMG91dHB1dHMubGFzdF9oaWRkZW5fc3RhdGUlMEFsaXN0KGxhc3RfaGlkZGVuX3N0YXRlcy5zaGFwZSk=",highlighted:`<span class="hljs-meta">&gt;&gt;&gt; </span><span class="hljs-keyword">from</span> transformers <span class="hljs-keyword">import</span> AutoImageProcessor, SwiftFormerModel
<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;MBZUAI/swiftformer-xs&quot;</span>)
<span class="hljs-meta">&gt;&gt;&gt; </span>model = SwiftFormerModel.from_pretrained(<span class="hljs-string">&quot;MBZUAI/swiftformer-xs&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">220</span>, <span class="hljs-number">7</span>, <span class="hljs-number">7</span>]`,wrap:!1}}),{c(){t=c("p"),t.textContent=h,l=r(),w(m.$$.fragment)},l(o){t=d(o,"P",{"data-svelte-h":!0}),g(t)!=="svelte-11lpom8"&&(t.textContent=h),l=i(o),_(m.$$.fragment,o)},m(o,u){n(o,t,u),n(o,l,u),b(m,o,u),p=!0},p:fe,i(o){p||(y(m.$$.fragment,o),p=!0)},o(o){M(m.$$.fragment,o),p=!1},d(o){o&&(a(t),a(l)),v(m,o)}}}function pt(F){let t,h=`Although the recipe for forward pass needs to be defined within this function, one should call the <code>Module</code>
instance afterwards instead of this since the former takes care of running the pre and post processing steps while
the latter silently ignores them.`;return{c(){t=c("p"),t.innerHTML=h},l(l){t=d(l,"P",{"data-svelte-h":!0}),g(t)!=="svelte-fincs2"&&(t.innerHTML=h)},m(l,m){n(l,t,m)},p:fe,d(l){l&&a(t)}}}function ht(F){let t,h="Example:",l,m,p;return m=new He({props:{code:"ZnJvbSUyMHRyYW5zZm9ybWVycyUyMGltcG9ydCUyMEF1dG9JbWFnZVByb2Nlc3NvciUyQyUyMFN3aWZ0Rm9ybWVyRm9ySW1hZ2VDbGFzc2lmaWNhdGlvbiUwQWltcG9ydCUyMHRvcmNoJTBBZnJvbSUyMGRhdGFzZXRzJTIwaW1wb3J0JTIwbG9hZF9kYXRhc2V0JTBBJTBBZGF0YXNldCUyMCUzRCUyMGxvYWRfZGF0YXNldCglMjJodWdnaW5nZmFjZSUyRmNhdHMtaW1hZ2UlMjIpJTBBaW1hZ2UlMjAlM0QlMjBkYXRhc2V0JTVCJTIydGVzdCUyMiU1RCU1QiUyMmltYWdlJTIyJTVEJTVCMCU1RCUwQSUwQWltYWdlX3Byb2Nlc3NvciUyMCUzRCUyMEF1dG9JbWFnZVByb2Nlc3Nvci5mcm9tX3ByZXRyYWluZWQoJTIyTUJaVUFJJTJGc3dpZnRmb3JtZXIteHMlMjIpJTBBbW9kZWwlMjAlM0QlMjBTd2lmdEZvcm1lckZvckltYWdlQ2xhc3NpZmljYXRpb24uZnJvbV9wcmV0cmFpbmVkKCUyMk1CWlVBSSUyRnN3aWZ0Zm9ybWVyLXhzJTIyKSUwQSUwQWlucHV0cyUyMCUzRCUyMGltYWdlX3Byb2Nlc3NvcihpbWFnZSUyQyUyMHJldHVybl90ZW5zb3JzJTNEJTIycHQlMjIpJTBBJTBBd2l0aCUyMHRvcmNoLm5vX2dyYWQoKSUzQSUwQSUyMCUyMCUyMCUyMGxvZ2l0cyUyMCUzRCUyMG1vZGVsKCoqaW5wdXRzKS5sb2dpdHMlMEElMEElMjMlMjBtb2RlbCUyMHByZWRpY3RzJTIwb25lJTIwb2YlMjB0aGUlMjAxMDAwJTIwSW1hZ2VOZXQlMjBjbGFzc2VzJTBBcHJlZGljdGVkX2xhYmVsJTIwJTNEJTIwbG9naXRzLmFyZ21heCgtMSkuaXRlbSgpJTBBcHJpbnQobW9kZWwuY29uZmlnLmlkMmxhYmVsJTVCcHJlZGljdGVkX2xhYmVsJTVEKQ==",highlighted:`<span class="hljs-meta">&gt;&gt;&gt; </span><span class="hljs-keyword">from</span> transformers <span class="hljs-keyword">import</span> AutoImageProcessor, SwiftFormerForImageClassification
<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;MBZUAI/swiftformer-xs&quot;</span>)
<span class="hljs-meta">&gt;&gt;&gt; </span>model = SwiftFormerForImageClassification.from_pretrained(<span class="hljs-string">&quot;MBZUAI/swiftformer-xs&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=c("p"),t.textContent=h,l=r(),w(m.$$.fragment)},l(o){t=d(o,"P",{"data-svelte-h":!0}),g(t)!=="svelte-11lpom8"&&(t.textContent=h),l=i(o),_(m.$$.fragment,o)},m(o,u){n(o,t,u),n(o,l,u),b(m,o,u),p=!0},p:fe,i(o){p||(y(m.$$.fragment,o),p=!0)},o(o){M(m.$$.fragment,o),p=!1},d(o){o&&(a(t),a(l)),v(m,o)}}}function ut(F){let t,h,l,m,p,o,u,pe,N,Xe='The SwiftFormer model was proposed in <a href="https://arxiv.org/abs/2303.15446" rel="nofollow">SwiftFormer: Efficient Additive Attention for Transformer-based Real-time Mobile Vision Applications</a> by Abdelrahman Shaker, Muhammad Maaz, Hanoona Rasheed, Salman Khan, Ming-Hsuan Yang, Fahad Shahbaz Khan.',he,B,Ee="The SwiftFormer paper introduces a novel efficient additive attention mechanism that effectively replaces the quadratic matrix multiplication operations in the self-attention computation with linear element-wise multiplications. A series of models called ‘SwiftFormer’ is built based on this, which achieves state-of-the-art performance in terms of both accuracy and mobile inference speed. Even their small variant achieves 78.5% top-1 ImageNet1K accuracy with only 0.8 ms latency on iPhone 14, which is more accurate and 2× faster compared to MobileViT-v2.",ue,z,Qe="The abstract from the paper is the following:",ge,P,Ye="<em>Self-attention has become a defacto choice for capturing global context in various vision applications. However, its quadratic computational complexity with respect to image resolution limits its use in real-time applications, especially for deployment on resource-constrained mobile devices. Although hybrid approaches have been proposed to combine the advantages of convolutions and self-attention for a better speed-accuracy trade-off, the expensive matrix multiplication operations in self-attention remain a bottleneck. In this work, we introduce a novel efficient additive attention mechanism that effectively replaces the quadratic matrix multiplication operations with linear element-wise multiplications. Our design shows that the key-value interaction can be replaced with a linear layer without sacrificing any accuracy. Unlike previous state-of-the-art methods, our efficient formulation of self-attention enables its usage at all stages of the network. Using our proposed efficient additive attention, we build a series of models called “SwiftFormer” which achieves state-of-the-art performance in terms of both accuracy and mobile inference speed. Our small variant achieves 78.5% top-1 ImageNet-1K accuracy with only 0.8 ms latency on iPhone 14, which is more accurate and 2x faster compared to MobileViT-v2.</em>",we,H,Le="Tips:",_e,X,qe='<li>One can use the <a href="/docs/transformers/main/en/model_doc/vit#transformers.ViTImageProcessor">ViTImageProcessor</a> API to prepare images for the model.</li>',be,E,Ae=`This model was contributed by <a href="https://huggingface.co/shehan97" rel="nofollow">shehan97</a>.
The original code can be found <a href="https://github.com/Amshaker/SwiftFormer" rel="nofollow">here</a>.`,ye,Q,Me,$,Y,xe,oe,De=`This is the configuration class to store the configuration of a <a href="/docs/transformers/main/en/model_doc/swiftformer#transformers.SwiftFormerModel">SwiftFormerModel</a>. It is used to instantiate an
SwiftFormer 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 SwiftFormer
<a href="https://huggingface.co/MBZUAI/swiftformer-xs" rel="nofollow">MBZUAI/swiftformer-xs</a> architecture.`,Ue,se,Oe=`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.`,je,W,ve,L,$e,x,q,Je,ae,Ke=`The bare SwiftFormer Model transformer outputting raw hidden-states without any specific head on top.
This model is a PyTorch <a href="https://pytorch.org/docs/stable/nn.html#torch.nn.Module" rel="nofollow">torch.nn.Module</a> subclass. Use it
as a regular PyTorch Module and refer to the PyTorch documentation for all matter related to general usage and
behavior.`,Ze,C,A,Ie,ne,et='The <a href="/docs/transformers/main/en/model_doc/swiftformer#transformers.SwiftFormerModel">SwiftFormerModel</a> forward method, overrides the <code>__call__</code> special method.',We,R,Re,V,Te,D,Fe,T,O,Ve,re,tt="SwiftFormer Model transformer with an image classification head on top (e.g. for ImageNet).",Ge,ie,ot=`This model is a PyTorch <a href="https://pytorch.org/docs/stable/nn.html#torch.nn.Module" rel="nofollow">torch.nn.Module</a> subclass. Use it
as a regular PyTorch Module and refer to the PyTorch documentation for all matter related to general usage and
behavior.`,ke,S,K,Ne,le,st='The <a href="/docs/transformers/main/en/model_doc/swiftformer#transformers.SwiftFormerForImageClassification">SwiftFormerForImageClassification</a> forward method, overrides the <code>__call__</code> special method.',Be,G,ze,k,Ce,me,Se;return p=new de({props:{title:"SwiftFormer",local:"swiftformer",headingTag:"h1"}}),u=new de({props:{title:"Overview",local:"overview",headingTag:"h2"}}),Q=new de({props:{title:"SwiftFormerConfig",local:"transformers.SwiftFormerConfig",headingTag:"h2"}}),Y=new ce({props:{name:"class transformers.SwiftFormerConfig",anchor:"transformers.SwiftFormerConfig",parameters:[{name:"num_channels",val:" = 3"},{name:"depths",val:" = [3, 3, 6, 4]"},{name:"embed_dims",val:" = [48, 56, 112, 220]"},{name:"mlp_ratio",val:" = 4"},{name:"downsamples",val:" = [True, True, True, True]"},{name:"hidden_act",val:" = 'gelu'"},{name:"down_patch_size",val:" = 3"},{name:"down_stride",val:" = 2"},{name:"down_pad",val:" = 1"},{name:"drop_path_rate",val:" = 0.0"},{name:"use_layer_scale",val:" = True"},{name:"layer_scale_init_value",val:" = 1e-05"},{name:"batch_norm_eps",val:" = 1e-05"},{name:"**kwargs",val:""}],parametersDescription:[{anchor:"transformers.SwiftFormerConfig.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.SwiftFormerConfig.depths",description:`<strong>depths</strong> (<code>List[int]</code>, <em>optional</em>, defaults to <code>[3, 3, 6, 4]</code>) &#x2014;
Depth of each stage`,name:"depths"},{anchor:"transformers.SwiftFormerConfig.embed_dims",description:`<strong>embed_dims</strong> (<code>List[int]</code>, <em>optional</em>, defaults to <code>[48, 56, 112, 220]</code>) &#x2014;
The embedding dimension at each stage`,name:"embed_dims"},{anchor:"transformers.SwiftFormerConfig.mlp_ratio",description:`<strong>mlp_ratio</strong> (<code>int</code>, <em>optional</em>, defaults to 4) &#x2014;
Ratio of size of the hidden dimensionality of an MLP to the dimensionality of its input.`,name:"mlp_ratio"},{anchor:"transformers.SwiftFormerConfig.downsamples",description:`<strong>downsamples</strong> (<code>List[bool]</code>, <em>optional</em>, defaults to <code>[True, True, True, True]</code>) &#x2014;
Whether or not to downsample inputs between two stages.`,name:"downsamples"},{anchor:"transformers.SwiftFormerConfig.hidden_act",description:`<strong>hidden_act</strong> (<code>str</code>, <em>optional</em>, defaults to <code>&quot;gelu&quot;</code>) &#x2014;
The non-linear activation function (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.SwiftFormerConfig.down_patch_size",description:`<strong>down_patch_size</strong> (<code>int</code>, <em>optional</em>, defaults to 3) &#x2014;
The size of patches in downsampling layers.`,name:"down_patch_size"},{anchor:"transformers.SwiftFormerConfig.down_stride",description:`<strong>down_stride</strong> (<code>int</code>, <em>optional</em>, defaults to 2) &#x2014;
The stride of convolution kernels in downsampling layers.`,name:"down_stride"},{anchor:"transformers.SwiftFormerConfig.down_pad",description:`<strong>down_pad</strong> (<code>int</code>, <em>optional</em>, defaults to 1) &#x2014;
Padding in downsampling layers.`,name:"down_pad"},{anchor:"transformers.SwiftFormerConfig.drop_path_rate",description:`<strong>drop_path_rate</strong> (<code>float</code>, <em>optional</em>, defaults to 0.0) &#x2014;
Rate at which to increase dropout probability in DropPath.`,name:"drop_path_rate"},{anchor:"transformers.SwiftFormerConfig.use_layer_scale",description:`<strong>use_layer_scale</strong> (<code>bool</code>, <em>optional</em>, defaults to <code>True</code>) &#x2014;
Whether to scale outputs from token mixers.`,name:"use_layer_scale"},{anchor:"transformers.SwiftFormerConfig.layer_scale_init_value",description:`<strong>layer_scale_init_value</strong> (<code>float</code>, <em>optional</em>, defaults to 1e-05) &#x2014;
Factor by which outputs from token mixers are scaled.`,name:"layer_scale_init_value"},{anchor:"transformers.SwiftFormerConfig.batch_norm_eps",description:`<strong>batch_norm_eps</strong> (<code>float</code>, <em>optional</em>, defaults to 1e-05) &#x2014;
The epsilon used by the batch normalization layers.`,name:"batch_norm_eps"}],source:"https://github.com/huggingface/transformers/blob/main/src/transformers/models/swiftformer/configuration_swiftformer.py#L34"}}),W=new Pe({props:{anchor:"transformers.SwiftFormerConfig.example",$$slots:{default:[ct]},$$scope:{ctx:F}}}),L=new de({props:{title:"SwiftFormerModel",local:"transformers.SwiftFormerModel",headingTag:"h2"}}),q=new ce({props:{name:"class transformers.SwiftFormerModel",anchor:"transformers.SwiftFormerModel",parameters:[{name:"config",val:": SwiftFormerConfig"}],parametersDescription:[{anchor:"transformers.SwiftFormerModel.config",description:`<strong>config</strong> (<a href="/docs/transformers/main/en/model_doc/swiftformer#transformers.SwiftFormerConfig">SwiftFormerConfig</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/swiftformer/modeling_swiftformer.py#L479"}}),A=new ce({props:{name:"forward",anchor:"transformers.SwiftFormerModel.forward",parameters:[{name:"pixel_values",val:": typing.Optional[torch.Tensor] = None"},{name:"output_hidden_states",val:": typing.Optional[bool] = None"},{name:"return_dict",val:": typing.Optional[bool] = None"}],parametersDescription:[{anchor:"transformers.SwiftFormerModel.forward.pixel_values",description:`<strong>pixel_values</strong> (<code>torch.FloatTensor</code> of shape <code>(batch_size, num_channels, height, width)</code>) &#x2014;
Pixel values. Pixel values can be obtained using <a href="/docs/transformers/main/en/model_doc/auto#transformers.AutoImageProcessor">AutoImageProcessor</a>. See <a href="/docs/transformers/main/en/model_doc/deit#transformers.DeiTFeatureExtractor.__call__">ViTImageProcessor.<strong>call</strong>()</a>
for details.`,name:"pixel_values"},{anchor:"transformers.SwiftFormerModel.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.SwiftFormerModel.forward.return_dict",description:`<strong>return_dict</strong> (<code>bool</code>, <em>optional</em>) &#x2014;
Whether or not to return a <a href="/docs/transformers/main/en/main_classes/output#transformers.utils.ModelOutput">ModelOutput</a> instead of a plain tuple.`,name:"return_dict"}],source:"https://github.com/huggingface/transformers/blob/main/src/transformers/models/swiftformer/modeling_swiftformer.py#L490",returnDescription:`<script context="module">export const metadata = 'undefined';<\/script>


<p>A <code>transformers.modeling_outputs.BaseModelOutputWithNoAttention</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/swiftformer#transformers.SwiftFormerConfig"
>SwiftFormerConfig</a>) and inputs.</p>
<ul>
<li>
<p><strong>last_hidden_state</strong> (<code>torch.FloatTensor</code> of shape <code>(batch_size, num_channels, height, width)</code>) — Sequence of hidden-states at the output of the last layer of the model.</p>
</li>
<li>
<p><strong>hidden_states</strong> (<code>tuple(torch.FloatTensor)</code>, <em>optional</em>, returned when <code>output_hidden_states=True</code> is passed or when <code>config.output_hidden_states=True</code>) — Tuple of <code>torch.FloatTensor</code> (one for the output of the embeddings, if the model has an embedding layer, +
one for the output of each layer) of shape <code>(batch_size, num_channels, height, width)</code>.</p>
<p>Hidden-states of the model at the output of each layer plus the optional initial embedding outputs.</p>
</li>
</ul>
`,returnType:`<script context="module">export const metadata = 'undefined';<\/script>


<p><code>transformers.modeling_outputs.BaseModelOutputWithNoAttention</code> or <code>tuple(torch.FloatTensor)</code></p>
`}}),R=new at({props:{$$slots:{default:[dt]},$$scope:{ctx:F}}}),V=new Pe({props:{anchor:"transformers.SwiftFormerModel.forward.example",$$slots:{default:[ft]},$$scope:{ctx:F}}}),D=new de({props:{title:"SwiftFormerForImageClassification",local:"transformers.SwiftFormerForImageClassification",headingTag:"h2"}}),O=new ce({props:{name:"class transformers.SwiftFormerForImageClassification",anchor:"transformers.SwiftFormerForImageClassification",parameters:[{name:"config",val:": SwiftFormerConfig"}],parametersDescription:[{anchor:"transformers.SwiftFormerForImageClassification.config",description:`<strong>config</strong> (<a href="/docs/transformers/main/en/model_doc/swiftformer#transformers.SwiftFormerConfig">SwiftFormerConfig</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/swiftformer/modeling_swiftformer.py#L536"}}),K=new ce({props:{name:"forward",anchor:"transformers.SwiftFormerForImageClassification.forward",parameters:[{name:"pixel_values",val:": typing.Optional[torch.Tensor] = None"},{name:"labels",val:": typing.Optional[torch.Tensor] = None"},{name:"output_hidden_states",val:": typing.Optional[bool] = None"},{name:"return_dict",val:": typing.Optional[bool] = None"}],parametersDescription:[{anchor:"transformers.SwiftFormerForImageClassification.forward.pixel_values",description:`<strong>pixel_values</strong> (<code>torch.FloatTensor</code> of shape <code>(batch_size, num_channels, height, width)</code>) &#x2014;
Pixel values. Pixel values can be obtained using <a href="/docs/transformers/main/en/model_doc/auto#transformers.AutoImageProcessor">AutoImageProcessor</a>. See <a href="/docs/transformers/main/en/model_doc/deit#transformers.DeiTFeatureExtractor.__call__">ViTImageProcessor.<strong>call</strong>()</a>
for details.`,name:"pixel_values"},{anchor:"transformers.SwiftFormerForImageClassification.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.SwiftFormerForImageClassification.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.SwiftFormerForImageClassification.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/swiftformer/modeling_swiftformer.py#L553",returnDescription:`<script context="module">export const metadata = 'undefined';<\/script>


<p>A <a
  href="/docs/transformers/main/en/main_classes/output#transformers.modeling_outputs.ImageClassifierOutputWithNoAttention"
>transformers.modeling_outputs.ImageClassifierOutputWithNoAttention</a> or a tuple of
<code>torch.FloatTensor</code> (if <code>return_dict=False</code> is passed or when <code>config.return_dict=False</code>) comprising various
elements depending on the configuration (<a
  href="/docs/transformers/main/en/model_doc/swiftformer#transformers.SwiftFormerConfig"
>SwiftFormerConfig</a>) and inputs.</p>
<ul>
<li><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.</li>
<li><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).</li>
<li><strong>hidden_states</strong> (<code>tuple(torch.FloatTensor)</code>, <em>optional</em>, returned when <code>output_hidden_states=True</code> is passed or when <code>config.output_hidden_states=True</code>) — Tuple of <code>torch.FloatTensor</code> (one for the output of the embeddings, if the model has an embedding layer, +
one for the output of each stage) of shape <code>(batch_size, num_channels, height, width)</code>. Hidden-states (also
called feature maps) of the model at the output of each stage.</li>
</ul>
`,returnType:`<script context="module">export const metadata = 'undefined';<\/script>


<p><a
  href="/docs/transformers/main/en/main_classes/output#transformers.modeling_outputs.ImageClassifierOutputWithNoAttention"
>transformers.modeling_outputs.ImageClassifierOutputWithNoAttention</a> or <code>tuple(torch.FloatTensor)</code></p>
`}}),G=new at({props:{$$slots:{default:[pt]},$$scope:{ctx:F}}}),k=new Pe({props:{anchor:"transformers.SwiftFormerForImageClassification.forward.example",$$slots:{default:[ht]},$$scope:{ctx:F}}}),{c(){t=c("meta"),h=r(),l=c("p"),m=r(),w(p.$$.fragment),o=r(),w(u.$$.fragment),pe=r(),N=c("p"),N.innerHTML=Xe,he=r(),B=c("p"),B.textContent=Ee,ue=r(),z=c("p"),z.textContent=Qe,ge=r(),P=c("p"),P.innerHTML=Ye,we=r(),H=c("p"),H.textContent=Le,_e=r(),X=c("ul"),X.innerHTML=qe,be=r(),E=c("p"),E.innerHTML=Ae,ye=r(),w(Q.$$.fragment),Me=r(),$=c("div"),w(Y.$$.fragment),xe=r(),oe=c("p"),oe.innerHTML=De,Ue=r(),se=c("p"),se.innerHTML=Oe,je=r(),w(W.$$.fragment),ve=r(),w(L.$$.fragment),$e=r(),x=c("div"),w(q.$$.fragment),Je=r(),ae=c("p"),ae.innerHTML=Ke,Ze=r(),C=c("div"),w(A.$$.fragment),Ie=r(),ne=c("p"),ne.innerHTML=et,We=r(),w(R.$$.fragment),Re=r(),w(V.$$.fragment),Te=r(),w(D.$$.fragment),Fe=r(),T=c("div"),w(O.$$.fragment),Ve=r(),re=c("p"),re.textContent=tt,Ge=r(),ie=c("p"),ie.innerHTML=ot,ke=r(),S=c("div"),w(K.$$.fragment),Ne=r(),le=c("p"),le.innerHTML=st,Be=r(),w(G.$$.fragment),ze=r(),w(k.$$.fragment),Ce=r(),me=c("p"),this.h()},l(e){const s=mt("svelte-u9bgzb",document.head);t=d(s,"META",{name:!0,content:!0}),s.forEach(a),h=i(e),l=d(e,"P",{}),ee(l).forEach(a),m=i(e),_(p.$$.fragment,e),o=i(e),_(u.$$.fragment,e),pe=i(e),N=d(e,"P",{"data-svelte-h":!0}),g(N)!=="svelte-1xrpfhe"&&(N.innerHTML=Xe),he=i(e),B=d(e,"P",{"data-svelte-h":!0}),g(B)!=="svelte-q1qv2z"&&(B.textContent=Ee),ue=i(e),z=d(e,"P",{"data-svelte-h":!0}),g(z)!=="svelte-vfdo9a"&&(z.textContent=Qe),ge=i(e),P=d(e,"P",{"data-svelte-h":!0}),g(P)!=="svelte-1hgv92f"&&(P.innerHTML=Ye),we=i(e),H=d(e,"P",{"data-svelte-h":!0}),g(H)!=="svelte-axv494"&&(H.textContent=Le),_e=i(e),X=d(e,"UL",{"data-svelte-h":!0}),g(X)!=="svelte-iiv6x8"&&(X.innerHTML=qe),be=i(e),E=d(e,"P",{"data-svelte-h":!0}),g(E)!=="svelte-18uisef"&&(E.innerHTML=Ae),ye=i(e),_(Q.$$.fragment,e),Me=i(e),$=d(e,"DIV",{class:!0});var U=ee($);_(Y.$$.fragment,U),xe=i(U),oe=d(U,"P",{"data-svelte-h":!0}),g(oe)!=="svelte-1rvnpyv"&&(oe.innerHTML=De),Ue=i(U),se=d(U,"P",{"data-svelte-h":!0}),g(se)!=="svelte-o55m63"&&(se.innerHTML=Oe),je=i(U),_(W.$$.fragment,U),U.forEach(a),ve=i(e),_(L.$$.fragment,e),$e=i(e),x=d(e,"DIV",{class:!0});var I=ee(x);_(q.$$.fragment,I),Je=i(I),ae=d(I,"P",{"data-svelte-h":!0}),g(ae)!=="svelte-12h2za7"&&(ae.innerHTML=Ke),Ze=i(I),C=d(I,"DIV",{class:!0});var j=ee(C);_(A.$$.fragment,j),Ie=i(j),ne=d(j,"P",{"data-svelte-h":!0}),g(ne)!=="svelte-1lpypw3"&&(ne.innerHTML=et),We=i(j),_(R.$$.fragment,j),Re=i(j),_(V.$$.fragment,j),j.forEach(a),I.forEach(a),Te=i(e),_(D.$$.fragment,e),Fe=i(e),T=d(e,"DIV",{class:!0});var J=ee(T);_(O.$$.fragment,J),Ve=i(J),re=d(J,"P",{"data-svelte-h":!0}),g(re)!=="svelte-cokk7a"&&(re.textContent=tt),Ge=i(J),ie=d(J,"P",{"data-svelte-h":!0}),g(ie)!=="svelte-1gjh92c"&&(ie.innerHTML=ot),ke=i(J),S=d(J,"DIV",{class:!0});var Z=ee(S);_(K.$$.fragment,Z),Ne=i(Z),le=d(Z,"P",{"data-svelte-h":!0}),g(le)!=="svelte-ut67bx"&&(le.innerHTML=st),Be=i(Z),_(G.$$.fragment,Z),ze=i(Z),_(k.$$.fragment,Z),Z.forEach(a),J.forEach(a),Ce=i(e),me=d(e,"P",{}),ee(me).forEach(a),this.h()},h(){te(t,"name","hf:doc:metadata"),te(t,"content",gt),te($,"class","docstring border-l-2 border-t-2 pl-4 pt-3.5 border-gray-100 rounded-tl-xl mb-6 mt-8"),te(C,"class","docstring border-l-2 border-t-2 pl-4 pt-3.5 border-gray-100 rounded-tl-xl mb-6 mt-8"),te(x,"class","docstring border-l-2 border-t-2 pl-4 pt-3.5 border-gray-100 rounded-tl-xl mb-6 mt-8"),te(S,"class","docstring border-l-2 border-t-2 pl-4 pt-3.5 border-gray-100 rounded-tl-xl mb-6 mt-8"),te(T,"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,s){f(document.head,t),n(e,h,s),n(e,l,s),n(e,m,s),b(p,e,s),n(e,o,s),b(u,e,s),n(e,pe,s),n(e,N,s),n(e,he,s),n(e,B,s),n(e,ue,s),n(e,z,s),n(e,ge,s),n(e,P,s),n(e,we,s),n(e,H,s),n(e,_e,s),n(e,X,s),n(e,be,s),n(e,E,s),n(e,ye,s),b(Q,e,s),n(e,Me,s),n(e,$,s),b(Y,$,null),f($,xe),f($,oe),f($,Ue),f($,se),f($,je),b(W,$,null),n(e,ve,s),b(L,e,s),n(e,$e,s),n(e,x,s),b(q,x,null),f(x,Je),f(x,ae),f(x,Ze),f(x,C),b(A,C,null),f(C,Ie),f(C,ne),f(C,We),b(R,C,null),f(C,Re),b(V,C,null),n(e,Te,s),b(D,e,s),n(e,Fe,s),n(e,T,s),b(O,T,null),f(T,Ve),f(T,re),f(T,Ge),f(T,ie),f(T,ke),f(T,S),b(K,S,null),f(S,Ne),f(S,le),f(S,Be),b(G,S,null),f(S,ze),b(k,S,null),n(e,Ce,s),n(e,me,s),Se=!0},p(e,[s]){const U={};s&2&&(U.$$scope={dirty:s,ctx:e}),W.$set(U);const I={};s&2&&(I.$$scope={dirty:s,ctx:e}),R.$set(I);const j={};s&2&&(j.$$scope={dirty:s,ctx:e}),V.$set(j);const J={};s&2&&(J.$$scope={dirty:s,ctx:e}),G.$set(J);const Z={};s&2&&(Z.$$scope={dirty:s,ctx:e}),k.$set(Z)},i(e){Se||(y(p.$$.fragment,e),y(u.$$.fragment,e),y(Q.$$.fragment,e),y(Y.$$.fragment,e),y(W.$$.fragment,e),y(L.$$.fragment,e),y(q.$$.fragment,e),y(A.$$.fragment,e),y(R.$$.fragment,e),y(V.$$.fragment,e),y(D.$$.fragment,e),y(O.$$.fragment,e),y(K.$$.fragment,e),y(G.$$.fragment,e),y(k.$$.fragment,e),Se=!0)},o(e){M(p.$$.fragment,e),M(u.$$.fragment,e),M(Q.$$.fragment,e),M(Y.$$.fragment,e),M(W.$$.fragment,e),M(L.$$.fragment,e),M(q.$$.fragment,e),M(A.$$.fragment,e),M(R.$$.fragment,e),M(V.$$.fragment,e),M(D.$$.fragment,e),M(O.$$.fragment,e),M(K.$$.fragment,e),M(G.$$.fragment,e),M(k.$$.fragment,e),Se=!1},d(e){e&&(a(h),a(l),a(m),a(o),a(pe),a(N),a(he),a(B),a(ue),a(z),a(ge),a(P),a(we),a(H),a(_e),a(X),a(be),a(E),a(ye),a(Me),a($),a(ve),a($e),a(x),a(Te),a(Fe),a(T),a(Ce),a(me)),a(t),v(p,e),v(u,e),v(Q,e),v(Y),v(W),v(L,e),v(q),v(A),v(R),v(V),v(D,e),v(O),v(K),v(G),v(k)}}}const gt='{"title":"SwiftFormer","local":"swiftformer","sections":[{"title":"Overview","local":"overview","sections":[],"depth":2},{"title":"SwiftFormerConfig","local":"transformers.SwiftFormerConfig","sections":[],"depth":2},{"title":"SwiftFormerModel","local":"transformers.SwiftFormerModel","sections":[],"depth":2},{"title":"SwiftFormerForImageClassification","local":"transformers.SwiftFormerForImageClassification","sections":[],"depth":2}],"depth":1}';function wt(F){return rt(()=>{new URLSearchParams(window.location.search).get("fw")}),[]}class Ft extends it{constructor(t){super(),lt(this,t,wt,ut,nt,{})}}export{Ft as component};
