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


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