import{s as ht,f as ft,o as ut,n as Ze}from"../chunks/scheduler.25b97de1.js";import{S as bt,i as _t,g as l,s,r as g,A as Mt,h as c,f as o,c as r,j as N,u as h,x as M,k as x,y as p,a as n,v as f,d as u,t as b,w as _}from"../chunks/index.d9030fc9.js";import{T as dt}from"../chunks/Tip.baa67368.js";import{D as he}from"../chunks/Docstring.e257edda.js";import{C as gt}from"../chunks/CodeBlock.e6cd0d95.js";import{E as pt}from"../chunks/ExampleCodeBlock.20db4b6e.js";import{H as fe,E as vt}from"../chunks/EditOnGithub.91d95064.js";function yt(U){let a,y="The model expects both the image and trimap (concatenated) as input. Use <code>ViTMatteImageProcessor</code> for this purpose.";return{c(){a=l("p"),a.innerHTML=y},l(m){a=c(m,"P",{"data-svelte-h":!0}),M(a)!=="svelte-8i6ct1"&&(a.innerHTML=y)},m(m,d){n(m,a,d)},p:Ze,d(m){m&&o(a)}}}function Tt(U){let a,y="Example:",m,d,v;return d=new gt({props:{code:"ZnJvbSUyMHRyYW5zZm9ybWVycyUyMGltcG9ydCUyMFZpdE1hdHRlQ29uZmlnJTJDJTIwVml0TWF0dGVGb3JJbWFnZU1hdHRpbmclMEElMEElMjMlMjBJbml0aWFsaXppbmclMjBhJTIwVmlUTWF0dGUlMjBodXN0dmwlMkZ2aXRtYXR0ZS1zbWFsbC1jb21wb3NpdGlvbi0xayUyMHN0eWxlJTIwY29uZmlndXJhdGlvbiUwQWNvbmZpZ3VyYXRpb24lMjAlM0QlMjBWaXRNYXR0ZUNvbmZpZygpJTBBJTBBJTIzJTIwSW5pdGlhbGl6aW5nJTIwYSUyMG1vZGVsJTIwKHdpdGglMjByYW5kb20lMjB3ZWlnaHRzKSUyMGZyb20lMjB0aGUlMjBodXN0dmwlMkZ2aXRtYXR0ZS1zbWFsbC1jb21wb3NpdGlvbi0xayUyMHN0eWxlJTIwY29uZmlndXJhdGlvbiUwQW1vZGVsJTIwJTNEJTIwVml0TWF0dGVGb3JJbWFnZU1hdHRpbmcoY29uZmlndXJhdGlvbiklMEElMEElMjMlMjBBY2Nlc3NpbmclMjB0aGUlMjBtb2RlbCUyMGNvbmZpZ3VyYXRpb24lMEFjb25maWd1cmF0aW9uJTIwJTNEJTIwbW9kZWwuY29uZmln",highlighted:`<span class="hljs-meta">&gt;&gt;&gt; </span><span class="hljs-keyword">from</span> transformers <span class="hljs-keyword">import</span> VitMatteConfig, VitMatteForImageMatting

<span class="hljs-meta">&gt;&gt;&gt; </span><span class="hljs-comment"># Initializing a ViTMatte hustvl/vitmatte-small-composition-1k style configuration</span>
<span class="hljs-meta">&gt;&gt;&gt; </span>configuration = VitMatteConfig()

<span class="hljs-meta">&gt;&gt;&gt; </span><span class="hljs-comment"># Initializing a model (with random weights) from the hustvl/vitmatte-small-composition-1k style configuration</span>
<span class="hljs-meta">&gt;&gt;&gt; </span>model = VitMatteForImageMatting(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(){a=l("p"),a.textContent=y,m=s(),g(d.$$.fragment)},l(i){a=c(i,"P",{"data-svelte-h":!0}),M(a)!=="svelte-11lpom8"&&(a.textContent=y),m=r(i),h(d.$$.fragment,i)},m(i,T){n(i,a,T),n(i,m,T),f(d,i,T),v=!0},p:Ze,i(i){v||(u(d.$$.fragment,i),v=!0)},o(i){b(d.$$.fragment,i),v=!1},d(i){i&&(o(a),o(m)),_(d,i)}}}function wt(U){let a,y=`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(){a=l("p"),a.innerHTML=y},l(m){a=c(m,"P",{"data-svelte-h":!0}),M(a)!=="svelte-fincs2"&&(a.innerHTML=y)},m(m,d){n(m,a,d)},p:Ze,d(m){m&&o(a)}}}function $t(U){let a,y="Examples:",m,d,v;return d=new gt({props:{code:"ZnJvbSUyMHRyYW5zZm9ybWVycyUyMGltcG9ydCUyMFZpdE1hdHRlSW1hZ2VQcm9jZXNzb3IlMkMlMjBWaXRNYXR0ZUZvckltYWdlTWF0dGluZyUwQWltcG9ydCUyMHRvcmNoJTBBZnJvbSUyMFBJTCUyMGltcG9ydCUyMEltYWdlJTBBZnJvbSUyMGh1Z2dpbmdmYWNlX2h1YiUyMGltcG9ydCUyMGhmX2h1Yl9kb3dubG9hZCUwQSUwQXByb2Nlc3NvciUyMCUzRCUyMFZpdE1hdHRlSW1hZ2VQcm9jZXNzb3IuZnJvbV9wcmV0cmFpbmVkKCUyMmh1c3R2bCUyRnZpdG1hdHRlLXNtYWxsLWNvbXBvc2l0aW9uLTFrJTIyKSUwQW1vZGVsJTIwJTNEJTIwVml0TWF0dGVGb3JJbWFnZU1hdHRpbmcuZnJvbV9wcmV0cmFpbmVkKCUyMmh1c3R2bCUyRnZpdG1hdHRlLXNtYWxsLWNvbXBvc2l0aW9uLTFrJTIyKSUwQSUwQWZpbGVwYXRoJTIwJTNEJTIwaGZfaHViX2Rvd25sb2FkKCUwQSUyMCUyMCUyMCUyMHJlcG9faWQlM0QlMjJoZi1pbnRlcm5hbC10ZXN0aW5nJTJGaW1hZ2UtbWF0dGluZy1maXh0dXJlcyUyMiUyQyUyMGZpbGVuYW1lJTNEJTIyaW1hZ2UucG5nJTIyJTJDJTIwcmVwb190eXBlJTNEJTIyZGF0YXNldCUyMiUwQSklMEFpbWFnZSUyMCUzRCUyMEltYWdlLm9wZW4oZmlsZXBhdGgpLmNvbnZlcnQoJTIyUkdCJTIyKSUwQWZpbGVwYXRoJTIwJTNEJTIwaGZfaHViX2Rvd25sb2FkKCUwQSUyMCUyMCUyMCUyMHJlcG9faWQlM0QlMjJoZi1pbnRlcm5hbC10ZXN0aW5nJTJGaW1hZ2UtbWF0dGluZy1maXh0dXJlcyUyMiUyQyUyMGZpbGVuYW1lJTNEJTIydHJpbWFwLnBuZyUyMiUyQyUyMHJlcG9fdHlwZSUzRCUyMmRhdGFzZXQlMjIlMEEpJTBBdHJpbWFwJTIwJTNEJTIwSW1hZ2Uub3BlbihmaWxlcGF0aCkuY29udmVydCglMjJMJTIyKSUwQSUwQSUyMyUyMHByZXBhcmUlMjBpbWFnZSUyMCUyQiUyMHRyaW1hcCUyMGZvciUyMHRoZSUyMG1vZGVsJTBBaW5wdXRzJTIwJTNEJTIwcHJvY2Vzc29yKGltYWdlcyUzRGltYWdlJTJDJTIwdHJpbWFwcyUzRHRyaW1hcCUyQyUyMHJldHVybl90ZW5zb3JzJTNEJTIycHQlMjIpJTBBJTBBd2l0aCUyMHRvcmNoLm5vX2dyYWQoKSUzQSUwQSUyMCUyMCUyMCUyMGFscGhhcyUyMCUzRCUyMG1vZGVsKCoqaW5wdXRzKS5hbHBoYXMlMEFwcmludChhbHBoYXMuc2hhcGUp",highlighted:`<span class="hljs-meta">&gt;&gt;&gt; </span><span class="hljs-keyword">from</span> transformers <span class="hljs-keyword">import</span> VitMatteImageProcessor, VitMatteForImageMatting
<span class="hljs-meta">&gt;&gt;&gt; </span><span class="hljs-keyword">import</span> torch
<span class="hljs-meta">&gt;&gt;&gt; </span><span class="hljs-keyword">from</span> 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>processor = VitMatteImageProcessor.from_pretrained(<span class="hljs-string">&quot;hustvl/vitmatte-small-composition-1k&quot;</span>)
<span class="hljs-meta">&gt;&gt;&gt; </span>model = VitMatteForImageMatting.from_pretrained(<span class="hljs-string">&quot;hustvl/vitmatte-small-composition-1k&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/image-matting-fixtures&quot;</span>, filename=<span class="hljs-string">&quot;image.png&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>filepath = hf_hub_download(
<span class="hljs-meta">... </span>    repo_id=<span class="hljs-string">&quot;hf-internal-testing/image-matting-fixtures&quot;</span>, filename=<span class="hljs-string">&quot;trimap.png&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>trimap = Image.<span class="hljs-built_in">open</span>(filepath).convert(<span class="hljs-string">&quot;L&quot;</span>)

<span class="hljs-meta">&gt;&gt;&gt; </span><span class="hljs-comment"># prepare image + trimap for the model</span>
<span class="hljs-meta">&gt;&gt;&gt; </span>inputs = processor(images=image, trimaps=trimap, return_tensors=<span class="hljs-string">&quot;pt&quot;</span>)

<span class="hljs-meta">&gt;&gt;&gt; </span><span class="hljs-keyword">with</span> torch.no_grad():
<span class="hljs-meta">... </span>    alphas = model(**inputs).alphas
<span class="hljs-meta">&gt;&gt;&gt; </span><span class="hljs-built_in">print</span>(alphas.shape)
torch.Size([<span class="hljs-number">1</span>, <span class="hljs-number">1</span>, <span class="hljs-number">640</span>, <span class="hljs-number">960</span>])`,wrap:!1}}),{c(){a=l("p"),a.textContent=y,m=s(),g(d.$$.fragment)},l(i){a=c(i,"P",{"data-svelte-h":!0}),M(a)!=="svelte-kvfsh7"&&(a.textContent=y),m=r(i),h(d.$$.fragment,i)},m(i,T){n(i,a,T),n(i,m,T),f(d,i,T),v=!0},p:Ze,i(i){v||(u(d.$$.fragment,i),v=!0)},o(i){b(d.$$.fragment,i),v=!1},d(i){i&&(o(a),o(m)),_(d,i)}}}function Vt(U){let a,y,m,d,v,i,T,be,R,Qe=`The ViTMatte model was proposed in <a href="https://arxiv.org/abs/2305.15272" rel="nofollow">Boosting Image Matting with Pretrained Plain Vision Transformers</a> by Jingfeng Yao, Xinggang Wang, Shusheng Yang, Baoyuan Wang.
ViTMatte leverages plain <a href="vit">Vision Transformers</a> for the task of image matting, which is the process of accurately estimating the foreground object in images and videos.`,_e,H,Ae="The abstract from the paper is the following:",Me,L,Oe="<em>Recently, plain vision Transformers (ViTs) have shown impressive performance on various computer vision tasks, thanks to their strong modeling capacity and large-scale pretraining. However, they have not yet conquered the problem of image matting. We hypothesize that image matting could also be boosted by ViTs and present a new efficient and robust ViT-based matting system, named ViTMatte. Our method utilizes (i) a hybrid attention mechanism combined with a convolution neck to help ViTs achieve an excellent performance-computation trade-off in matting tasks. (ii) Additionally, we introduce the detail capture module, which just consists of simple lightweight convolutions to complement the detailed information required by matting. To the best of our knowledge, ViTMatte is the first work to unleash the potential of ViT on image matting with concise adaptation. It inherits many superior properties from ViT to matting, including various pretraining strategies, concise architecture design, and flexible inference strategies. We evaluate ViTMatte on Composition-1k and Distinctions-646, the most commonly used benchmark for image matting, our method achieves state-of-the-art performance and outperforms prior matting works by a large margin.</em>",ve,E,Ke=`This model was contributed by <a href="https://huggingface.co/nielsr" rel="nofollow">nielsr</a>.
The original code can be found <a href="https://github.com/hustvl/ViTMatte" rel="nofollow">here</a>.`,ye,J,et,Te,S,tt='ViTMatte high-level overview. Taken from the <a href="https://arxiv.org/abs/2305.15272">original paper.</a>',we,B,$e,X,ot="A list of official Hugging Face and community (indicated by 🌎) resources to help you get started with ViTMatte.",Ve,q,at='<li>A demo notebook regarding inference with <a href="/docs/transformers/main/en/model_doc/vitmatte#transformers.VitMatteForImageMatting">VitMatteForImageMatting</a>, including background replacement, can be found <a href="https://github.com/NielsRogge/Transformers-Tutorials/tree/master/ViTMatte" rel="nofollow">here</a>.</li>',Ce,j,Ie,Y,xe,w,D,Pe,re,nt=`This is the configuration class to store the configuration of <a href="/docs/transformers/main/en/model_doc/vitmatte#transformers.VitMatteForImageMatting">VitMatteForImageMatting</a>. It is used to
instantiate a ViTMatte 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 ViTMatte
<a href="https://huggingface.co/hustvl/vitmatte-small-composition-1k" rel="nofollow">hustvl/vitmatte-small-composition-1k</a> architecture.`,Ge,ie,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.`,Ne,W,Re,F,Q,He,le,rt=`Serializes this instance to a Python dictionary. Override the default <a href="/docs/transformers/main/en/main_classes/configuration#transformers.PretrainedConfig.to_dict">to_dict()</a>. Returns:
<code>Dict[str, any]</code>: Dictionary of all the attributes that make up this configuration instance,`,Ue,A,ke,C,O,Le,ce,it="Constructs a ViTMatte image processor.",Ee,z,K,Se,me,lt="Preprocess an image or batch of images.",Je,ee,je,I,te,Be,de,ct="ViTMatte framework leveraging any vision backbone e.g. for ADE20k, CityScapes.",Xe,V,oe,qe,pe,mt='The <a href="/docs/transformers/main/en/model_doc/vitmatte#transformers.VitMatteForImageMatting">VitMatteForImageMatting</a> forward method, overrides the <code>__call__</code> special method.',Ye,Z,De,P,We,ae,Fe,ue,ze;return v=new fe({props:{title:"ViTMatte",local:"vitmatte",headingTag:"h1"}}),T=new fe({props:{title:"Overview",local:"overview",headingTag:"h2"}}),B=new fe({props:{title:"Resources",local:"resources",headingTag:"h2"}}),j=new dt({props:{$$slots:{default:[yt]},$$scope:{ctx:U}}}),Y=new fe({props:{title:"VitMatteConfig",local:"transformers.VitMatteConfig",headingTag:"h2"}}),D=new he({props:{name:"class transformers.VitMatteConfig",anchor:"transformers.VitMatteConfig",parameters:[{name:"backbone_config",val:": PretrainedConfig = 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:": int = 384"},{name:"batch_norm_eps",val:": float = 1e-05"},{name:"initializer_range",val:": float = 0.02"},{name:"convstream_hidden_sizes",val:": List = [48, 96, 192]"},{name:"fusion_hidden_sizes",val:": List = [256, 128, 64, 32]"},{name:"**kwargs",val:""}],parametersDescription:[{anchor:"transformers.VitMatteConfig.backbone_config",description:`<strong>backbone_config</strong> (<code>PretrainedConfig</code> or <code>dict</code>, <em>optional</em>, defaults to <code>VitDetConfig()</code>) &#x2014;
The configuration of the backbone model.`,name:"backbone_config"},{anchor:"transformers.VitMatteConfig.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.VitMatteConfig.use_pretrained_backbone",description:`<strong>use_pretrained_backbone</strong> (<code>bool</code>, <em>optional</em>, defaults to <code>False</code>) &#x2014;
Whether to use pretrained weights for the backbone.`,name:"use_pretrained_backbone"},{anchor:"transformers.VitMatteConfig.use_timm_backbone",description:`<strong>use_timm_backbone</strong> (<code>bool</code>, <em>optional</em>, defaults to <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.VitMatteConfig.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.VitMatteConfig.hidden_size",description:`<strong>hidden_size</strong> (<code>int</code>, <em>optional</em>, defaults to 384) &#x2014;
The number of input channels of the decoder.`,name:"hidden_size"},{anchor:"transformers.VitMatteConfig.batch_norm_eps",description:`<strong>batch_norm_eps</strong> (<code>float</code>, <em>optional</em>, defaults to 1e-05) &#x2014;
The epsilon used by the batch norm layers.`,name:"batch_norm_eps"},{anchor:"transformers.VitMatteConfig.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.VitMatteConfig.convstream_hidden_sizes",description:`<strong>convstream_hidden_sizes</strong> (<code>List[int]</code>, <em>optional</em>, defaults to <code>[48, 96, 192]</code>) &#x2014;
The output channels of the ConvStream module.`,name:"convstream_hidden_sizes"},{anchor:"transformers.VitMatteConfig.fusion_hidden_sizes",description:`<strong>fusion_hidden_sizes</strong> (<code>List[int]</code>, <em>optional</em>, defaults to <code>[256, 128, 64, 32]</code>) &#x2014;
The output channels of the Fusion blocks.`,name:"fusion_hidden_sizes"}],source:"https://github.com/huggingface/transformers/blob/main/src/transformers/models/vitmatte/configuration_vitmatte.py#L29"}}),W=new pt({props:{anchor:"transformers.VitMatteConfig.example",$$slots:{default:[Tt]},$$scope:{ctx:U}}}),Q=new he({props:{name:"to_dict",anchor:"transformers.VitMatteConfig.to_dict",parameters:[],source:"https://github.com/huggingface/transformers/blob/main/src/transformers/models/vitmatte/configuration_vitmatte.py#L125"}}),A=new fe({props:{title:"VitMatteImageProcessor",local:"transformers.VitMatteImageProcessor",headingTag:"h2"}}),O=new he({props:{name:"class transformers.VitMatteImageProcessor",anchor:"transformers.VitMatteImageProcessor",parameters:[{name:"do_rescale",val:": bool = True"},{name:"rescale_factor",val:": Union = 0.00392156862745098"},{name:"do_normalize",val:": bool = True"},{name:"image_mean",val:": Union = None"},{name:"image_std",val:": Union = None"},{name:"do_pad",val:": bool = True"},{name:"size_divisibility",val:": int = 32"},{name:"**kwargs",val:""}],parametersDescription:[{anchor:"transformers.VitMatteImageProcessor.do_rescale",description:`<strong>do_rescale</strong> (<code>bool</code>, <em>optional</em>, defaults to <code>True</code>) &#x2014;
Whether to rescale the image by the specified scale <code>rescale_factor</code>. Can be overridden by the <code>do_rescale</code>
parameter in the <code>preprocess</code> method.`,name:"do_rescale"},{anchor:"transformers.VitMatteImageProcessor.rescale_factor",description:`<strong>rescale_factor</strong> (<code>int</code> or <code>float</code>, <em>optional</em>, defaults to <code>1/255</code>) &#x2014;
Scale factor to use if rescaling the image. Can be overridden by the <code>rescale_factor</code> parameter in the
<code>preprocess</code> method.`,name:"rescale_factor"},{anchor:"transformers.VitMatteImageProcessor.do_normalize",description:`<strong>do_normalize</strong> (<code>bool</code>, <em>optional</em>, defaults to <code>True</code>) &#x2014;
Whether to normalize the image. Can be overridden by the <code>do_normalize</code> parameter in the <code>preprocess</code>
method.`,name:"do_normalize"},{anchor:"transformers.VitMatteImageProcessor.image_mean",description:`<strong>image_mean</strong> (<code>float</code> or <code>List[float]</code>, <em>optional</em>, defaults to <code>IMAGENET_STANDARD_MEAN</code>) &#x2014;
Mean to use if normalizing the image. This is a float or list of floats the length of the number of
channels in the image. Can be overridden by the <code>image_mean</code> parameter in the <code>preprocess</code> method.`,name:"image_mean"},{anchor:"transformers.VitMatteImageProcessor.image_std",description:`<strong>image_std</strong> (<code>float</code> or <code>List[float]</code>, <em>optional</em>, defaults to <code>IMAGENET_STANDARD_STD</code>) &#x2014;
Standard deviation to use if normalizing the image. This is a float or list of floats the length of the
number of channels in the image. Can be overridden by the <code>image_std</code> parameter in the <code>preprocess</code> method.`,name:"image_std"},{anchor:"transformers.VitMatteImageProcessor.do_pad",description:`<strong>do_pad</strong> (<code>bool</code>, <em>optional</em>, defaults to <code>True</code>) &#x2014;
Whether to pad the image to make the width and height divisible by <code>size_divisibility</code>. Can be overridden
by the <code>do_pad</code> parameter in the <code>preprocess</code> method.`,name:"do_pad"},{anchor:"transformers.VitMatteImageProcessor.size_divisibility",description:`<strong>size_divisibility</strong> (<code>int</code>, <em>optional</em>, defaults to 32) &#x2014;
The width and height of the image will be padded to be divisible by this number.`,name:"size_divisibility"}],source:"https://github.com/huggingface/transformers/blob/main/src/transformers/models/vitmatte/image_processing_vitmatte.py#L43"}}),K=new he({props:{name:"preprocess",anchor:"transformers.VitMatteImageProcessor.preprocess",parameters:[{name:"images",val:": Union"},{name:"trimaps",val:": Union"},{name:"do_rescale",val:": Optional = None"},{name:"rescale_factor",val:": Optional = None"},{name:"do_normalize",val:": Optional = None"},{name:"image_mean",val:": Union = None"},{name:"image_std",val:": Union = None"},{name:"do_pad",val:": Optional = None"},{name:"size_divisibility",val:": Optional = None"},{name:"return_tensors",val:": Union = None"},{name:"data_format",val:": Union = <ChannelDimension.FIRST: 'channels_first'>"},{name:"input_data_format",val:": Union = None"},{name:"**kwargs",val:""}],parametersDescription:[{anchor:"transformers.VitMatteImageProcessor.preprocess.images",description:`<strong>images</strong> (<code>ImageInput</code>) &#x2014;
Image to preprocess. Expects a single or batch of images with pixel values ranging from 0 to 255. If
passing in images with pixel values between 0 and 1, set <code>do_rescale=False</code>.`,name:"images"},{anchor:"transformers.VitMatteImageProcessor.preprocess.trimaps",description:`<strong>trimaps</strong> (<code>ImageInput</code>) &#x2014;
Trimap to preprocess.`,name:"trimaps"},{anchor:"transformers.VitMatteImageProcessor.preprocess.do_rescale",description:`<strong>do_rescale</strong> (<code>bool</code>, <em>optional</em>, defaults to <code>self.do_rescale</code>) &#x2014;
Whether to rescale the image values between [0 - 1].`,name:"do_rescale"},{anchor:"transformers.VitMatteImageProcessor.preprocess.rescale_factor",description:`<strong>rescale_factor</strong> (<code>float</code>, <em>optional</em>, defaults to <code>self.rescale_factor</code>) &#x2014;
Rescale factor to rescale the image by if <code>do_rescale</code> is set to <code>True</code>.`,name:"rescale_factor"},{anchor:"transformers.VitMatteImageProcessor.preprocess.do_normalize",description:`<strong>do_normalize</strong> (<code>bool</code>, <em>optional</em>, defaults to <code>self.do_normalize</code>) &#x2014;
Whether to normalize the image.`,name:"do_normalize"},{anchor:"transformers.VitMatteImageProcessor.preprocess.image_mean",description:`<strong>image_mean</strong> (<code>float</code> or <code>List[float]</code>, <em>optional</em>, defaults to <code>self.image_mean</code>) &#x2014;
Image mean to use if <code>do_normalize</code> is set to <code>True</code>.`,name:"image_mean"},{anchor:"transformers.VitMatteImageProcessor.preprocess.image_std",description:`<strong>image_std</strong> (<code>float</code> or <code>List[float]</code>, <em>optional</em>, defaults to <code>self.image_std</code>) &#x2014;
Image standard deviation to use if <code>do_normalize</code> is set to <code>True</code>.`,name:"image_std"},{anchor:"transformers.VitMatteImageProcessor.preprocess.do_pad",description:`<strong>do_pad</strong> (<code>bool</code>, <em>optional</em>, defaults to <code>self.do_pad</code>) &#x2014;
Whether to pad the image.`,name:"do_pad"},{anchor:"transformers.VitMatteImageProcessor.preprocess.size_divisibility",description:`<strong>size_divisibility</strong> (<code>int</code>, <em>optional</em>, defaults to <code>self.size_divisibility</code>) &#x2014;
The size divisibility to pad the image to if <code>do_pad</code> is set to <code>True</code>.`,name:"size_divisibility"},{anchor:"transformers.VitMatteImageProcessor.preprocess.return_tensors",description:`<strong>return_tensors</strong> (<code>str</code> or <code>TensorType</code>, <em>optional</em>) &#x2014;
The type of tensors to return. Can be one of:<ul>
<li>Unset: Return a list of <code>np.ndarray</code>.</li>
<li><code>TensorType.TENSORFLOW</code> or <code>&apos;tf&apos;</code>: Return a batch of type <code>tf.Tensor</code>.</li>
<li><code>TensorType.PYTORCH</code> or <code>&apos;pt&apos;</code>: Return a batch of type <code>torch.Tensor</code>.</li>
<li><code>TensorType.NUMPY</code> or <code>&apos;np&apos;</code>: Return a batch of type <code>np.ndarray</code>.</li>
<li><code>TensorType.JAX</code> or <code>&apos;jax&apos;</code>: Return a batch of type <code>jax.numpy.ndarray</code>.</li>
</ul>`,name:"return_tensors"},{anchor:"transformers.VitMatteImageProcessor.preprocess.data_format",description:`<strong>data_format</strong> (<code>ChannelDimension</code> or <code>str</code>, <em>optional</em>, defaults to <code>ChannelDimension.FIRST</code>) &#x2014;
The channel dimension format for the output image. Can be one of:<ul>
<li><code>&quot;channels_first&quot;</code> or <code>ChannelDimension.FIRST</code>: image in (num_channels, height, width) format.</li>
<li><code>&quot;channels_last&quot;</code> or <code>ChannelDimension.LAST</code>: image in (height, width, num_channels) format.</li>
<li>Unset: Use the channel dimension format of the input image.</li>
</ul>`,name:"data_format"},{anchor:"transformers.VitMatteImageProcessor.preprocess.input_data_format",description:`<strong>input_data_format</strong> (<code>ChannelDimension</code> or <code>str</code>, <em>optional</em>) &#x2014;
The channel dimension format for the input image. If unset, the channel dimension format is inferred
from the input image. Can be one of:<ul>
<li><code>&quot;channels_first&quot;</code> or <code>ChannelDimension.FIRST</code>: image in (num_channels, height, width) format.</li>
<li><code>&quot;channels_last&quot;</code> or <code>ChannelDimension.LAST</code>: image in (height, width, num_channels) format.</li>
<li><code>&quot;none&quot;</code> or <code>ChannelDimension.NONE</code>: image in (height, width) format.</li>
</ul>`,name:"input_data_format"}],source:"https://github.com/huggingface/transformers/blob/main/src/transformers/models/vitmatte/image_processing_vitmatte.py#L147"}}),ee=new fe({props:{title:"VitMatteForImageMatting",local:"transformers.VitMatteForImageMatting",headingTag:"h2"}}),te=new he({props:{name:"class transformers.VitMatteForImageMatting",anchor:"transformers.VitMatteForImageMatting",parameters:[{name:"config",val:""}],parametersDescription:[{anchor:"transformers.VitMatteForImageMatting.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.VitMatteForImageMatting.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/vitmatte/modeling_vitmatte.py#L253"}}),oe=new he({props:{name:"forward",anchor:"transformers.VitMatteForImageMatting.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.VitMatteForImageMatting.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/imagegpt#transformers.ImageGPTFeatureExtractor.__call__">VitMatteImageProcessor.<strong>call</strong>()</a> for details.`,name:"pixel_values"},{anchor:"transformers.VitMatteForImageMatting.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.VitMatteForImageMatting.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.VitMatteForImageMatting.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.VitMatteForImageMatting.forward.labels",description:`<strong>labels</strong> (<code>torch.LongTensor</code> of shape <code>(batch_size, height, width)</code>, <em>optional</em>) &#x2014;
Ground truth image matting for computing the loss.`,name:"labels"}],source:"https://github.com/huggingface/transformers/blob/main/src/transformers/models/vitmatte/modeling_vitmatte.py#L268",returnDescription:`<script context="module">export const metadata = 'undefined';<\/script>


<p>A <code>transformers.models.vitmatte.modeling_vitmatte.ImageMattingOutput</code> or a tuple of
<code>torch.FloatTensor</code> (if <code>return_dict=False</code> is passed or when <code>config.return_dict=False</code>) comprising various
elements depending on the configuration (<a
  href="/docs/transformers/main/en/model_doc/vitmatte#transformers.VitMatteConfig"
>VitMatteConfig</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) — Loss.</p>
</li>
<li>
<p><strong>alphas</strong> (<code>torch.FloatTensor</code> of shape <code>(batch_size, num_channels, height, width)</code>) — Estimated alpha values.</p>
</li>
<li>
<p><strong>hidden_states</strong> (<code>tuple(torch.FloatTensor)</code>, <em>optional</em>, returned when <code>output_hidden_states=True</code> is passed or when <code>config.output_hidden_states=True</code>) — Tuple of <code>torch.FloatTensor</code> (one for the output of the embeddings, if the model has an embedding layer, +
one for the output of each stage) of shape <code>(batch_size, sequence_length, hidden_size)</code>. Hidden-states
(also called feature maps) of the model at the output of each stage.</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><code>transformers.models.vitmatte.modeling_vitmatte.ImageMattingOutput</code> or <code>tuple(torch.FloatTensor)</code></p>
`}}),Z=new dt({props:{$$slots:{default:[wt]},$$scope:{ctx:U}}}),P=new pt({props:{anchor:"transformers.VitMatteForImageMatting.forward.example",$$slots:{default:[$t]},$$scope:{ctx:U}}}),ae=new vt({props:{source:"https://github.com/huggingface/transformers/blob/main/docs/source/en/model_doc/vitmatte.md"}}),{c(){a=l("meta"),y=s(),m=l("p"),d=s(),g(v.$$.fragment),i=s(),g(T.$$.fragment),be=s(),R=l("p"),R.innerHTML=Qe,_e=s(),H=l("p"),H.textContent=Ae,Me=s(),L=l("p"),L.innerHTML=Oe,ve=s(),E=l("p"),E.innerHTML=Ke,ye=s(),J=l("img"),Te=s(),S=l("small"),S.innerHTML=tt,we=s(),g(B.$$.fragment),$e=s(),X=l("p"),X.textContent=ot,Ve=s(),q=l("ul"),q.innerHTML=at,Ce=s(),g(j.$$.fragment),Ie=s(),g(Y.$$.fragment),xe=s(),w=l("div"),g(D.$$.fragment),Pe=s(),re=l("p"),re.innerHTML=nt,Ge=s(),ie=l("p"),ie.innerHTML=st,Ne=s(),g(W.$$.fragment),Re=s(),F=l("div"),g(Q.$$.fragment),He=s(),le=l("p"),le.innerHTML=rt,Ue=s(),g(A.$$.fragment),ke=s(),C=l("div"),g(O.$$.fragment),Le=s(),ce=l("p"),ce.textContent=it,Ee=s(),z=l("div"),g(K.$$.fragment),Se=s(),me=l("p"),me.textContent=lt,Je=s(),g(ee.$$.fragment),je=s(),I=l("div"),g(te.$$.fragment),Be=s(),de=l("p"),de.textContent=ct,Xe=s(),V=l("div"),g(oe.$$.fragment),qe=s(),pe=l("p"),pe.innerHTML=mt,Ye=s(),g(Z.$$.fragment),De=s(),g(P.$$.fragment),We=s(),g(ae.$$.fragment),Fe=s(),ue=l("p"),this.h()},l(e){const t=Mt("svelte-u9bgzb",document.head);a=c(t,"META",{name:!0,content:!0}),t.forEach(o),y=r(e),m=c(e,"P",{}),N(m).forEach(o),d=r(e),h(v.$$.fragment,e),i=r(e),h(T.$$.fragment,e),be=r(e),R=c(e,"P",{"data-svelte-h":!0}),M(R)!=="svelte-1oupqpp"&&(R.innerHTML=Qe),_e=r(e),H=c(e,"P",{"data-svelte-h":!0}),M(H)!=="svelte-vfdo9a"&&(H.textContent=Ae),Me=r(e),L=c(e,"P",{"data-svelte-h":!0}),M(L)!=="svelte-ejbjbx"&&(L.innerHTML=Oe),ve=r(e),E=c(e,"P",{"data-svelte-h":!0}),M(E)!=="svelte-cgl4x9"&&(E.innerHTML=Ke),ye=r(e),J=c(e,"IMG",{src:!0,alt:!0,width:!0}),Te=r(e),S=c(e,"SMALL",{"data-svelte-h":!0}),M(S)!=="svelte-htuduo"&&(S.innerHTML=tt),we=r(e),h(B.$$.fragment,e),$e=r(e),X=c(e,"P",{"data-svelte-h":!0}),M(X)!=="svelte-1h6mpjr"&&(X.textContent=ot),Ve=r(e),q=c(e,"UL",{"data-svelte-h":!0}),M(q)!=="svelte-v530fr"&&(q.innerHTML=at),Ce=r(e),h(j.$$.fragment,e),Ie=r(e),h(Y.$$.fragment,e),xe=r(e),w=c(e,"DIV",{class:!0});var $=N(w);h(D.$$.fragment,$),Pe=r($),re=c($,"P",{"data-svelte-h":!0}),M(re)!=="svelte-12czi7a"&&(re.innerHTML=nt),Ge=r($),ie=c($,"P",{"data-svelte-h":!0}),M(ie)!=="svelte-o55m63"&&(ie.innerHTML=st),Ne=r($),h(W.$$.fragment,$),Re=r($),F=c($,"DIV",{class:!0});var ne=N(F);h(Q.$$.fragment,ne),He=r(ne),le=c(ne,"P",{"data-svelte-h":!0}),M(le)!=="svelte-f91b28"&&(le.innerHTML=rt),ne.forEach(o),$.forEach(o),Ue=r(e),h(A.$$.fragment,e),ke=r(e),C=c(e,"DIV",{class:!0});var k=N(C);h(O.$$.fragment,k),Le=r(k),ce=c(k,"P",{"data-svelte-h":!0}),M(ce)!=="svelte-ohhgeg"&&(ce.textContent=it),Ee=r(k),z=c(k,"DIV",{class:!0});var se=N(z);h(K.$$.fragment,se),Se=r(se),me=c(se,"P",{"data-svelte-h":!0}),M(me)!=="svelte-1x3yxsa"&&(me.textContent=lt),se.forEach(o),k.forEach(o),Je=r(e),h(ee.$$.fragment,e),je=r(e),I=c(e,"DIV",{class:!0});var ge=N(I);h(te.$$.fragment,ge),Be=r(ge),de=c(ge,"P",{"data-svelte-h":!0}),M(de)!=="svelte-hfzn9x"&&(de.textContent=ct),Xe=r(ge),V=c(ge,"DIV",{class:!0});var G=N(V);h(oe.$$.fragment,G),qe=r(G),pe=c(G,"P",{"data-svelte-h":!0}),M(pe)!=="svelte-frucsj"&&(pe.innerHTML=mt),Ye=r(G),h(Z.$$.fragment,G),De=r(G),h(P.$$.fragment,G),G.forEach(o),ge.forEach(o),We=r(e),h(ae.$$.fragment,e),Fe=r(e),ue=c(e,"P",{}),N(ue).forEach(o),this.h()},h(){x(a,"name","hf:doc:metadata"),x(a,"content",Ct),ft(J.src,et="https://huggingface.co/datasets/huggingface/documentation-images/resolve/main/transformers/model_doc/vitmatte_architecture.png")||x(J,"src",et),x(J,"alt","drawing"),x(J,"width","600"),x(F,"class","docstring border-l-2 border-t-2 pl-4 pt-3.5 border-gray-100 rounded-tl-xl mb-6 mt-8"),x(w,"class","docstring border-l-2 border-t-2 pl-4 pt-3.5 border-gray-100 rounded-tl-xl mb-6 mt-8"),x(z,"class","docstring border-l-2 border-t-2 pl-4 pt-3.5 border-gray-100 rounded-tl-xl mb-6 mt-8"),x(C,"class","docstring border-l-2 border-t-2 pl-4 pt-3.5 border-gray-100 rounded-tl-xl mb-6 mt-8"),x(V,"class","docstring border-l-2 border-t-2 pl-4 pt-3.5 border-gray-100 rounded-tl-xl mb-6 mt-8"),x(I,"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){p(document.head,a),n(e,y,t),n(e,m,t),n(e,d,t),f(v,e,t),n(e,i,t),f(T,e,t),n(e,be,t),n(e,R,t),n(e,_e,t),n(e,H,t),n(e,Me,t),n(e,L,t),n(e,ve,t),n(e,E,t),n(e,ye,t),n(e,J,t),n(e,Te,t),n(e,S,t),n(e,we,t),f(B,e,t),n(e,$e,t),n(e,X,t),n(e,Ve,t),n(e,q,t),n(e,Ce,t),f(j,e,t),n(e,Ie,t),f(Y,e,t),n(e,xe,t),n(e,w,t),f(D,w,null),p(w,Pe),p(w,re),p(w,Ge),p(w,ie),p(w,Ne),f(W,w,null),p(w,Re),p(w,F),f(Q,F,null),p(F,He),p(F,le),n(e,Ue,t),f(A,e,t),n(e,ke,t),n(e,C,t),f(O,C,null),p(C,Le),p(C,ce),p(C,Ee),p(C,z),f(K,z,null),p(z,Se),p(z,me),n(e,Je,t),f(ee,e,t),n(e,je,t),n(e,I,t),f(te,I,null),p(I,Be),p(I,de),p(I,Xe),p(I,V),f(oe,V,null),p(V,qe),p(V,pe),p(V,Ye),f(Z,V,null),p(V,De),f(P,V,null),n(e,We,t),f(ae,e,t),n(e,Fe,t),n(e,ue,t),ze=!0},p(e,[t]){const $={};t&2&&($.$$scope={dirty:t,ctx:e}),j.$set($);const ne={};t&2&&(ne.$$scope={dirty:t,ctx:e}),W.$set(ne);const k={};t&2&&(k.$$scope={dirty:t,ctx:e}),Z.$set(k);const se={};t&2&&(se.$$scope={dirty:t,ctx:e}),P.$set(se)},i(e){ze||(u(v.$$.fragment,e),u(T.$$.fragment,e),u(B.$$.fragment,e),u(j.$$.fragment,e),u(Y.$$.fragment,e),u(D.$$.fragment,e),u(W.$$.fragment,e),u(Q.$$.fragment,e),u(A.$$.fragment,e),u(O.$$.fragment,e),u(K.$$.fragment,e),u(ee.$$.fragment,e),u(te.$$.fragment,e),u(oe.$$.fragment,e),u(Z.$$.fragment,e),u(P.$$.fragment,e),u(ae.$$.fragment,e),ze=!0)},o(e){b(v.$$.fragment,e),b(T.$$.fragment,e),b(B.$$.fragment,e),b(j.$$.fragment,e),b(Y.$$.fragment,e),b(D.$$.fragment,e),b(W.$$.fragment,e),b(Q.$$.fragment,e),b(A.$$.fragment,e),b(O.$$.fragment,e),b(K.$$.fragment,e),b(ee.$$.fragment,e),b(te.$$.fragment,e),b(oe.$$.fragment,e),b(Z.$$.fragment,e),b(P.$$.fragment,e),b(ae.$$.fragment,e),ze=!1},d(e){e&&(o(y),o(m),o(d),o(i),o(be),o(R),o(_e),o(H),o(Me),o(L),o(ve),o(E),o(ye),o(J),o(Te),o(S),o(we),o($e),o(X),o(Ve),o(q),o(Ce),o(Ie),o(xe),o(w),o(Ue),o(ke),o(C),o(Je),o(je),o(I),o(We),o(Fe),o(ue)),o(a),_(v,e),_(T,e),_(B,e),_(j,e),_(Y,e),_(D),_(W),_(Q),_(A,e),_(O),_(K),_(ee,e),_(te),_(oe),_(Z),_(P),_(ae,e)}}}const Ct='{"title":"ViTMatte","local":"vitmatte","sections":[{"title":"Overview","local":"overview","sections":[],"depth":2},{"title":"Resources","local":"resources","sections":[],"depth":2},{"title":"VitMatteConfig","local":"transformers.VitMatteConfig","sections":[],"depth":2},{"title":"VitMatteImageProcessor","local":"transformers.VitMatteImageProcessor","sections":[],"depth":2},{"title":"VitMatteForImageMatting","local":"transformers.VitMatteForImageMatting","sections":[],"depth":2}],"depth":1}';function It(U){return ut(()=>{new URLSearchParams(window.location.search).get("fw")}),[]}class zt extends bt{constructor(a){super(),_t(this,a,It,Vt,ht,{})}}export{zt as component};
