import{s as ot,f as st,o as rt,n as Xe}from"../chunks/scheduler.9bc65507.js";import{S as it,i as lt,g as l,s,r as g,A as mt,h as m,f as n,c as r,j as ie,u,x as d,k as W,y as w,a,v as h,d as b,t as y,w as _}from"../chunks/index.707bf1b6.js";import{T as ct}from"../chunks/Tip.c2ecdbf4.js";import{D as Pe}from"../chunks/Docstring.17db21ae.js";import{C as Ce}from"../chunks/CodeBlock.54a9f38d.js";import{E as at}from"../chunks/ExampleCodeBlock.4f515aa9.js";import{H as se}from"../chunks/Heading.342b1fa6.js";function pt(Z){let i,v="Examples:",p,c,f;return c=new Ce({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`,wrap:!1}}),{c(){i=l("p"),i.textContent=v,p=s(),g(c.$$.fragment)},l(o){i=m(o,"P",{"data-svelte-h":!0}),d(i)!=="svelte-kvfsh7"&&(i.textContent=v),p=r(o),u(c.$$.fragment,o)},m(o,M){a(o,i,M),a(o,p,M),h(c,o,M),f=!0},p:Xe,i(o){f||(b(c.$$.fragment,o),f=!0)},o(o){y(c.$$.fragment,o),f=!1},d(o){o&&(n(i),n(p)),_(c,o)}}}function dt(Z){let i,v=`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(){i=l("p"),i.innerHTML=v},l(p){i=m(p,"P",{"data-svelte-h":!0}),d(i)!=="svelte-fincs2"&&(i.innerHTML=v)},m(p,c){a(p,i,c)},p:Xe,d(p){p&&n(i)}}}function ft(Z){let i,v="Examples:",p,c,f;return c=new Ce({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>]`,wrap:!1}}),{c(){i=l("p"),i.textContent=v,p=s(),g(c.$$.fragment)},l(o){i=m(o,"P",{"data-svelte-h":!0}),d(i)!=="svelte-kvfsh7"&&(i.textContent=v),p=r(o),u(c.$$.fragment,o)},m(o,M){a(o,i,M),a(o,p,M),h(c,o,M),f=!0},p:Xe,i(o){f||(b(c.$$.fragment,o),f=!0)},o(o){y(c.$$.fragment,o),f=!1},d(o){o&&(n(i),n(p)),_(c,o)}}}function gt(Z){let i,v,p,c,f,o,M,le,F,ze=`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>.`,me,R,Be="The abstract from the paper is the following:",ce,V,Ee="<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>",pe,C,Ie,de,G,Qe='UPerNet framework. Taken from the <a href="https://arxiv.org/abs/1807.10221">original paper</a>.',fe,P,He='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>.',ge,X,ue,z,Ye="A list of official Hugging Face and community (indicated by 🌎) resources to help you get started with UPerNet.",he,B,qe='<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/main/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>',be,E,Le="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.",ye,I,_e,Q,Ae="UPerNet is a general framework for semantic segmentation. It can be used with any vision backbone, like so:",Me,H,we,Y,Oe='To use another vision backbone, like <a href="convnext">ConvNeXt</a>, simply instantiate the model with the appropriate backbone:',ve,q,Ue,L,De="Note that this will randomly initialize all the weights of the model.",$e,A,xe,U,O,Se,te,Ke=`This is the configuration class to store the configuration of an <a href="/docs/transformers/main/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.`,ke,ne,et=`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,S,Te,D,je,x,K,We,ae,tt="UperNet framework leveraging any vision backbone e.g. for ADE20k, CityScapes.",Fe,$,ee,Re,oe,nt='The <a href="/docs/transformers/main/en/model_doc/upernet#transformers.UperNetForSemanticSegmentation">UperNetForSemanticSegmentation</a> forward method, overrides the <code>__call__</code> special method.',Ve,k,Ge,J,Ne,re,Ze;return f=new se({props:{title:"UPerNet",local:"upernet",headingTag:"h1"}}),M=new se({props:{title:"Overview",local:"overview",headingTag:"h2"}}),X=new se({props:{title:"Resources",local:"resources",headingTag:"h2"}}),I=new se({props:{title:"Usage",local:"usage",headingTag:"h2"}}),H=new Ce({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)`,wrap:!1}}),q=new Ce({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)`,wrap:!1}}),A=new se({props:{title:"UperNetConfig",local:"transformers.UperNetConfig",headingTag:"h2"}}),O=new Pe({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/main/src/transformers/models/upernet/configuration_upernet.py#L26"}}),S=new at({props:{anchor:"transformers.UperNetConfig.example",$$slots:{default:[pt]},$$scope:{ctx:Z}}}),D=new se({props:{title:"UperNetForSemanticSegmentation",local:"transformers.UperNetForSemanticSegmentation",headingTag:"h2"}}),K=new Pe({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/main/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/main/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/main/src/transformers/models/upernet/modeling_upernet.py#L353"}}),ee=new Pe({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/main/en/model_doc/auto#transformers.AutoImageProcessor">AutoImageProcessor</a>. See <a href="/docs/transformers/main/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/main/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/main/src/transformers/models/upernet/modeling_upernet.py#L366",returnDescription:`<script context="module">export const metadata = 'undefined';<\/script>


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


<p><a
  href="/docs/transformers/main/en/main_classes/output#transformers.modeling_outputs.SemanticSegmenterOutput"
>transformers.modeling_outputs.SemanticSegmenterOutput</a> or <code>tuple(torch.FloatTensor)</code></p>
`}}),k=new ct({props:{$$slots:{default:[dt]},$$scope:{ctx:Z}}}),J=new at({props:{anchor:"transformers.UperNetForSemanticSegmentation.forward.example",$$slots:{default:[ft]},$$scope:{ctx:Z}}}),{c(){i=l("meta"),v=s(),p=l("p"),c=s(),g(f.$$.fragment),o=s(),g(M.$$.fragment),le=s(),F=l("p"),F.innerHTML=ze,me=s(),R=l("p"),R.textContent=Be,ce=s(),V=l("p"),V.innerHTML=Ee,pe=s(),C=l("img"),de=s(),G=l("small"),G.innerHTML=Qe,fe=s(),P=l("p"),P.innerHTML=He,ge=s(),g(X.$$.fragment),ue=s(),z=l("p"),z.textContent=Ye,he=s(),B=l("ul"),B.innerHTML=qe,be=s(),E=l("p"),E.textContent=Le,ye=s(),g(I.$$.fragment),_e=s(),Q=l("p"),Q.textContent=Ae,Me=s(),g(H.$$.fragment),we=s(),Y=l("p"),Y.innerHTML=Oe,ve=s(),g(q.$$.fragment),Ue=s(),L=l("p"),L.textContent=De,$e=s(),g(A.$$.fragment),xe=s(),U=l("div"),g(O.$$.fragment),Se=s(),te=l("p"),te.innerHTML=Ke,ke=s(),ne=l("p"),ne.innerHTML=et,Je=s(),g(S.$$.fragment),Te=s(),g(D.$$.fragment),je=s(),x=l("div"),g(K.$$.fragment),We=s(),ae=l("p"),ae.textContent=tt,Fe=s(),$=l("div"),g(ee.$$.fragment),Re=s(),oe=l("p"),oe.innerHTML=nt,Ve=s(),g(k.$$.fragment),Ge=s(),g(J.$$.fragment),Ne=s(),re=l("p"),this.h()},l(e){const t=mt("svelte-u9bgzb",document.head);i=m(t,"META",{name:!0,content:!0}),t.forEach(n),v=r(e),p=m(e,"P",{}),ie(p).forEach(n),c=r(e),u(f.$$.fragment,e),o=r(e),u(M.$$.fragment,e),le=r(e),F=m(e,"P",{"data-svelte-h":!0}),d(F)!=="svelte-1c4g37v"&&(F.innerHTML=ze),me=r(e),R=m(e,"P",{"data-svelte-h":!0}),d(R)!=="svelte-vfdo9a"&&(R.textContent=Be),ce=r(e),V=m(e,"P",{"data-svelte-h":!0}),d(V)!=="svelte-1k7ta1y"&&(V.innerHTML=Ee),pe=r(e),C=m(e,"IMG",{src:!0,alt:!0,width:!0}),de=r(e),G=m(e,"SMALL",{"data-svelte-h":!0}),d(G)!=="svelte-vh2z7s"&&(G.innerHTML=Qe),fe=r(e),P=m(e,"P",{"data-svelte-h":!0}),d(P)!=="svelte-1xqy3xr"&&(P.innerHTML=He),ge=r(e),u(X.$$.fragment,e),ue=r(e),z=m(e,"P",{"data-svelte-h":!0}),d(z)!=="svelte-108fh4w"&&(z.textContent=Ye),he=r(e),B=m(e,"UL",{"data-svelte-h":!0}),d(B)!=="svelte-17s05lc"&&(B.innerHTML=qe),be=r(e),E=m(e,"P",{"data-svelte-h":!0}),d(E)!=="svelte-1xesile"&&(E.textContent=Le),ye=r(e),u(I.$$.fragment,e),_e=r(e),Q=m(e,"P",{"data-svelte-h":!0}),d(Q)!=="svelte-gv2geu"&&(Q.textContent=Ae),Me=r(e),u(H.$$.fragment,e),we=r(e),Y=m(e,"P",{"data-svelte-h":!0}),d(Y)!=="svelte-1ffmd3f"&&(Y.innerHTML=Oe),ve=r(e),u(q.$$.fragment,e),Ue=r(e),L=m(e,"P",{"data-svelte-h":!0}),d(L)!=="svelte-a05sd1"&&(L.textContent=De),$e=r(e),u(A.$$.fragment,e),xe=r(e),U=m(e,"DIV",{class:!0});var T=ie(U);u(O.$$.fragment,T),Se=r(T),te=m(T,"P",{"data-svelte-h":!0}),d(te)!=="svelte-10jovpc"&&(te.innerHTML=Ke),ke=r(T),ne=m(T,"P",{"data-svelte-h":!0}),d(ne)!=="svelte-o55m63"&&(ne.innerHTML=et),Je=r(T),u(S.$$.fragment,T),T.forEach(n),Te=r(e),u(D.$$.fragment,e),je=r(e),x=m(e,"DIV",{class:!0});var N=ie(x);u(K.$$.fragment,N),We=r(N),ae=m(N,"P",{"data-svelte-h":!0}),d(ae)!=="svelte-ohcumq"&&(ae.textContent=tt),Fe=r(N),$=m(N,"DIV",{class:!0});var j=ie($);u(ee.$$.fragment,j),Re=r(j),oe=m(j,"P",{"data-svelte-h":!0}),d(oe)!=="svelte-1al9aea"&&(oe.innerHTML=nt),Ve=r(j),u(k.$$.fragment,j),Ge=r(j),u(J.$$.fragment,j),j.forEach(n),N.forEach(n),Ne=r(e),re=m(e,"P",{}),ie(re).forEach(n),this.h()},h(){W(i,"name","hf:doc:metadata"),W(i,"content",ut),st(C.src,Ie="https://huggingface.co/datasets/huggingface/documentation-images/resolve/main/transformers/model_doc/upernet_architecture.jpg")||W(C,"src",Ie),W(C,"alt","drawing"),W(C,"width","600"),W(U,"class","docstring border-l-2 border-t-2 pl-4 pt-3.5 border-gray-100 rounded-tl-xl mb-6 mt-8"),W($,"class","docstring border-l-2 border-t-2 pl-4 pt-3.5 border-gray-100 rounded-tl-xl mb-6 mt-8"),W(x,"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,t){w(document.head,i),a(e,v,t),a(e,p,t),a(e,c,t),h(f,e,t),a(e,o,t),h(M,e,t),a(e,le,t),a(e,F,t),a(e,me,t),a(e,R,t),a(e,ce,t),a(e,V,t),a(e,pe,t),a(e,C,t),a(e,de,t),a(e,G,t),a(e,fe,t),a(e,P,t),a(e,ge,t),h(X,e,t),a(e,ue,t),a(e,z,t),a(e,he,t),a(e,B,t),a(e,be,t),a(e,E,t),a(e,ye,t),h(I,e,t),a(e,_e,t),a(e,Q,t),a(e,Me,t),h(H,e,t),a(e,we,t),a(e,Y,t),a(e,ve,t),h(q,e,t),a(e,Ue,t),a(e,L,t),a(e,$e,t),h(A,e,t),a(e,xe,t),a(e,U,t),h(O,U,null),w(U,Se),w(U,te),w(U,ke),w(U,ne),w(U,Je),h(S,U,null),a(e,Te,t),h(D,e,t),a(e,je,t),a(e,x,t),h(K,x,null),w(x,We),w(x,ae),w(x,Fe),w(x,$),h(ee,$,null),w($,Re),w($,oe),w($,Ve),h(k,$,null),w($,Ge),h(J,$,null),a(e,Ne,t),a(e,re,t),Ze=!0},p(e,[t]){const T={};t&2&&(T.$$scope={dirty:t,ctx:e}),S.$set(T);const N={};t&2&&(N.$$scope={dirty:t,ctx:e}),k.$set(N);const j={};t&2&&(j.$$scope={dirty:t,ctx:e}),J.$set(j)},i(e){Ze||(b(f.$$.fragment,e),b(M.$$.fragment,e),b(X.$$.fragment,e),b(I.$$.fragment,e),b(H.$$.fragment,e),b(q.$$.fragment,e),b(A.$$.fragment,e),b(O.$$.fragment,e),b(S.$$.fragment,e),b(D.$$.fragment,e),b(K.$$.fragment,e),b(ee.$$.fragment,e),b(k.$$.fragment,e),b(J.$$.fragment,e),Ze=!0)},o(e){y(f.$$.fragment,e),y(M.$$.fragment,e),y(X.$$.fragment,e),y(I.$$.fragment,e),y(H.$$.fragment,e),y(q.$$.fragment,e),y(A.$$.fragment,e),y(O.$$.fragment,e),y(S.$$.fragment,e),y(D.$$.fragment,e),y(K.$$.fragment,e),y(ee.$$.fragment,e),y(k.$$.fragment,e),y(J.$$.fragment,e),Ze=!1},d(e){e&&(n(v),n(p),n(c),n(o),n(le),n(F),n(me),n(R),n(ce),n(V),n(pe),n(C),n(de),n(G),n(fe),n(P),n(ge),n(ue),n(z),n(he),n(B),n(be),n(E),n(ye),n(_e),n(Q),n(Me),n(we),n(Y),n(ve),n(Ue),n(L),n($e),n(xe),n(U),n(Te),n(je),n(x),n(Ne),n(re)),n(i),_(f,e),_(M,e),_(X,e),_(I,e),_(H,e),_(q,e),_(A,e),_(O),_(S),_(D,e),_(K),_(ee),_(k),_(J)}}}const ut='{"title":"UPerNet","local":"upernet","sections":[{"title":"Overview","local":"overview","sections":[],"depth":2},{"title":"Resources","local":"resources","sections":[],"depth":2},{"title":"Usage","local":"usage","sections":[],"depth":2},{"title":"UperNetConfig","local":"transformers.UperNetConfig","sections":[],"depth":2},{"title":"UperNetForSemanticSegmentation","local":"transformers.UperNetForSemanticSegmentation","sections":[],"depth":2}],"depth":1}';function ht(Z){return rt(()=>{new URLSearchParams(window.location.search).get("fw")}),[]}class $t extends it{constructor(i){super(),lt(this,i,ht,gt,ot,{})}}export{$t as component};
