import{s as mt,A as ct,o as pt,n as Ee}from"../chunks/scheduler.01eeda35.js";import{S as dt,i as gt,g as l,s as a,r as f,A as ft,h as m,f as n,c as s,j as me,u,x as d,k as j,y as w,a as o,v as h,d as b,t as _,w as y}from"../chunks/index.6dd51b66.js";import{T as ut}from"../chunks/Tip.de9bae2b.js";import{D as Ie}from"../chunks/Docstring.cb556860.js";import{C as Je}from"../chunks/CodeBlock.19ec9b8c.js";import{E as lt}from"../chunks/ExampleCodeBlock.69db56ad.js";import{H as ie,E as ht}from"../chunks/index.58fe8f9d.js";function bt(Z){let i,v="Examples:",p,c,g;return c=new Je({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=a(),f(c.$$.fragment)},l(r){i=m(r,"P",{"data-svelte-h":!0}),d(i)!=="svelte-kvfsh7"&&(i.textContent=v),p=s(r),u(c.$$.fragment,r)},m(r,M){o(r,i,M),o(r,p,M),h(c,r,M),g=!0},p:Ee,i(r){g||(b(c.$$.fragment,r),g=!0)},o(r){_(c.$$.fragment,r),g=!1},d(r){r&&(n(i),n(p)),y(c,r)}}}function _t(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){o(p,i,c)},p:Ee,d(p){p&&n(i)}}}function yt(Z){let i,v="Examples:",p,c,g;return c=new Je({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=a(),f(c.$$.fragment)},l(r){i=m(r,"P",{"data-svelte-h":!0}),d(i)!=="svelte-kvfsh7"&&(i.textContent=v),p=s(r),u(c.$$.fragment,r)},m(r,M){o(r,i,M),o(r,p,M),h(c,r,M),g=!0},p:Ee,i(r){g||(b(c.$$.fragment,r),g=!0)},o(r){_(c.$$.fragment,r),g=!1},d(r){r&&(n(i),n(p)),y(c,r)}}}function Mt(Z){let i,v,p,c,g,r,M,He='<img alt="PyTorch" src="https://img.shields.io/badge/PyTorch-DE3412?style=flat&amp;logo=pytorch&amp;logoColor=white"/>',ce,W,pe,R,Qe=`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>.`,de,V,Ye="The abstract from the paper is the following:",ge,G,qe="<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>",fe,k,Le,ue,P,Ae='UPerNet framework. Taken from the <a href="https://arxiv.org/abs/1807.10221">original paper</a>.',he,z,De='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>.',be,X,_e,B,Oe="UPerNet is a general framework for semantic segmentation. It can be used with any vision backbone, like so:",ye,I,Me,E,Ke='To use another vision backbone, like <a href="convnext">ConvNeXt</a>, simply instantiate the model with the appropriate backbone:',we,H,ve,Q,et="Note that this will randomly initialize all the weights of the model.",Ue,Y,$e,q,tt="A list of official Hugging Face and community (indicated by 🌎) resources to help you get started with UPerNet.",xe,L,nt='<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>',Te,A,ot="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.",Ne,D,Ce,U,O,We,oe,at=`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.`,Re,ae,st=`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.`,Ve,S,je,K,Ze,x,ee,Ge,se,rt="UperNet framework leveraging any vision backbone e.g. for ADE20k, CityScapes.",Pe,$,te,ze,re,it='The <a href="/docs/transformers/main/en/model_doc/upernet#transformers.UperNetForSemanticSegmentation">UperNetForSemanticSegmentation</a> forward method, overrides the <code>__call__</code> special method.',Xe,F,Be,J,ke,ne,Se,le,Fe;return g=new ie({props:{title:"UPerNet",local:"upernet",headingTag:"h1"}}),W=new ie({props:{title:"Overview",local:"overview",headingTag:"h2"}}),X=new ie({props:{title:"Usage examples",local:"usage-examples",headingTag:"h2"}}),I=new Je({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}}),H=new Je({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}}),Y=new ie({props:{title:"Resources",local:"resources",headingTag:"h2"}}),D=new ie({props:{title:"UperNetConfig",local:"transformers.UperNetConfig",headingTag:"h2"}}),O=new Ie({props:{name:"class transformers.UperNetConfig",anchor:"transformers.UperNetConfig",parameters:[{name:"backbone_config",val:" = None"},{name:"backbone",val:" = None"},{name:"use_pretrained_backbone",val:" = False"},{name:"use_timm_backbone",val:" = False"},{name:"backbone_kwargs",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.backbone",description:`<strong>backbone</strong> (<code>str</code>, <em>optional</em>) &#x2014;
Name of backbone to use when <code>backbone_config</code> is <code>None</code>. If <code>use_pretrained_backbone</code> is <code>True</code>, this
will load the corresponding pretrained weights from the timm or transformers library. If <code>use_pretrained_backbone</code>
is <code>False</code>, this loads the backbone&#x2019;s config and uses that to initialize the backbone with random weights.`,name:"backbone"},{anchor:"transformers.UperNetConfig.use_pretrained_backbone",description:`<strong>use_pretrained_backbone</strong> (<code>bool</code>, <em>optional</em>, <code>False</code>) &#x2014;
Whether to use pretrained weights for the backbone.`,name:"use_pretrained_backbone"},{anchor:"transformers.UperNetConfig.use_timm_backbone",description:`<strong>use_timm_backbone</strong> (<code>bool</code>, <em>optional</em>, <code>False</code>) &#x2014;
Whether to load <code>backbone</code> from the timm library. If <code>False</code>, the backbone is loaded from the transformers
library.`,name:"use_timm_backbone"},{anchor:"transformers.UperNetConfig.backbone_kwargs",description:`<strong>backbone_kwargs</strong> (<code>dict</code>, <em>optional</em>) &#x2014;
Keyword arguments to be passed to AutoBackbone when loading from a checkpoint
e.g. <code>{&apos;out_indices&apos;: (0, 1, 2, 3)}</code>. Cannot be specified if <code>backbone_config</code> is set.`,name:"backbone_kwargs"},{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 lt({props:{anchor:"transformers.UperNetConfig.example",$$slots:{default:[bt]},$$scope:{ctx:Z}}}),K=new ie({props:{title:"UperNetForSemanticSegmentation",local:"transformers.UperNetForSemanticSegmentation",headingTag:"h2"}}),ee=new Ie({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;",name:"it"},{anchor:"transformers.UperNetForSemanticSegmentation.behavior.",description:`<strong>behavior.</strong> &#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:"behavior."}],source:"https://github.com/huggingface/transformers/blob/main/src/transformers/models/upernet/modeling_upernet.py#L339"}}),te=new Ie({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#L356",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>
`}}),F=new ut({props:{$$slots:{default:[_t]},$$scope:{ctx:Z}}}),J=new lt({props:{anchor:"transformers.UperNetForSemanticSegmentation.forward.example",$$slots:{default:[yt]},$$scope:{ctx:Z}}}),ne=new ht({props:{source:"https://github.com/huggingface/transformers/blob/main/docs/source/en/model_doc/upernet.md"}}),{c(){i=l("meta"),v=a(),p=l("p"),c=a(),f(g.$$.fragment),r=a(),M=l("div"),M.innerHTML=He,ce=a(),f(W.$$.fragment),pe=a(),R=l("p"),R.innerHTML=Qe,de=a(),V=l("p"),V.textContent=Ye,ge=a(),G=l("p"),G.innerHTML=qe,fe=a(),k=l("img"),ue=a(),P=l("small"),P.innerHTML=Ae,he=a(),z=l("p"),z.innerHTML=De,be=a(),f(X.$$.fragment),_e=a(),B=l("p"),B.textContent=Oe,ye=a(),f(I.$$.fragment),Me=a(),E=l("p"),E.innerHTML=Ke,we=a(),f(H.$$.fragment),ve=a(),Q=l("p"),Q.textContent=et,Ue=a(),f(Y.$$.fragment),$e=a(),q=l("p"),q.textContent=tt,xe=a(),L=l("ul"),L.innerHTML=nt,Te=a(),A=l("p"),A.textContent=ot,Ne=a(),f(D.$$.fragment),Ce=a(),U=l("div"),f(O.$$.fragment),We=a(),oe=l("p"),oe.innerHTML=at,Re=a(),ae=l("p"),ae.innerHTML=st,Ve=a(),f(S.$$.fragment),je=a(),f(K.$$.fragment),Ze=a(),x=l("div"),f(ee.$$.fragment),Ge=a(),se=l("p"),se.textContent=rt,Pe=a(),$=l("div"),f(te.$$.fragment),ze=a(),re=l("p"),re.innerHTML=it,Xe=a(),f(F.$$.fragment),Be=a(),f(J.$$.fragment),ke=a(),f(ne.$$.fragment),Se=a(),le=l("p"),this.h()},l(e){const t=ft("svelte-u9bgzb",document.head);i=m(t,"META",{name:!0,content:!0}),t.forEach(n),v=s(e),p=m(e,"P",{}),me(p).forEach(n),c=s(e),u(g.$$.fragment,e),r=s(e),M=m(e,"DIV",{class:!0,"data-svelte-h":!0}),d(M)!=="svelte-13t8s2t"&&(M.innerHTML=He),ce=s(e),u(W.$$.fragment,e),pe=s(e),R=m(e,"P",{"data-svelte-h":!0}),d(R)!=="svelte-1c4g37v"&&(R.innerHTML=Qe),de=s(e),V=m(e,"P",{"data-svelte-h":!0}),d(V)!=="svelte-vfdo9a"&&(V.textContent=Ye),ge=s(e),G=m(e,"P",{"data-svelte-h":!0}),d(G)!=="svelte-1k7ta1y"&&(G.innerHTML=qe),fe=s(e),k=m(e,"IMG",{src:!0,alt:!0,width:!0}),ue=s(e),P=m(e,"SMALL",{"data-svelte-h":!0}),d(P)!=="svelte-vh2z7s"&&(P.innerHTML=Ae),he=s(e),z=m(e,"P",{"data-svelte-h":!0}),d(z)!=="svelte-1xqy3xr"&&(z.innerHTML=De),be=s(e),u(X.$$.fragment,e),_e=s(e),B=m(e,"P",{"data-svelte-h":!0}),d(B)!=="svelte-gv2geu"&&(B.textContent=Oe),ye=s(e),u(I.$$.fragment,e),Me=s(e),E=m(e,"P",{"data-svelte-h":!0}),d(E)!=="svelte-1ffmd3f"&&(E.innerHTML=Ke),we=s(e),u(H.$$.fragment,e),ve=s(e),Q=m(e,"P",{"data-svelte-h":!0}),d(Q)!=="svelte-a05sd1"&&(Q.textContent=et),Ue=s(e),u(Y.$$.fragment,e),$e=s(e),q=m(e,"P",{"data-svelte-h":!0}),d(q)!=="svelte-108fh4w"&&(q.textContent=tt),xe=s(e),L=m(e,"UL",{"data-svelte-h":!0}),d(L)!=="svelte-17s05lc"&&(L.innerHTML=nt),Te=s(e),A=m(e,"P",{"data-svelte-h":!0}),d(A)!=="svelte-1xesile"&&(A.textContent=ot),Ne=s(e),u(D.$$.fragment,e),Ce=s(e),U=m(e,"DIV",{class:!0});var T=me(U);u(O.$$.fragment,T),We=s(T),oe=m(T,"P",{"data-svelte-h":!0}),d(oe)!=="svelte-10jovpc"&&(oe.innerHTML=at),Re=s(T),ae=m(T,"P",{"data-svelte-h":!0}),d(ae)!=="svelte-o55m63"&&(ae.innerHTML=st),Ve=s(T),u(S.$$.fragment,T),T.forEach(n),je=s(e),u(K.$$.fragment,e),Ze=s(e),x=m(e,"DIV",{class:!0});var C=me(x);u(ee.$$.fragment,C),Ge=s(C),se=m(C,"P",{"data-svelte-h":!0}),d(se)!=="svelte-ohcumq"&&(se.textContent=rt),Pe=s(C),$=m(C,"DIV",{class:!0});var N=me($);u(te.$$.fragment,N),ze=s(N),re=m(N,"P",{"data-svelte-h":!0}),d(re)!=="svelte-1al9aea"&&(re.innerHTML=it),Xe=s(N),u(F.$$.fragment,N),Be=s(N),u(J.$$.fragment,N),N.forEach(n),C.forEach(n),ke=s(e),u(ne.$$.fragment,e),Se=s(e),le=m(e,"P",{}),me(le).forEach(n),this.h()},h(){j(i,"name","hf:doc:metadata"),j(i,"content",wt),j(M,"class","flex flex-wrap space-x-1"),ct(k.src,Le="https://huggingface.co/datasets/huggingface/documentation-images/resolve/main/transformers/model_doc/upernet_architecture.jpg")||j(k,"src",Le),j(k,"alt","drawing"),j(k,"width","600"),j(U,"class","docstring border-l-2 border-t-2 pl-4 pt-3.5 border-gray-100 rounded-tl-xl mb-6 mt-8"),j($,"class","docstring border-l-2 border-t-2 pl-4 pt-3.5 border-gray-100 rounded-tl-xl mb-6 mt-8"),j(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),o(e,v,t),o(e,p,t),o(e,c,t),h(g,e,t),o(e,r,t),o(e,M,t),o(e,ce,t),h(W,e,t),o(e,pe,t),o(e,R,t),o(e,de,t),o(e,V,t),o(e,ge,t),o(e,G,t),o(e,fe,t),o(e,k,t),o(e,ue,t),o(e,P,t),o(e,he,t),o(e,z,t),o(e,be,t),h(X,e,t),o(e,_e,t),o(e,B,t),o(e,ye,t),h(I,e,t),o(e,Me,t),o(e,E,t),o(e,we,t),h(H,e,t),o(e,ve,t),o(e,Q,t),o(e,Ue,t),h(Y,e,t),o(e,$e,t),o(e,q,t),o(e,xe,t),o(e,L,t),o(e,Te,t),o(e,A,t),o(e,Ne,t),h(D,e,t),o(e,Ce,t),o(e,U,t),h(O,U,null),w(U,We),w(U,oe),w(U,Re),w(U,ae),w(U,Ve),h(S,U,null),o(e,je,t),h(K,e,t),o(e,Ze,t),o(e,x,t),h(ee,x,null),w(x,Ge),w(x,se),w(x,Pe),w(x,$),h(te,$,null),w($,ze),w($,re),w($,Xe),h(F,$,null),w($,Be),h(J,$,null),o(e,ke,t),h(ne,e,t),o(e,Se,t),o(e,le,t),Fe=!0},p(e,[t]){const T={};t&2&&(T.$$scope={dirty:t,ctx:e}),S.$set(T);const C={};t&2&&(C.$$scope={dirty:t,ctx:e}),F.$set(C);const N={};t&2&&(N.$$scope={dirty:t,ctx:e}),J.$set(N)},i(e){Fe||(b(g.$$.fragment,e),b(W.$$.fragment,e),b(X.$$.fragment,e),b(I.$$.fragment,e),b(H.$$.fragment,e),b(Y.$$.fragment,e),b(D.$$.fragment,e),b(O.$$.fragment,e),b(S.$$.fragment,e),b(K.$$.fragment,e),b(ee.$$.fragment,e),b(te.$$.fragment,e),b(F.$$.fragment,e),b(J.$$.fragment,e),b(ne.$$.fragment,e),Fe=!0)},o(e){_(g.$$.fragment,e),_(W.$$.fragment,e),_(X.$$.fragment,e),_(I.$$.fragment,e),_(H.$$.fragment,e),_(Y.$$.fragment,e),_(D.$$.fragment,e),_(O.$$.fragment,e),_(S.$$.fragment,e),_(K.$$.fragment,e),_(ee.$$.fragment,e),_(te.$$.fragment,e),_(F.$$.fragment,e),_(J.$$.fragment,e),_(ne.$$.fragment,e),Fe=!1},d(e){e&&(n(v),n(p),n(c),n(r),n(M),n(ce),n(pe),n(R),n(de),n(V),n(ge),n(G),n(fe),n(k),n(ue),n(P),n(he),n(z),n(be),n(_e),n(B),n(ye),n(Me),n(E),n(we),n(ve),n(Q),n(Ue),n($e),n(q),n(xe),n(L),n(Te),n(A),n(Ne),n(Ce),n(U),n(je),n(Ze),n(x),n(ke),n(Se),n(le)),n(i),y(g,e),y(W,e),y(X,e),y(I,e),y(H,e),y(Y,e),y(D,e),y(O),y(S),y(K,e),y(ee),y(te),y(F),y(J),y(ne,e)}}}const wt='{"title":"UPerNet","local":"upernet","sections":[{"title":"Overview","local":"overview","sections":[],"depth":2},{"title":"Usage examples","local":"usage-examples","sections":[],"depth":2},{"title":"Resources","local":"resources","sections":[],"depth":2},{"title":"UperNetConfig","local":"transformers.UperNetConfig","sections":[],"depth":2},{"title":"UperNetForSemanticSegmentation","local":"transformers.UperNetForSemanticSegmentation","sections":[],"depth":2}],"depth":1}';function vt(Z){return pt(()=>{new URLSearchParams(window.location.search).get("fw")}),[]}class Zt extends dt{constructor(i){super(),gt(this,i,vt,Mt,mt,{})}}export{Zt as component};
