import{s as an,f as sn,o as rn,n as xt}from"../chunks/scheduler.9bc65507.js";import{S as ln,i as cn,g as a,s as r,u as b,A as pn,h as s,f as t,c as i,j as h,v,y as d,k as m,o as c,a as o,w as y,d as _,t as w,x as M}from"../chunks/index.78c82d43.js";import{T as mn}from"../chunks/Tip.87d55b76.js";import{D as Ut}from"../chunks/Docstring.f3d04bd2.js";import{C as lt}from"../chunks/CodeBlock.48618ec2.js";import{I as $e}from"../chunks/IconCopyLink.bedaa44d.js";import{E as on}from"../chunks/ExampleCodeBlock.872b014d.js";function dn(J){let p,U="Examples:",f,u,g;return u=new lt({props:{code:"ZnJvbSUyMHRyYW5zZm9ybWVycyUyMGltcG9ydCUyMFVwZXJOZXRDb25maWclMkMlMjBVcGVyTmV0Rm9yU2VtYW50aWNTZWdtZW50YXRpb24lMEElMEElMjMlMjBJbml0aWFsaXppbmclMjBhJTIwY29uZmlndXJhdGlvbiUwQWNvbmZpZ3VyYXRpb24lMjAlM0QlMjBVcGVyTmV0Q29uZmlnKCklMEElMEElMjMlMjBJbml0aWFsaXppbmclMjBhJTIwbW9kZWwlMjAod2l0aCUyMHJhbmRvbSUyMHdlaWdodHMpJTIwZnJvbSUyMHRoZSUyMGNvbmZpZ3VyYXRpb24lMEFtb2RlbCUyMCUzRCUyMFVwZXJOZXRGb3JTZW1hbnRpY1NlZ21lbnRhdGlvbihjb25maWd1cmF0aW9uKSUwQSUwQSUyMyUyMEFjY2Vzc2luZyUyMHRoZSUyMG1vZGVsJTIwY29uZmlndXJhdGlvbiUwQWNvbmZpZ3VyYXRpb24lMjAlM0QlMjBtb2RlbC5jb25maWc=",highlighted:`<span class="hljs-meta">&gt;&gt;&gt; </span><span class="hljs-keyword">from</span> transformers <span class="hljs-keyword">import</span> UperNetConfig, UperNetForSemanticSegmentation

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

<span class="hljs-meta">&gt;&gt;&gt; </span><span class="hljs-comment"># Initializing a model (with random weights) from the configuration</span>
<span class="hljs-meta">&gt;&gt;&gt; </span>model = UperNetForSemanticSegmentation(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(){p=a("p"),p.textContent=U,f=r(),b(u.$$.fragment)},l(l){p=s(l,"P",{"data-svelte-h":!0}),d(p)!=="svelte-kvfsh7"&&(p.textContent=U),f=i(l),v(u.$$.fragment,l)},m(l,x){o(l,p,x),o(l,f,x),y(u,l,x),g=!0},p:xt,i(l){g||(_(u.$$.fragment,l),g=!0)},o(l){w(u.$$.fragment,l),g=!1},d(l){l&&(t(p),t(f)),M(u,l)}}}function hn(J){let p,U=`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(){p=a("p"),p.innerHTML=U},l(f){p=s(f,"P",{"data-svelte-h":!0}),d(p)!=="svelte-fincs2"&&(p.innerHTML=U)},m(f,u){o(f,p,u)},p:xt,d(f){f&&t(p)}}}function un(J){let p,U="Examples:",f,u,g;return u=new lt({props:{code:"ZnJvbSUyMHRyYW5zZm9ybWVycyUyMGltcG9ydCUyMEF1dG9JbWFnZVByb2Nlc3NvciUyQyUyMFVwZXJOZXRGb3JTZW1hbnRpY1NlZ21lbnRhdGlvbiUwQWZyb20lMjBQSUwlMjBpbXBvcnQlMjBJbWFnZSUwQWZyb20lMjBodWdnaW5nZmFjZV9odWIlMjBpbXBvcnQlMjBoZl9odWJfZG93bmxvYWQlMEElMEFpbWFnZV9wcm9jZXNzb3IlMjAlM0QlMjBBdXRvSW1hZ2VQcm9jZXNzb3IuZnJvbV9wcmV0cmFpbmVkKCUyMm9wZW5tbWxhYiUyRnVwZXJuZXQtY29udm5leHQtdGlueSUyMiklMEFtb2RlbCUyMCUzRCUyMFVwZXJOZXRGb3JTZW1hbnRpY1NlZ21lbnRhdGlvbi5mcm9tX3ByZXRyYWluZWQoJTIyb3Blbm1tbGFiJTJGdXBlcm5ldC1jb252bmV4dC10aW55JTIyKSUwQSUwQWZpbGVwYXRoJTIwJTNEJTIwaGZfaHViX2Rvd25sb2FkKCUwQSUyMCUyMCUyMCUyMHJlcG9faWQlM0QlMjJoZi1pbnRlcm5hbC10ZXN0aW5nJTJGZml4dHVyZXNfYWRlMjBrJTIyJTJDJTIwZmlsZW5hbWUlM0QlMjJBREVfdmFsXzAwMDAwMDAxLmpwZyUyMiUyQyUyMHJlcG9fdHlwZSUzRCUyMmRhdGFzZXQlMjIlMEEpJTBBaW1hZ2UlMjAlM0QlMjBJbWFnZS5vcGVuKGZpbGVwYXRoKS5jb252ZXJ0KCUyMlJHQiUyMiklMEElMEFpbnB1dHMlMjAlM0QlMjBpbWFnZV9wcm9jZXNzb3IoaW1hZ2VzJTNEaW1hZ2UlMkMlMjByZXR1cm5fdGVuc29ycyUzRCUyMnB0JTIyKSUwQSUwQW91dHB1dHMlMjAlM0QlMjBtb2RlbCgqKmlucHV0cyklMEElMEFsb2dpdHMlMjAlM0QlMjBvdXRwdXRzLmxvZ2l0cyUyMCUyMCUyMyUyMHNoYXBlJTIwKGJhdGNoX3NpemUlMkMlMjBudW1fbGFiZWxzJTJDJTIwaGVpZ2h0JTJDJTIwd2lkdGgpJTBBbGlzdChsb2dpdHMuc2hhcGUp",highlighted:`<span class="hljs-meta">&gt;&gt;&gt; </span><span class="hljs-keyword">from</span> transformers <span class="hljs-keyword">import</span> AutoImageProcessor, UperNetForSemanticSegmentation
<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">from</span> huggingface_hub <span class="hljs-keyword">import</span> hf_hub_download

<span class="hljs-meta">&gt;&gt;&gt; </span>image_processor = AutoImageProcessor.from_pretrained(<span class="hljs-string">&quot;openmmlab/upernet-convnext-tiny&quot;</span>)
<span class="hljs-meta">&gt;&gt;&gt; </span>model = UperNetForSemanticSegmentation.from_pretrained(<span class="hljs-string">&quot;openmmlab/upernet-convnext-tiny&quot;</span>)

<span class="hljs-meta">&gt;&gt;&gt; </span>filepath = hf_hub_download(
<span class="hljs-meta">... </span>    repo_id=<span class="hljs-string">&quot;hf-internal-testing/fixtures_ade20k&quot;</span>, filename=<span class="hljs-string">&quot;ADE_val_00000001.jpg&quot;</span>, repo_type=<span class="hljs-string">&quot;dataset&quot;</span>
<span class="hljs-meta">... </span>)
<span class="hljs-meta">&gt;&gt;&gt; </span>image = Image.<span class="hljs-built_in">open</span>(filepath).convert(<span class="hljs-string">&quot;RGB&quot;</span>)

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

<span class="hljs-meta">&gt;&gt;&gt; </span>outputs = model(**inputs)

<span class="hljs-meta">&gt;&gt;&gt; </span>logits = outputs.logits  <span class="hljs-comment"># shape (batch_size, num_labels, height, width)</span>
<span class="hljs-meta">&gt;&gt;&gt; </span><span class="hljs-built_in">list</span>(logits.shape)
[<span class="hljs-number">1</span>, <span class="hljs-number">150</span>, <span class="hljs-number">512</span>, <span class="hljs-number">512</span>]`}}),{c(){p=a("p"),p.textContent=U,f=r(),b(u.$$.fragment)},l(l){p=s(l,"P",{"data-svelte-h":!0}),d(p)!=="svelte-kvfsh7"&&(p.textContent=U),f=i(l),v(u.$$.fragment,l)},m(l,x){o(l,p,x),o(l,f,x),y(u,l,x),g=!0},p:xt,i(l){g||(_(u.$$.fragment,l),g=!0)},o(l){w(u.$$.fragment,l),g=!1},d(l){l&&(t(p),t(f)),M(u,l)}}}function fn(J){let p,U,f,u,g,l,x,H,ct,ue,$t="UPerNet",We,j,W,Ce,Q,pt,fe,Ct="Overview",Fe,A,Nt=`The UPerNet model was proposed in <a href="https://arxiv.org/abs/1807.10221" rel="nofollow">Unified Perceptual Parsing for Scene Understanding</a>
by Tete Xiao, Yingcheng Liu, Bolei Zhou, Yuning Jiang, Jian Sun. UPerNet is a general framework to effectively segment
a wide range of concepts from images, leveraging any vision backbone like <a href="convnext">ConvNeXt</a> or <a href="swin">Swin</a>.`,Pe,Y,jt="The abstract from the paper is the following:",Ee,q,Tt="<em>Humans recognize the visual world at multiple levels: we effortlessly categorize scenes and detect objects inside, while also identifying the textures and surfaces of the objects along with their different compositional parts. In this paper, we study a new task called Unified Perceptual Parsing, which requires the machine vision systems to recognize as many visual concepts as possible from a given image. A multi-task framework called UPerNet and a training strategy are developed to learn from heterogeneous image annotations. We benchmark our framework on Unified Perceptual Parsing and show that it is able to effectively segment a wide range of concepts from images. The trained networks are further applied to discover visual knowledge in natural scenes.</em>",Re,F,Zt,Ve,L,St='UPerNet framework. Taken from the <a href="https://arxiv.org/abs/1807.10221">original paper</a>.',Ge,O,kt='This model was contributed by <a href="https://huggingface.co/nielsr" rel="nofollow">nielsr</a>. The original code is based on OpenMMLab’s mmsegmentation <a href="https://github.com/open-mmlab/mmsegmentation/blob/master/mmseg/models/decode_heads/uper_head.py" rel="nofollow">here</a>.',ze,T,P,Ne,D,mt,ge,Jt="Resources",Xe,K,Wt="A list of official Hugging Face and community (indicated by 🌎) resources to help you get started with UPerNet.",Be,ee,Ft='<li>Demo notebooks for UPerNet can be found <a href="https://github.com/NielsRogge/Transformers-Tutorials/tree/master/UPerNet" rel="nofollow">here</a>.</li> <li><a href="/docs/transformers/v4.33.3/en/model_doc/upernet#transformers.UperNetForSemanticSegmentation">UperNetForSemanticSegmentation</a> is supported by this <a href="https://github.com/huggingface/transformers/tree/main/examples/pytorch/semantic-segmentation" rel="nofollow">example script</a> and <a href="https://colab.research.google.com/github/huggingface/notebooks/blob/main/examples/semantic_segmentation.ipynb" rel="nofollow">notebook</a>.</li> <li>See also: <a href="../tasks/semantic_segmentation">Semantic segmentation task guide</a></li>',Ie,te,Pt="If you’re interested in submitting a resource to be included here, please feel free to open a Pull Request and we’ll review it! The resource should ideally demonstrate something new instead of duplicating an existing resource.",He,Z,E,je,ne,dt,be,Et="Usage",Qe,oe,Rt="UPerNet is a general framework for semantic segmentation. It can be used with any vision backbone, like so:",Ae,ae,Ye,se,Vt='To use another vision backbone, like <a href="convnext">ConvNeXt</a>, simply instantiate the model with the appropriate backbone:',qe,re,Le,ie,Gt="Note that this will randomly initialize all the weights of the model.",Oe,S,R,Te,le,ht,ve,zt="UperNetConfig",De,$,ce,ut,ye,Xt=`This is the configuration class to store the configuration of an <a href="/docs/transformers/v4.33.3/en/model_doc/upernet#transformers.UperNetForSemanticSegmentation">UperNetForSemanticSegmentation</a>. It is used to
instantiate an UperNet 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 UperNet
<a href="https://huggingface.co/openmmlab/upernet-convnext-tiny" rel="nofollow">openmmlab/upernet-convnext-tiny</a> architecture.`,ft,_e,Bt=`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.`,gt,V,Ke,k,G,Ze,pe,bt,we,It="UperNetForSemanticSegmentation",et,N,me,vt,Me,Ht="UperNet framework leveraging any vision backbone e.g. for ADE20k, CityScapes.",yt,C,de,_t,Ue,Qt='The <a href="/docs/transformers/v4.33.3/en/model_doc/upernet#transformers.UperNetForSemanticSegmentation">UperNetForSemanticSegmentation</a> forward method, overrides the <code>__call__</code> special method.',wt,z,Mt,X,tt,Se,nt;return H=new $e({}),Q=new $e({}),D=new $e({}),ne=new $e({}),ae=new lt({props:{code:"ZnJvbSUyMHRyYW5zZm9ybWVycyUyMGltcG9ydCUyMFN3aW5Db25maWclMkMlMjBVcGVyTmV0Q29uZmlnJTJDJTIwVXBlck5ldEZvclNlbWFudGljU2VnbWVudGF0aW9uJTBBJTBBYmFja2JvbmVfY29uZmlnJTIwJTNEJTIwU3dpbkNvbmZpZyhvdXRfZmVhdHVyZXMlM0QlNUIlMjJzdGFnZTElMjIlMkMlMjAlMjJzdGFnZTIlMjIlMkMlMjAlMjJzdGFnZTMlMjIlMkMlMjAlMjJzdGFnZTQlMjIlNUQpJTBBJTBBY29uZmlnJTIwJTNEJTIwVXBlck5ldENvbmZpZyhiYWNrYm9uZV9jb25maWclM0RiYWNrYm9uZV9jb25maWcpJTBBbW9kZWwlMjAlM0QlMjBVcGVyTmV0Rm9yU2VtYW50aWNTZWdtZW50YXRpb24oY29uZmlnKQ==",highlighted:`<span class="hljs-keyword">from</span> transformers <span class="hljs-keyword">import</span> SwinConfig, UperNetConfig, UperNetForSemanticSegmentation

backbone_config = SwinConfig(out_features=[<span class="hljs-string">&quot;stage1&quot;</span>, <span class="hljs-string">&quot;stage2&quot;</span>, <span class="hljs-string">&quot;stage3&quot;</span>, <span class="hljs-string">&quot;stage4&quot;</span>])

config = UperNetConfig(backbone_config=backbone_config)
model = UperNetForSemanticSegmentation(config)`}}),re=new lt({props:{code:"ZnJvbSUyMHRyYW5zZm9ybWVycyUyMGltcG9ydCUyMENvbnZOZXh0Q29uZmlnJTJDJTIwVXBlck5ldENvbmZpZyUyQyUyMFVwZXJOZXRGb3JTZW1hbnRpY1NlZ21lbnRhdGlvbiUwQSUwQWJhY2tib25lX2NvbmZpZyUyMCUzRCUyMENvbnZOZXh0Q29uZmlnKG91dF9mZWF0dXJlcyUzRCU1QiUyMnN0YWdlMSUyMiUyQyUyMCUyMnN0YWdlMiUyMiUyQyUyMCUyMnN0YWdlMyUyMiUyQyUyMCUyMnN0YWdlNCUyMiU1RCklMEElMEFjb25maWclMjAlM0QlMjBVcGVyTmV0Q29uZmlnKGJhY2tib25lX2NvbmZpZyUzRGJhY2tib25lX2NvbmZpZyklMEFtb2RlbCUyMCUzRCUyMFVwZXJOZXRGb3JTZW1hbnRpY1NlZ21lbnRhdGlvbihjb25maWcp",highlighted:`<span class="hljs-keyword">from</span> transformers <span class="hljs-keyword">import</span> ConvNextConfig, UperNetConfig, UperNetForSemanticSegmentation

backbone_config = ConvNextConfig(out_features=[<span class="hljs-string">&quot;stage1&quot;</span>, <span class="hljs-string">&quot;stage2&quot;</span>, <span class="hljs-string">&quot;stage3&quot;</span>, <span class="hljs-string">&quot;stage4&quot;</span>])

config = UperNetConfig(backbone_config=backbone_config)
model = UperNetForSemanticSegmentation(config)`}}),le=new $e({}),ce=new Ut({props:{name:"class transformers.UperNetConfig",anchor:"transformers.UperNetConfig",parameters:[{name:"backbone_config",val:" = None"},{name:"hidden_size",val:" = 512"},{name:"initializer_range",val:" = 0.02"},{name:"pool_scales",val:" = [1, 2, 3, 6]"},{name:"use_auxiliary_head",val:" = True"},{name:"auxiliary_loss_weight",val:" = 0.4"},{name:"auxiliary_in_channels",val:" = 384"},{name:"auxiliary_channels",val:" = 256"},{name:"auxiliary_num_convs",val:" = 1"},{name:"auxiliary_concat_input",val:" = False"},{name:"loss_ignore_index",val:" = 255"},{name:"**kwargs",val:""}],parametersDescription:[{anchor:"transformers.UperNetConfig.backbone_config",description:`<strong>backbone_config</strong> (<code>PretrainedConfig</code> or <code>dict</code>, <em>optional</em>, defaults to <code>ResNetConfig()</code>) &#x2014;
The configuration of the backbone model.`,name:"backbone_config"},{anchor:"transformers.UperNetConfig.hidden_size",description:`<strong>hidden_size</strong> (<code>int</code>, <em>optional</em>, defaults to 512) &#x2014;
The number of hidden units in the convolutional layers.`,name:"hidden_size"},{anchor:"transformers.UperNetConfig.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.UperNetConfig.pool_scales",description:`<strong>pool_scales</strong> (<code>Tuple[int]</code>, <em>optional</em>, defaults to <code>[1, 2, 3, 6]</code>) &#x2014;
Pooling scales used in Pooling Pyramid Module applied on the last feature map.`,name:"pool_scales"},{anchor:"transformers.UperNetConfig.use_auxiliary_head",description:`<strong>use_auxiliary_head</strong> (<code>bool</code>, <em>optional</em>, defaults to <code>True</code>) &#x2014;
Whether to use an auxiliary head during training.`,name:"use_auxiliary_head"},{anchor:"transformers.UperNetConfig.auxiliary_loss_weight",description:`<strong>auxiliary_loss_weight</strong> (<code>float</code>, <em>optional</em>, defaults to 0.4) &#x2014;
Weight of the cross-entropy loss of the auxiliary head.`,name:"auxiliary_loss_weight"},{anchor:"transformers.UperNetConfig.auxiliary_channels",description:`<strong>auxiliary_channels</strong> (<code>int</code>, <em>optional</em>, defaults to 256) &#x2014;
Number of channels to use in the auxiliary head.`,name:"auxiliary_channels"},{anchor:"transformers.UperNetConfig.auxiliary_num_convs",description:`<strong>auxiliary_num_convs</strong> (<code>int</code>, <em>optional</em>, defaults to 1) &#x2014;
Number of convolutional layers to use in the auxiliary head.`,name:"auxiliary_num_convs"},{anchor:"transformers.UperNetConfig.auxiliary_concat_input",description:`<strong>auxiliary_concat_input</strong> (<code>bool</code>, <em>optional</em>, defaults to <code>False</code>) &#x2014;
Whether to concatenate the output of the auxiliary head with the input before the classification layer.`,name:"auxiliary_concat_input"},{anchor:"transformers.UperNetConfig.loss_ignore_index",description:`<strong>loss_ignore_index</strong> (<code>int</code>, <em>optional</em>, defaults to 255) &#x2014;
The index that is ignored by the loss function.`,name:"loss_ignore_index"}],source:"https://github.com/huggingface/transformers/blob/v4.33.3/src/transformers/models/upernet/configuration_upernet.py#L26"}}),V=new on({props:{anchor:"transformers.UperNetConfig.example",$$slots:{default:[dn]},$$scope:{ctx:J}}}),pe=new $e({}),me=new Ut({props:{name:"class transformers.UperNetForSemanticSegmentation",anchor:"transformers.UperNetForSemanticSegmentation",parameters:[{name:"config",val:""}],parametersDescription:[{anchor:"transformers.UperNetForSemanticSegmentation.This",description:"<strong>This</strong> model is a PyTorch [torch.nn.Module](https &#x2014;//pytorch.org/docs/stable/nn.html#torch.nn.Module) sub-class. Use",name:"This"},{anchor:"transformers.UperNetForSemanticSegmentation.it",description:`<strong>it</strong> as a regular PyTorch Module and refer to the PyTorch documentation for all matter related to general usage and &#x2014;
behavior. &#x2014;
config (<a href="/docs/transformers/v4.33.3/en/model_doc/upernet#transformers.UperNetConfig">UperNetConfig</a>): 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:"it"}],source:"https://github.com/huggingface/transformers/blob/v4.33.3/src/transformers/models/upernet/modeling_upernet.py#L353"}}),de=new Ut({props:{name:"forward",anchor:"transformers.UperNetForSemanticSegmentation.forward",parameters:[{name:"pixel_values",val:": typing.Optional[torch.Tensor] = None"},{name:"output_attentions",val:": typing.Optional[bool] = None"},{name:"output_hidden_states",val:": typing.Optional[bool] = None"},{name:"labels",val:": typing.Optional[torch.Tensor] = None"},{name:"return_dict",val:": typing.Optional[bool] = None"}],parametersDescription:[{anchor:"transformers.UperNetForSemanticSegmentation.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. Padding will be ignored by default should you provide it. Pixel values can be obtained using
<a href="/docs/transformers/v4.33.3/en/model_doc/auto#transformers.AutoImageProcessor">AutoImageProcessor</a>. See <a href="/docs/transformers/v4.33.3/en/model_doc/segformer#transformers.SegformerFeatureExtractor.__call__">SegformerImageProcessor.<strong>call</strong>()</a> for details.`,name:"pixel_values"},{anchor:"transformers.UperNetForSemanticSegmentation.forward.output_attentions",description:`<strong>output_attentions</strong> (<code>bool</code>, <em>optional</em>) &#x2014;
Whether or not to return the attentions tensors of all attention layers in case the backbone has them. See
<code>attentions</code> under returned tensors for more detail.`,name:"output_attentions"},{anchor:"transformers.UperNetForSemanticSegmentation.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 of the backbone. See <code>hidden_states</code> under
returned tensors for more detail.`,name:"output_hidden_states"},{anchor:"transformers.UperNetForSemanticSegmentation.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.UperNetForSemanticSegmentation.forward.labels",description:`<strong>labels</strong> (<code>torch.LongTensor</code> of shape <code>(batch_size, height, width)</code>, <em>optional</em>) &#x2014;
Ground truth semantic segmentation maps for computing the loss. Indices should be in <code>[0, ..., config.num_labels - 1]</code>. 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/upernet/modeling_upernet.py#L366",returnDescription:`
<p>A <a
  href="/docs/transformers/v4.33.3/en/main_classes/output#transformers.modeling_outputs.SemanticSegmenterOutput"
>transformers.modeling_outputs.SemanticSegmenterOutput</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/v4.33.3/en/model_doc/upernet#transformers.UperNetConfig"
>UperNetConfig</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, logits_height, logits_width)</code>) — Classification scores for each pixel.</p>
<Tip warning={true}>
<p>The logits returned do not necessarily have the same size as the <code>pixel_values</code> passed as inputs. This is
to avoid doing two interpolations and lose some quality when a user needs to resize the logits to the
original image size as post-processing. You should always check your logits shape and resize as needed.</p>
</Tip>
</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, patch_size, hidden_size)</code>.</p>
<p>Hidden-states of the model at the output of each layer plus the optional initial embedding outputs.</p>
</li>
<li>
<p><strong>attentions</strong> (<code>tuple(torch.FloatTensor)</code>, <em>optional</em>, returned when <code>output_attentions=True</code> is passed or when <code>config.output_attentions=True</code>) — Tuple of <code>torch.FloatTensor</code> (one for each layer) of shape <code>(batch_size, num_heads, patch_size, sequence_length)</code>.</p>
<p>Attentions weights after the attention softmax, used to compute the weighted average in the self-attention
heads.</p>
</li>
</ul>
`,returnType:`
<p><a
  href="/docs/transformers/v4.33.3/en/main_classes/output#transformers.modeling_outputs.SemanticSegmenterOutput"
>transformers.modeling_outputs.SemanticSegmenterOutput</a> or <code>tuple(torch.FloatTensor)</code></p>
`}}),z=new mn({props:{$$slots:{default:[hn]},$$scope:{ctx:J}}}),X=new on({props:{anchor:"transformers.UperNetForSemanticSegmentation.forward.example",$$slots:{default:[un]},$$scope:{ctx:J}}}),{c(){p=a("meta"),U=r(),f=a("p"),u=r(),g=a("h1"),l=a("a"),x=a("span"),b(H.$$.fragment),ct=r(),ue=a("span"),ue.textContent=$t,We=r(),j=a("h2"),W=a("a"),Ce=a("span"),b(Q.$$.fragment),pt=r(),fe=a("span"),fe.textContent=Ct,Fe=r(),A=a("p"),A.innerHTML=Nt,Pe=r(),Y=a("p"),Y.textContent=jt,Ee=r(),q=a("p"),q.innerHTML=Tt,Re=r(),F=a("img"),Ve=r(),L=a("small"),L.innerHTML=St,Ge=r(),O=a("p"),O.innerHTML=kt,ze=r(),T=a("h2"),P=a("a"),Ne=a("span"),b(D.$$.fragment),mt=r(),ge=a("span"),ge.textContent=Jt,Xe=r(),K=a("p"),K.textContent=Wt,Be=r(),ee=a("ul"),ee.innerHTML=Ft,Ie=r(),te=a("p"),te.textContent=Pt,He=r(),Z=a("h2"),E=a("a"),je=a("span"),b(ne.$$.fragment),dt=r(),be=a("span"),be.textContent=Et,Qe=r(),oe=a("p"),oe.textContent=Rt,Ae=r(),b(ae.$$.fragment),Ye=r(),se=a("p"),se.innerHTML=Vt,qe=r(),b(re.$$.fragment),Le=r(),ie=a("p"),ie.textContent=Gt,Oe=r(),S=a("h2"),R=a("a"),Te=a("span"),b(le.$$.fragment),ht=r(),ve=a("span"),ve.textContent=zt,De=r(),$=a("div"),b(ce.$$.fragment),ut=r(),ye=a("p"),ye.innerHTML=Xt,ft=r(),_e=a("p"),_e.innerHTML=Bt,gt=r(),b(V.$$.fragment),Ke=r(),k=a("h2"),G=a("a"),Ze=a("span"),b(pe.$$.fragment),bt=r(),we=a("span"),we.textContent=It,et=r(),N=a("div"),b(me.$$.fragment),vt=r(),Me=a("p"),Me.textContent=Ht,yt=r(),C=a("div"),b(de.$$.fragment),_t=r(),Ue=a("p"),Ue.innerHTML=Qt,wt=r(),b(z.$$.fragment),Mt=r(),b(X.$$.fragment),tt=r(),Se=a("p"),this.h()},l(e){const n=pn("svelte-1phssyn",document.head);p=s(n,"META",{name:!0,content:!0}),n.forEach(t),U=i(e),f=s(e,"P",{}),h(f).forEach(t),u=i(e),g=s(e,"H1",{class:!0});var he=h(g);l=s(he,"A",{id:!0,class:!0,href:!0});var ke=h(l);x=s(ke,"SPAN",{});var Je=h(x);v(H.$$.fragment,Je),Je.forEach(t),ke.forEach(t),ct=i(he),ue=s(he,"SPAN",{"data-svelte-h":!0}),d(ue)!=="svelte-1gk4oz2"&&(ue.textContent=$t),he.forEach(t),We=i(e),j=s(e,"H2",{class:!0});var ot=h(j);W=s(ot,"A",{id:!0,class:!0,href:!0});var At=h(W);Ce=s(At,"SPAN",{});var Yt=h(Ce);v(Q.$$.fragment,Yt),Yt.forEach(t),At.forEach(t),pt=i(ot),fe=s(ot,"SPAN",{"data-svelte-h":!0}),d(fe)!=="svelte-1jsw1pg"&&(fe.textContent=Ct),ot.forEach(t),Fe=i(e),A=s(e,"P",{"data-svelte-h":!0}),d(A)!=="svelte-1c4g37v"&&(A.innerHTML=Nt),Pe=i(e),Y=s(e,"P",{"data-svelte-h":!0}),d(Y)!=="svelte-vfdo9a"&&(Y.textContent=jt),Ee=i(e),q=s(e,"P",{"data-svelte-h":!0}),d(q)!=="svelte-1k7ta1y"&&(q.innerHTML=Tt),Re=i(e),F=s(e,"IMG",{src:!0,alt:!0,width:!0}),Ve=i(e),L=s(e,"SMALL",{"data-svelte-h":!0}),d(L)!=="svelte-vh2z7s"&&(L.innerHTML=St),Ge=i(e),O=s(e,"P",{"data-svelte-h":!0}),d(O)!=="svelte-1xqy3xr"&&(O.innerHTML=kt),ze=i(e),T=s(e,"H2",{class:!0});var at=h(T);P=s(at,"A",{id:!0,class:!0,href:!0});var qt=h(P);Ne=s(qt,"SPAN",{});var Lt=h(Ne);v(D.$$.fragment,Lt),Lt.forEach(t),qt.forEach(t),mt=i(at),ge=s(at,"SPAN",{"data-svelte-h":!0}),d(ge)!=="svelte-w4zzv6"&&(ge.textContent=Jt),at.forEach(t),Xe=i(e),K=s(e,"P",{"data-svelte-h":!0}),d(K)!=="svelte-108fh4w"&&(K.textContent=Wt),Be=i(e),ee=s(e,"UL",{"data-svelte-h":!0}),d(ee)!=="svelte-kzs4qq"&&(ee.innerHTML=Ft),Ie=i(e),te=s(e,"P",{"data-svelte-h":!0}),d(te)!=="svelte-1xesile"&&(te.textContent=Pt),He=i(e),Z=s(e,"H2",{class:!0});var st=h(Z);E=s(st,"A",{id:!0,class:!0,href:!0});var Ot=h(E);je=s(Ot,"SPAN",{});var Dt=h(je);v(ne.$$.fragment,Dt),Dt.forEach(t),Ot.forEach(t),dt=i(st),be=s(st,"SPAN",{"data-svelte-h":!0}),d(be)!=="svelte-jwh4bg"&&(be.textContent=Et),st.forEach(t),Qe=i(e),oe=s(e,"P",{"data-svelte-h":!0}),d(oe)!=="svelte-gv2geu"&&(oe.textContent=Rt),Ae=i(e),v(ae.$$.fragment,e),Ye=i(e),se=s(e,"P",{"data-svelte-h":!0}),d(se)!=="svelte-1ffmd3f"&&(se.innerHTML=Vt),qe=i(e),v(re.$$.fragment,e),Le=i(e),ie=s(e,"P",{"data-svelte-h":!0}),d(ie)!=="svelte-a05sd1"&&(ie.textContent=Gt),Oe=i(e),S=s(e,"H2",{class:!0});var rt=h(S);R=s(rt,"A",{id:!0,class:!0,href:!0});var Kt=h(R);Te=s(Kt,"SPAN",{});var en=h(Te);v(le.$$.fragment,en),en.forEach(t),Kt.forEach(t),ht=i(rt),ve=s(rt,"SPAN",{"data-svelte-h":!0}),d(ve)!=="svelte-1obxhy0"&&(ve.textContent=zt),rt.forEach(t),De=i(e),$=s(e,"DIV",{class:!0});var B=h($);v(ce.$$.fragment,B),ut=i(B),ye=s(B,"P",{"data-svelte-h":!0}),d(ye)!=="svelte-1aibhie"&&(ye.innerHTML=Xt),ft=i(B),_e=s(B,"P",{"data-svelte-h":!0}),d(_e)!=="svelte-cfh5wl"&&(_e.innerHTML=Bt),gt=i(B),v(V.$$.fragment,B),B.forEach(t),Ke=i(e),k=s(e,"H2",{class:!0});var it=h(k);G=s(it,"A",{id:!0,class:!0,href:!0});var tn=h(G);Ze=s(tn,"SPAN",{});var nn=h(Ze);v(pe.$$.fragment,nn),nn.forEach(t),tn.forEach(t),bt=i(it),we=s(it,"SPAN",{"data-svelte-h":!0}),d(we)!=="svelte-1m934e7"&&(we.textContent=It),it.forEach(t),et=i(e),N=s(e,"DIV",{class:!0});var xe=h(N);v(me.$$.fragment,xe),vt=i(xe),Me=s(xe,"P",{"data-svelte-h":!0}),d(Me)!=="svelte-ohcumq"&&(Me.textContent=Ht),yt=i(xe),C=s(xe,"DIV",{class:!0});var I=h(C);v(de.$$.fragment,I),_t=i(I),Ue=s(I,"P",{"data-svelte-h":!0}),d(Ue)!=="svelte-u983a6"&&(Ue.innerHTML=Qt),wt=i(I),v(z.$$.fragment,I),Mt=i(I),v(X.$$.fragment,I),I.forEach(t),xe.forEach(t),tt=i(e),Se=s(e,"P",{}),h(Se).forEach(t),this.h()},h(){m(p,"name","hf:doc:metadata"),m(p,"content",JSON.stringify(gn)),m(l,"id","upernet"),m(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"),m(l,"href","#upernet"),m(g,"class","relative group"),m(W,"id","overview"),m(W,"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"),m(W,"href","#overview"),m(j,"class","relative group"),sn(F.src,Zt="https://huggingface.co/datasets/huggingface/documentation-images/resolve/main/transformers/model_doc/upernet_architecture.jpg")||m(F,"src",Zt),m(F,"alt","drawing"),m(F,"width","600"),m(P,"id","resources"),m(P,"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"),m(P,"href","#resources"),m(T,"class","relative group"),m(E,"id","usage"),m(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"),m(E,"href","#usage"),m(Z,"class","relative group"),m(R,"id","transformers.UperNetConfig"),m(R,"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"),m(R,"href","#transformers.UperNetConfig"),m(S,"class","relative group"),m($,"class","docstring border-l-2 border-t-2 pl-4 pt-3.5 border-gray-100 rounded-tl-xl mb-6 mt-8"),m(G,"id","transformers.UperNetForSemanticSegmentation"),m(G,"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"),m(G,"href","#transformers.UperNetForSemanticSegmentation"),m(k,"class","relative group"),m(C,"class","docstring border-l-2 border-t-2 pl-4 pt-3.5 border-gray-100 rounded-tl-xl mb-6 mt-8"),m(N,"class","docstring border-l-2 border-t-2 pl-4 pt-3.5 border-gray-100 rounded-tl-xl mb-6 mt-8")},m(e,n){c(document.head,p),o(e,U,n),o(e,f,n),o(e,u,n),o(e,g,n),c(g,l),c(l,x),y(H,x,null),c(g,ct),c(g,ue),o(e,We,n),o(e,j,n),c(j,W),c(W,Ce),y(Q,Ce,null),c(j,pt),c(j,fe),o(e,Fe,n),o(e,A,n),o(e,Pe,n),o(e,Y,n),o(e,Ee,n),o(e,q,n),o(e,Re,n),o(e,F,n),o(e,Ve,n),o(e,L,n),o(e,Ge,n),o(e,O,n),o(e,ze,n),o(e,T,n),c(T,P),c(P,Ne),y(D,Ne,null),c(T,mt),c(T,ge),o(e,Xe,n),o(e,K,n),o(e,Be,n),o(e,ee,n),o(e,Ie,n),o(e,te,n),o(e,He,n),o(e,Z,n),c(Z,E),c(E,je),y(ne,je,null),c(Z,dt),c(Z,be),o(e,Qe,n),o(e,oe,n),o(e,Ae,n),y(ae,e,n),o(e,Ye,n),o(e,se,n),o(e,qe,n),y(re,e,n),o(e,Le,n),o(e,ie,n),o(e,Oe,n),o(e,S,n),c(S,R),c(R,Te),y(le,Te,null),c(S,ht),c(S,ve),o(e,De,n),o(e,$,n),y(ce,$,null),c($,ut),c($,ye),c($,ft),c($,_e),c($,gt),y(V,$,null),o(e,Ke,n),o(e,k,n),c(k,G),c(G,Ze),y(pe,Ze,null),c(k,bt),c(k,we),o(e,et,n),o(e,N,n),y(me,N,null),c(N,vt),c(N,Me),c(N,yt),c(N,C),y(de,C,null),c(C,_t),c(C,Ue),c(C,wt),y(z,C,null),c(C,Mt),y(X,C,null),o(e,tt,n),o(e,Se,n),nt=!0},p(e,[n]){const he={};n&2&&(he.$$scope={dirty:n,ctx:e}),V.$set(he);const ke={};n&2&&(ke.$$scope={dirty:n,ctx:e}),z.$set(ke);const Je={};n&2&&(Je.$$scope={dirty:n,ctx:e}),X.$set(Je)},i(e){nt||(_(H.$$.fragment,e),_(Q.$$.fragment,e),_(D.$$.fragment,e),_(ne.$$.fragment,e),_(ae.$$.fragment,e),_(re.$$.fragment,e),_(le.$$.fragment,e),_(ce.$$.fragment,e),_(V.$$.fragment,e),_(pe.$$.fragment,e),_(me.$$.fragment,e),_(de.$$.fragment,e),_(z.$$.fragment,e),_(X.$$.fragment,e),nt=!0)},o(e){w(H.$$.fragment,e),w(Q.$$.fragment,e),w(D.$$.fragment,e),w(ne.$$.fragment,e),w(ae.$$.fragment,e),w(re.$$.fragment,e),w(le.$$.fragment,e),w(ce.$$.fragment,e),w(V.$$.fragment,e),w(pe.$$.fragment,e),w(me.$$.fragment,e),w(de.$$.fragment,e),w(z.$$.fragment,e),w(X.$$.fragment,e),nt=!1},d(e){e&&(t(U),t(f),t(u),t(g),t(We),t(j),t(Fe),t(A),t(Pe),t(Y),t(Ee),t(q),t(Re),t(F),t(Ve),t(L),t(Ge),t(O),t(ze),t(T),t(Xe),t(K),t(Be),t(ee),t(Ie),t(te),t(He),t(Z),t(Qe),t(oe),t(Ae),t(Ye),t(se),t(qe),t(Le),t(ie),t(Oe),t(S),t(De),t($),t(Ke),t(k),t(et),t(N),t(tt),t(Se)),t(p),M(H),M(Q),M(D),M(ne),M(ae,e),M(re,e),M(le),M(ce),M(V),M(pe),M(me),M(de),M(z),M(X)}}}const gn={local:"upernet",sections:[{local:"overview",title:"Overview"},{local:"resources",title:"Resources"},{local:"usage",title:"Usage"},{local:"transformers.UperNetConfig",title:"UperNetConfig"},{local:"transformers.UperNetForSemanticSegmentation",title:"UperNetForSemanticSegmentation"}],title:"UPerNet"};function bn(J){return rn(()=>{new URLSearchParams(window.location.search).get("fw")}),[]}class $n extends ln{constructor(p){super(),cn(this,p,bn,fn,an,{})}}export{$n as component};
