import{S as Zr,i as ei,s as si,e as o,k as m,w as u,t,M as ai,c as r,d as a,m as c,a as i,x as f,h as l,b as h,N as Qr,G as s,g as p,y as g,q as d,o as _,B as b,v as ti}from"../../chunks/vendor-hf-doc-builder.js";import{T as Xr}from"../../chunks/Tip-hf-doc-builder.js";import{Y as li}from"../../chunks/Youtube-hf-doc-builder.js";import{I as Ns}from"../../chunks/IconCopyLink-hf-doc-builder.js";import{C as $}from"../../chunks/CodeBlock-hf-doc-builder.js";import{D as ni}from"../../chunks/DocNotebookDropdown-hf-doc-builder.js";function oi(ns){let v,q,j,k,I;return{c(){v=o("p"),q=t("See the image segmentation "),j=o("a"),k=t("task page"),I=t(" for more information about its associated models, datasets, and metrics."),this.h()},l(w){v=r(w,"P",{});var P=i(v);q=l(P,"See the image segmentation "),j=r(P,"A",{href:!0,rel:!0});var A=i(j);k=l(A,"task page"),A.forEach(a),I=l(P," for more information about its associated models, datasets, and metrics."),P.forEach(a),this.h()},h(){h(j,"href","https://huggingface.co/tasks/image-segmentation"),h(j,"rel","nofollow")},m(w,P){p(w,v,P),s(v,q),s(v,j),s(j,k),s(v,I)},d(w){w&&a(v)}}}function ri(ns){let v,q,j,k,I,w,P,A;return{c(){v=o("p"),q=t("If you aren\u2019t familiar with finetuning a model with the "),j=o("a"),k=t("Trainer"),I=t(", take a look at the basic tutorial "),w=o("a"),P=t("here"),A=t("!"),this.h()},l(J){v=r(J,"P",{});var T=i(v);q=l(T,"If you aren\u2019t familiar with finetuning a model with the "),j=r(T,"A",{href:!0});var F=i(j);k=l(F,"Trainer"),F.forEach(a),I=l(T,", take a look at the basic tutorial "),w=r(T,"A",{href:!0});var fe=i(w);P=l(fe,"here"),fe.forEach(a),A=l(T,"!"),T.forEach(a),this.h()},h(){h(j,"href","/docs/transformers/v4.25.1/en/main_classes/trainer#transformers.Trainer"),h(w,"href","../training#finetune-with-trainer")},m(J,T){p(J,v,T),s(v,q),s(v,j),s(j,k),s(v,I),s(v,w),s(w,P),s(v,A)},d(J){J&&a(v)}}}function ii(ns){let v,q,j,k,I,w,P,A,J,T,F,fe,ge,Pa,os,Yt,Ia,rs,Gt,Ta,ee,R,Jt,de,Rt,Wt,_e,Vt,Kt,Qt,Bs,Xt,qa,se,Aa,is,Zt,Sa,be,Da,ps,el,Fa,ve,Ca,W,ae,Hs,je,sl,Ms,al,La,ms,tl,za,ye,Oa,C,ll,Us,nl,ol,$e,rl,il,Na,we,Ba,cs,pl,Ha,xe,Ma,L,hs,Ys,ml,cl,hl,us,Gs,ul,fl,gl,z,Js,dl,_l,Rs,bl,vl,Ws,jl,yl,Ua,O,$l,Vs,wl,xl,Ks,kl,El,Ya,ke,Ga,V,te,Qs,Ee,Pl,Xs,Il,Ja,N,Tl,Zs,ql,Al,ea,Sl,Dl,Ra,Pe,Wa,B,Fl,Ie,sa,Cl,Ll,Te,zl,Ol,Va,qe,Ka,E,Nl,aa,Bl,Hl,ta,Ml,Ul,la,Yl,Gl,na,Jl,Rl,oa,Wl,Vl,Qa,Ae,Xa,H,Kl,ra,Ql,Xl,Se,Zl,en,Za,De,et,K,le,ia,Fe,sn,pa,an,st,S,tn,Ce,ln,nn,Le,on,rn,ze,pn,mn,at,Oe,tt,M,cn,Ne,hn,un,Be,fn,gn,lt,He,nt,ne,dn,ma,_n,bn,ot,Q,oe,ca,Me,vn,ha,jn,rt,re,it,ie,yn,fs,$n,wn,pt,Ue,mt,gs,xn,ct,U,y,kn,ds,En,Pn,ua,In,Tn,fa,qn,An,ga,Sn,Dn,da,Fn,Cn,_a,Ln,zn,ba,On,Nn,_s,Bn,Hn,Mn,X,Un,bs,Yn,Gn,va,Jn,Rn,Wn,Ye,Vn,vs,Kn,Qn,ht,Ge,ut,pe,Xn,js,Zn,eo,ft,Je,gt,Z,me,ja,Re,so,ya,ao,dt,ys,to,_t,$s,lo,bt,We,vt,Ve,ws,ko,jt,Y,no,xs,oo,ro,$a,io,po,yt,Ke,$t,G,mo,wa,co,ho,xa,uo,fo,wt,Qe,xt,ce,go,ka,_o,bo,kt,Xe,Et,ks,vo,Pt,Ze,It,he,jo,es,yo,$o,Tt,ss,qt,as,Es,Eo,At;return w=new Ns({}),F=new ni({props:{classNames:"absolute z-10 right-0 top-0",options:[{label:"Mixed",value:"https://colab.research.google.com/github/huggingface/notebooks/blob/main/transformers_doc/en/semantic_segmentation.ipynb"},{label:"PyTorch",value:"https://colab.research.google.com/github/huggingface/notebooks/blob/main/transformers_doc/en/pytorch/semantic_segmentation.ipynb"},{label:"TensorFlow",value:"https://colab.research.google.com/github/huggingface/notebooks/blob/main/transformers_doc/en/tensorflow/semantic_segmentation.ipynb"},{label:"Mixed",value:"https://studiolab.sagemaker.aws/import/github/huggingface/notebooks/blob/main/transformers_doc/en/semantic_segmentation.ipynb"},{label:"PyTorch",value:"https://studiolab.sagemaker.aws/import/github/huggingface/notebooks/blob/main/transformers_doc/en/pytorch/semantic_segmentation.ipynb"},{label:"TensorFlow",value:"https://studiolab.sagemaker.aws/import/github/huggingface/notebooks/blob/main/transformers_doc/en/tensorflow/semantic_segmentation.ipynb"}]}}),ge=new li({props:{id:"dKE8SIt9C-w"}}),se=new Xr({props:{$$slots:{default:[oi]},$$scope:{ctx:ns}}}),be=new $({props:{code:"pip install -q datasets transformers evaluate",highlighted:"pip install -q datasets transformers evaluate"}}),ve=new $({props:{code:`from huggingface_hub import notebook_login

notebook_login()`,highlighted:`<span class="hljs-meta">&gt;&gt;&gt; </span><span class="hljs-keyword">from</span> huggingface_hub <span class="hljs-keyword">import</span> notebook_login

<span class="hljs-meta">&gt;&gt;&gt; </span>notebook_login()`}}),je=new Ns({}),ye=new $({props:{code:`from datasets import load_dataset

ds = load_dataset("scene_parse_150", split="train[:50]")`,highlighted:`<span class="hljs-meta">&gt;&gt;&gt; </span><span class="hljs-keyword">from</span> datasets <span class="hljs-keyword">import</span> load_dataset

<span class="hljs-meta">&gt;&gt;&gt; </span>ds = load_dataset(<span class="hljs-string">&quot;scene_parse_150&quot;</span>, split=<span class="hljs-string">&quot;train[:50]&quot;</span>)`}}),we=new $({props:{code:`ds = ds.train_test_split(test_size=0.2)
train_ds = ds["train"]
test_ds = ds["test"]`,highlighted:`<span class="hljs-meta">&gt;&gt;&gt; </span>ds = ds.train_test_split(test_size=<span class="hljs-number">0.2</span>)
<span class="hljs-meta">&gt;&gt;&gt; </span>train_ds = ds[<span class="hljs-string">&quot;train&quot;</span>]
<span class="hljs-meta">&gt;&gt;&gt; </span>test_ds = ds[<span class="hljs-string">&quot;test&quot;</span>]`}}),xe=new $({props:{code:"train_ds[0]",highlighted:`<span class="hljs-meta">&gt;&gt;&gt; </span>train_ds[<span class="hljs-number">0</span>]
{<span class="hljs-string">&#x27;image&#x27;</span>: &lt;PIL.JpegImagePlugin.JpegImageFile image mode=RGB size=512x683 at <span class="hljs-number">0x7F9B0C201F90</span>&gt;,
 <span class="hljs-string">&#x27;annotation&#x27;</span>: &lt;PIL.PngImagePlugin.PngImageFile image mode=L size=512x683 at <span class="hljs-number">0x7F9B0C201DD0</span>&gt;,
 <span class="hljs-string">&#x27;scene_category&#x27;</span>: <span class="hljs-number">368</span>}`}}),ke=new $({props:{code:`import json
from huggingface_hub import cached_download, hf_hub_url

repo_id = "huggingface/label-files"
filename = "ade20k-hf-doc-builder.json"
id2label = json.load(open(cached_download(hf_hub_url(repo_id, filename, repo_type="dataset")), "r"))
id2label = {int(k): v for k, v in id2label.items()}
label2id = {v: k for k, v in id2label.items()}
num_labels = len(id2label)`,highlighted:`<span class="hljs-meta">&gt;&gt;&gt; </span><span class="hljs-keyword">import</span> json
<span class="hljs-meta">&gt;&gt;&gt; </span><span class="hljs-keyword">from</span> huggingface_hub <span class="hljs-keyword">import</span> cached_download, hf_hub_url

<span class="hljs-meta">&gt;&gt;&gt; </span>repo_id = <span class="hljs-string">&quot;huggingface/label-files&quot;</span>
<span class="hljs-meta">&gt;&gt;&gt; </span>filename = <span class="hljs-string">&quot;ade20k-hf-doc-builder.json&quot;</span>
<span class="hljs-meta">&gt;&gt;&gt; </span>id2label = json.load(<span class="hljs-built_in">open</span>(cached_download(hf_hub_url(repo_id, filename, repo_type=<span class="hljs-string">&quot;dataset&quot;</span>)), <span class="hljs-string">&quot;r&quot;</span>))
<span class="hljs-meta">&gt;&gt;&gt; </span>id2label = {<span class="hljs-built_in">int</span>(k): v <span class="hljs-keyword">for</span> k, v <span class="hljs-keyword">in</span> id2label.items()}
<span class="hljs-meta">&gt;&gt;&gt; </span>label2id = {v: k <span class="hljs-keyword">for</span> k, v <span class="hljs-keyword">in</span> id2label.items()}
<span class="hljs-meta">&gt;&gt;&gt; </span>num_labels = <span class="hljs-built_in">len</span>(id2label)`}}),Ee=new Ns({}),Pe=new $({props:{code:`from transformers import AutoImageProcessor

feature_extractor = AutoImageProcessor.from_pretrained("nvidia/mit-b0", reduce_labels=True)`,highlighted:`<span class="hljs-meta">&gt;&gt;&gt; </span><span class="hljs-keyword">from</span> transformers <span class="hljs-keyword">import</span> AutoImageProcessor

<span class="hljs-meta">&gt;&gt;&gt; </span>feature_extractor = AutoImageProcessor.from_pretrained(<span class="hljs-string">&quot;nvidia/mit-b0&quot;</span>, reduce_labels=<span class="hljs-literal">True</span>)`}}),qe=new $({props:{code:`from torchvision.transforms import ColorJitter

jitter = ColorJitter(brightness=0.25, contrast=0.25, saturation=0.25, hue=0.1)`,highlighted:`<span class="hljs-meta">&gt;&gt;&gt; </span><span class="hljs-keyword">from</span> torchvision.transforms <span class="hljs-keyword">import</span> ColorJitter

<span class="hljs-meta">&gt;&gt;&gt; </span>jitter = ColorJitter(brightness=<span class="hljs-number">0.25</span>, contrast=<span class="hljs-number">0.25</span>, saturation=<span class="hljs-number">0.25</span>, hue=<span class="hljs-number">0.1</span>)`}}),Ae=new $({props:{code:`def train_transforms(example_batch):
    images = [jitter(x) for x in example_batch["image"]]
    labels = [x for x in example_batch["annotation"]]
    inputs = feature_extractor(images, labels)
    return inputs


def val_transforms(example_batch):
    images = [x for x in example_batch["image"]]
    labels = [x for x in example_batch["annotation"]]
    inputs = feature_extractor(images, labels)
    return inputs`,highlighted:`<span class="hljs-meta">&gt;&gt;&gt; </span><span class="hljs-keyword">def</span> <span class="hljs-title function_">train_transforms</span>(<span class="hljs-params">example_batch</span>):
<span class="hljs-meta">... </span>    images = [jitter(x) <span class="hljs-keyword">for</span> x <span class="hljs-keyword">in</span> example_batch[<span class="hljs-string">&quot;image&quot;</span>]]
<span class="hljs-meta">... </span>    labels = [x <span class="hljs-keyword">for</span> x <span class="hljs-keyword">in</span> example_batch[<span class="hljs-string">&quot;annotation&quot;</span>]]
<span class="hljs-meta">... </span>    inputs = feature_extractor(images, labels)
<span class="hljs-meta">... </span>    <span class="hljs-keyword">return</span> inputs


<span class="hljs-meta">&gt;&gt;&gt; </span><span class="hljs-keyword">def</span> <span class="hljs-title function_">val_transforms</span>(<span class="hljs-params">example_batch</span>):
<span class="hljs-meta">... </span>    images = [x <span class="hljs-keyword">for</span> x <span class="hljs-keyword">in</span> example_batch[<span class="hljs-string">&quot;image&quot;</span>]]
<span class="hljs-meta">... </span>    labels = [x <span class="hljs-keyword">for</span> x <span class="hljs-keyword">in</span> example_batch[<span class="hljs-string">&quot;annotation&quot;</span>]]
<span class="hljs-meta">... </span>    inputs = feature_extractor(images, labels)
<span class="hljs-meta">... </span>    <span class="hljs-keyword">return</span> inputs`}}),De=new $({props:{code:`train_ds.set_transform(train_transforms)
test_ds.set_transform(val_transforms)`,highlighted:`<span class="hljs-meta">&gt;&gt;&gt; </span>train_ds.set_transform(train_transforms)
<span class="hljs-meta">&gt;&gt;&gt; </span>test_ds.set_transform(val_transforms)`}}),Fe=new Ns({}),Oe=new $({props:{code:`import evaluate

metric = evaluate.load("mean_iou")`,highlighted:`<span class="hljs-meta">&gt;&gt;&gt; </span><span class="hljs-keyword">import</span> evaluate

<span class="hljs-meta">&gt;&gt;&gt; </span>metric = evaluate.load(<span class="hljs-string">&quot;mean_iou&quot;</span>)`}}),He=new $({props:{code:`def compute_metrics(eval_pred):
    with torch.no_grad():
        logits, labels = eval_pred
        logits_tensor = torch.from_numpy(logits)
        logits_tensor = nn.functional.interpolate(
            logits_tensor,
            size=labels.shape[-2:],
            mode="bilinear",
            align_corners=False,
        ).argmax(dim=1)

        pred_labels = logits_tensor.detach().cpu().numpy()
        metrics = metric.compute(
            predictions=pred_labels,
            references=labels,
            num_labels=num_labels,
            ignore_index=255,
            reduce_labels=False,
        )
        for key, value in metrics.items():
            if type(value) is np.ndarray:
                metrics[key] = value.tolist()
        return metrics`,highlighted:`<span class="hljs-meta">&gt;&gt;&gt; </span><span class="hljs-keyword">def</span> <span class="hljs-title function_">compute_metrics</span>(<span class="hljs-params">eval_pred</span>):
<span class="hljs-meta">... </span>    <span class="hljs-keyword">with</span> torch.no_grad():
<span class="hljs-meta">... </span>        logits, labels = eval_pred
<span class="hljs-meta">... </span>        logits_tensor = torch.from_numpy(logits)
<span class="hljs-meta">... </span>        logits_tensor = nn.functional.interpolate(
<span class="hljs-meta">... </span>            logits_tensor,
<span class="hljs-meta">... </span>            size=labels.shape[-<span class="hljs-number">2</span>:],
<span class="hljs-meta">... </span>            mode=<span class="hljs-string">&quot;bilinear&quot;</span>,
<span class="hljs-meta">... </span>            align_corners=<span class="hljs-literal">False</span>,
<span class="hljs-meta">... </span>        ).argmax(dim=<span class="hljs-number">1</span>)

<span class="hljs-meta">... </span>        pred_labels = logits_tensor.detach().cpu().numpy()
<span class="hljs-meta">... </span>        metrics = metric.compute(
<span class="hljs-meta">... </span>            predictions=pred_labels,
<span class="hljs-meta">... </span>            references=labels,
<span class="hljs-meta">... </span>            num_labels=num_labels,
<span class="hljs-meta">... </span>            ignore_index=<span class="hljs-number">255</span>,
<span class="hljs-meta">... </span>            reduce_labels=<span class="hljs-literal">False</span>,
<span class="hljs-meta">... </span>        )
<span class="hljs-meta">... </span>        <span class="hljs-keyword">for</span> key, value <span class="hljs-keyword">in</span> metrics.items():
<span class="hljs-meta">... </span>            <span class="hljs-keyword">if</span> <span class="hljs-built_in">type</span>(value) <span class="hljs-keyword">is</span> np.ndarray:
<span class="hljs-meta">... </span>                metrics[key] = value.tolist()
<span class="hljs-meta">... </span>        <span class="hljs-keyword">return</span> metrics`}}),Me=new Ns({}),re=new Xr({props:{$$slots:{default:[ri]},$$scope:{ctx:ns}}}),Ue=new $({props:{code:`from transformers import AutoModelForSemanticSegmentation, TrainingArguments, Trainer

pretrained_model_name = "nvidia/mit-b0"
model = AutoModelForSemanticSegmentation.from_pretrained(
    pretrained_model_name, id2label=id2label, label2id=label2id
)`,highlighted:`<span class="hljs-meta">&gt;&gt;&gt; </span><span class="hljs-keyword">from</span> transformers <span class="hljs-keyword">import</span> AutoModelForSemanticSegmentation, TrainingArguments, Trainer

<span class="hljs-meta">&gt;&gt;&gt; </span>pretrained_model_name = <span class="hljs-string">&quot;nvidia/mit-b0&quot;</span>
<span class="hljs-meta">&gt;&gt;&gt; </span>model = AutoModelForSemanticSegmentation.from_pretrained(
<span class="hljs-meta">... </span>    pretrained_model_name, id2label=id2label, label2id=label2id
<span class="hljs-meta">... </span>)`}}),Ge=new $({props:{code:`training_args = TrainingArguments(
    output_dir="segformer-b0-scene-parse-150",
    learning_rate=6e-5,
    num_train_epochs=50,
    per_device_train_batch_size=2,
    per_device_eval_batch_size=2,
    save_total_limit=3,
    evaluation_strategy="steps",
    save_strategy="steps",
    save_steps=20,
    eval_steps=20,
    logging_steps=1,
    eval_accumulation_steps=5,
    remove_unused_columns=False,
    push_to_hub=True,
)

trainer = Trainer(
    model=model,
    args=training_args,
    train_dataset=train_ds,
    eval_dataset=test_ds,
    compute_metrics=compute_metrics,
)

trainer.train()`,highlighted:`<span class="hljs-meta">&gt;&gt;&gt; </span>training_args = TrainingArguments(
<span class="hljs-meta">... </span>    output_dir=<span class="hljs-string">&quot;segformer-b0-scene-parse-150&quot;</span>,
<span class="hljs-meta">... </span>    learning_rate=<span class="hljs-number">6e-5</span>,
<span class="hljs-meta">... </span>    num_train_epochs=<span class="hljs-number">50</span>,
<span class="hljs-meta">... </span>    per_device_train_batch_size=<span class="hljs-number">2</span>,
<span class="hljs-meta">... </span>    per_device_eval_batch_size=<span class="hljs-number">2</span>,
<span class="hljs-meta">... </span>    save_total_limit=<span class="hljs-number">3</span>,
<span class="hljs-meta">... </span>    evaluation_strategy=<span class="hljs-string">&quot;steps&quot;</span>,
<span class="hljs-meta">... </span>    save_strategy=<span class="hljs-string">&quot;steps&quot;</span>,
<span class="hljs-meta">... </span>    save_steps=<span class="hljs-number">20</span>,
<span class="hljs-meta">... </span>    eval_steps=<span class="hljs-number">20</span>,
<span class="hljs-meta">... </span>    logging_steps=<span class="hljs-number">1</span>,
<span class="hljs-meta">... </span>    eval_accumulation_steps=<span class="hljs-number">5</span>,
<span class="hljs-meta">... </span>    remove_unused_columns=<span class="hljs-literal">False</span>,
<span class="hljs-meta">... </span>    push_to_hub=<span class="hljs-literal">True</span>,
<span class="hljs-meta">... </span>)

<span class="hljs-meta">&gt;&gt;&gt; </span>trainer = Trainer(
<span class="hljs-meta">... </span>    model=model,
<span class="hljs-meta">... </span>    args=training_args,
<span class="hljs-meta">... </span>    train_dataset=train_ds,
<span class="hljs-meta">... </span>    eval_dataset=test_ds,
<span class="hljs-meta">... </span>    compute_metrics=compute_metrics,
<span class="hljs-meta">... </span>)

<span class="hljs-meta">&gt;&gt;&gt; </span>trainer.train()`}}),Je=new $({props:{code:"trainer.push_to_hub()",highlighted:'<span class="hljs-meta">&gt;&gt;&gt; </span>trainer.push_to_hub()'}}),Re=new Ns({}),We=new $({props:{code:`image = ds[0]["image"]
image`,highlighted:`<span class="hljs-meta">&gt;&gt;&gt; </span>image = ds[<span class="hljs-number">0</span>][<span class="hljs-string">&quot;image&quot;</span>]
<span class="hljs-meta">&gt;&gt;&gt; </span>image`}}),Ke=new $({props:{code:`from transformers import pipeline

segmenter = pipeline("image-segmentation", model="my_awesome_seg_model")
segmenter(image)`,highlighted:`<span class="hljs-meta">&gt;&gt;&gt; </span><span class="hljs-keyword">from</span> transformers <span class="hljs-keyword">import</span> pipeline

<span class="hljs-meta">&gt;&gt;&gt; </span>segmenter = pipeline(<span class="hljs-string">&quot;image-segmentation&quot;</span>, model=<span class="hljs-string">&quot;my_awesome_seg_model&quot;</span>)
<span class="hljs-meta">&gt;&gt;&gt; </span>segmenter(image)
[{<span class="hljs-string">&#x27;score&#x27;</span>: <span class="hljs-literal">None</span>,
  <span class="hljs-string">&#x27;label&#x27;</span>: <span class="hljs-string">&#x27;wall&#x27;</span>,
  <span class="hljs-string">&#x27;mask&#x27;</span>: &lt;PIL.Image.Image image mode=L size=640x427 at <span class="hljs-number">0x7FD5B2062690</span>&gt;},
 {<span class="hljs-string">&#x27;score&#x27;</span>: <span class="hljs-literal">None</span>,
  <span class="hljs-string">&#x27;label&#x27;</span>: <span class="hljs-string">&#x27;sky&#x27;</span>,
  <span class="hljs-string">&#x27;mask&#x27;</span>: &lt;PIL.Image.Image image mode=L size=640x427 at <span class="hljs-number">0x7FD5B2062A50</span>&gt;},
 {<span class="hljs-string">&#x27;score&#x27;</span>: <span class="hljs-literal">None</span>,
  <span class="hljs-string">&#x27;label&#x27;</span>: <span class="hljs-string">&#x27;floor&#x27;</span>,
  <span class="hljs-string">&#x27;mask&#x27;</span>: &lt;PIL.Image.Image image mode=L size=640x427 at <span class="hljs-number">0x7FD5B2062B50</span>&gt;},
 {<span class="hljs-string">&#x27;score&#x27;</span>: <span class="hljs-literal">None</span>,
  <span class="hljs-string">&#x27;label&#x27;</span>: <span class="hljs-string">&#x27;ceiling&#x27;</span>,
  <span class="hljs-string">&#x27;mask&#x27;</span>: &lt;PIL.Image.Image image mode=L size=640x427 at <span class="hljs-number">0x7FD5B2062A10</span>&gt;},
 {<span class="hljs-string">&#x27;score&#x27;</span>: <span class="hljs-literal">None</span>,
  <span class="hljs-string">&#x27;label&#x27;</span>: <span class="hljs-string">&#x27;bed &#x27;</span>,
  <span class="hljs-string">&#x27;mask&#x27;</span>: &lt;PIL.Image.Image image mode=L size=640x427 at <span class="hljs-number">0x7FD5B2062E90</span>&gt;},
 {<span class="hljs-string">&#x27;score&#x27;</span>: <span class="hljs-literal">None</span>,
  <span class="hljs-string">&#x27;label&#x27;</span>: <span class="hljs-string">&#x27;windowpane&#x27;</span>,
  <span class="hljs-string">&#x27;mask&#x27;</span>: &lt;PIL.Image.Image image mode=L size=640x427 at <span class="hljs-number">0x7FD5B2062390</span>&gt;},
 {<span class="hljs-string">&#x27;score&#x27;</span>: <span class="hljs-literal">None</span>,
  <span class="hljs-string">&#x27;label&#x27;</span>: <span class="hljs-string">&#x27;cabinet&#x27;</span>,
  <span class="hljs-string">&#x27;mask&#x27;</span>: &lt;PIL.Image.Image image mode=L size=640x427 at <span class="hljs-number">0x7FD5B2062550</span>&gt;},
 {<span class="hljs-string">&#x27;score&#x27;</span>: <span class="hljs-literal">None</span>,
  <span class="hljs-string">&#x27;label&#x27;</span>: <span class="hljs-string">&#x27;chair&#x27;</span>,
  <span class="hljs-string">&#x27;mask&#x27;</span>: &lt;PIL.Image.Image image mode=L size=640x427 at <span class="hljs-number">0x7FD5B2062D90</span>&gt;},
 {<span class="hljs-string">&#x27;score&#x27;</span>: <span class="hljs-literal">None</span>,
  <span class="hljs-string">&#x27;label&#x27;</span>: <span class="hljs-string">&#x27;armchair&#x27;</span>,
  <span class="hljs-string">&#x27;mask&#x27;</span>: &lt;PIL.Image.Image image mode=L size=640x427 at <span class="hljs-number">0x7FD5B2062E10</span>&gt;}]`}}),Qe=new $({props:{code:`device = torch.device("cuda" if torch.cuda.is_available() else "cpu")  # use GPU if available, otherwise use a CPU
encoding = feature_extractor(image, return_tensors="pt")
pixel_values = encoding.pixel_values.to(device)`,highlighted:`<span class="hljs-meta">&gt;&gt;&gt; </span>device = torch.device(<span class="hljs-string">&quot;cuda&quot;</span> <span class="hljs-keyword">if</span> torch.cuda.is_available() <span class="hljs-keyword">else</span> <span class="hljs-string">&quot;cpu&quot;</span>)  <span class="hljs-comment"># use GPU if available, otherwise use a CPU</span>
<span class="hljs-meta">&gt;&gt;&gt; </span>encoding = feature_extractor(image, return_tensors=<span class="hljs-string">&quot;pt&quot;</span>)
<span class="hljs-meta">&gt;&gt;&gt; </span>pixel_values = encoding.pixel_values.to(device)`}}),Xe=new $({props:{code:`outputs = model(pixel_values=pixel_values)
logits = outputs.logits.cpu()`,highlighted:`<span class="hljs-meta">&gt;&gt;&gt; </span>outputs = model(pixel_values=pixel_values)
<span class="hljs-meta">&gt;&gt;&gt; </span>logits = outputs.logits.cpu()`}}),Ze=new $({props:{code:`upsampled_logits = nn.functional.interpolate(
    logits,
    size=image.size[::-1],
    mode="bilinear",
    align_corners=False,
)

pred_seg = upsampled_logits.argmax(dim=1)[0]`,highlighted:`<span class="hljs-meta">&gt;&gt;&gt; </span>upsampled_logits = nn.functional.interpolate(
<span class="hljs-meta">... </span>    logits,
<span class="hljs-meta">... </span>    size=image.size[::-<span class="hljs-number">1</span>],
<span class="hljs-meta">... </span>    mode=<span class="hljs-string">&quot;bilinear&quot;</span>,
<span class="hljs-meta">... </span>    align_corners=<span class="hljs-literal">False</span>,
<span class="hljs-meta">... </span>)

<span class="hljs-meta">&gt;&gt;&gt; </span>pred_seg = upsampled_logits.argmax(dim=<span class="hljs-number">1</span>)[<span class="hljs-number">0</span>]`}}),ss=new $({props:{code:`import matplotlib.pyplot as plt

color_seg = np.zeros((pred_seg.shape[0], pred_seg.shape[1], 3), dtype=np.uint8)
palette = np.array(ade_palette())
for label, color in enumerate(palette):
    color_seg[pred_seg == label, :] = color
color_seg = color_seg[..., ::-1]  # convert to BGR

img = np.array(image) * 0.5 + color_seg * 0.5  # plot the image with the segmentation map
img = img.astype(np.uint8)

plt.figure(figsize=(15, 10))
plt.imshow(img)
plt.show()`,highlighted:`<span class="hljs-meta">&gt;&gt;&gt; </span><span class="hljs-keyword">import</span> matplotlib.pyplot <span class="hljs-keyword">as</span> plt

<span class="hljs-meta">&gt;&gt;&gt; </span>color_seg = np.zeros((pred_seg.shape[<span class="hljs-number">0</span>], pred_seg.shape[<span class="hljs-number">1</span>], <span class="hljs-number">3</span>), dtype=np.uint8)
<span class="hljs-meta">&gt;&gt;&gt; </span>palette = np.array(ade_palette())
<span class="hljs-meta">&gt;&gt;&gt; </span><span class="hljs-keyword">for</span> label, color <span class="hljs-keyword">in</span> <span class="hljs-built_in">enumerate</span>(palette):
<span class="hljs-meta">... </span>    color_seg[pred_seg == label, :] = color
<span class="hljs-meta">&gt;&gt;&gt; </span>color_seg = color_seg[..., ::-<span class="hljs-number">1</span>]  <span class="hljs-comment"># convert to BGR</span>

<span class="hljs-meta">&gt;&gt;&gt; </span>img = np.array(image) * <span class="hljs-number">0.5</span> + color_seg * <span class="hljs-number">0.5</span>  <span class="hljs-comment"># plot the image with the segmentation map</span>
<span class="hljs-meta">&gt;&gt;&gt; </span>img = img.astype(np.uint8)

<span class="hljs-meta">&gt;&gt;&gt; </span>plt.figure(figsize=(<span class="hljs-number">15</span>, <span class="hljs-number">10</span>))
<span class="hljs-meta">&gt;&gt;&gt; </span>plt.imshow(img)
<span class="hljs-meta">&gt;&gt;&gt; </span>plt.show()`}}),{c(){v=o("meta"),q=m(),j=o("h1"),k=o("a"),I=o("span"),u(w.$$.fragment),P=m(),A=o("span"),J=t("Semantic segmentation"),T=m(),u(F.$$.fragment),fe=m(),u(ge.$$.fragment),Pa=m(),os=o("p"),Yt=t("Semantic segmentation assigns a label or class to each individual pixel of an image. There are several types of segmentation, and in the case of semantic segmentation, no distinction is made between unique instances of the same object. Both objects are given the same label (for example, \u201Ccar\u201D instead of \u201Ccar-1\u201D and \u201Ccar-2\u201D). Common real-world applications of semantic segmentation include training self-driving cars to identify pedestrians and important traffic information, identifying cells and abnormalities in medical imagery, and monitoring environmental changes from satellite imagery."),Ia=m(),rs=o("p"),Gt=t("This guide will show you how to:"),Ta=m(),ee=o("ol"),R=o("li"),Jt=t("Finetune "),de=o("a"),Rt=t("SegFormer"),Wt=t(" on the "),_e=o("a"),Vt=t("SceneParse150"),Kt=t(" dataset."),Qt=m(),Bs=o("li"),Xt=t("Use your finetuned model for inference."),qa=m(),u(se.$$.fragment),Aa=m(),is=o("p"),Zt=t("Before you begin, make sure you have all the necessary libraries installed:"),Sa=m(),u(be.$$.fragment),Da=m(),ps=o("p"),el=t("We encourage you to login to your Hugging Face account so you can upload and share your model with the community. When prompted, enter your token to login:"),Fa=m(),u(ve.$$.fragment),Ca=m(),W=o("h2"),ae=o("a"),Hs=o("span"),u(je.$$.fragment),sl=m(),Ms=o("span"),al=t("Load SceneParse150 dataset"),La=m(),ms=o("p"),tl=t("Start by loading a smaller subset of the SceneParse150 dataset from the \u{1F917} Datasets library. This\u2019ll give you a chance to experiment and make sure everythings works before spending more time training on the full dataset."),za=m(),u(ye.$$.fragment),Oa=m(),C=o("p"),ll=t("Split the dataset\u2019s "),Us=o("code"),nl=t("train"),ol=t(" split into a train and test set with the "),$e=o("a"),rl=t("train_test_split"),il=t(" method:"),Na=m(),u(we.$$.fragment),Ba=m(),cs=o("p"),pl=t("Then take a look at an example:"),Ha=m(),u(xe.$$.fragment),Ma=m(),L=o("ul"),hs=o("li"),Ys=o("code"),ml=t("image"),cl=t(": a PIL image of the scene."),hl=m(),us=o("li"),Gs=o("code"),ul=t("annotation"),fl=t(": a PIL image of the segmentation map, which is also the model\u2019s target."),gl=m(),z=o("li"),Js=o("code"),dl=t("scene_category"),_l=t(": a category id that describes the image scene like \u201Ckitchen\u201D or \u201Coffice\u201D. In this guide, you\u2019ll only need "),Rs=o("code"),bl=t("image"),vl=t(" and "),Ws=o("code"),jl=t("annotation"),yl=t(", both of which are PIL images."),Ua=m(),O=o("p"),$l=t("You\u2019ll also want to create a dictionary that maps a label id to a label class which will be useful when you set up the model later. Download the mappings from the Hub and create the "),Vs=o("code"),wl=t("id2label"),xl=t(" and "),Ks=o("code"),kl=t("label2id"),El=t(" dictionaries:"),Ya=m(),u(ke.$$.fragment),Ga=m(),V=o("h2"),te=o("a"),Qs=o("span"),u(Ee.$$.fragment),Pl=m(),Xs=o("span"),Il=t("Preprocess"),Ja=m(),N=o("p"),Tl=t("The next step is to load a SegFormer image processor to prepare the images and annotations for the model. Some datasets, like this one, use the zero-index as the background class. However, the background class isn\u2019t actually included in the 150 classes, so you\u2019ll need to set "),Zs=o("code"),ql=t("reduce_labels=True"),Al=t(" to subtract one from all the labels. The zero-index is replaced by "),ea=o("code"),Sl=t("255"),Dl=t(" so it\u2019s ignored by SegFormer\u2019s loss function:"),Ra=m(),u(Pe.$$.fragment),Wa=m(),B=o("p"),Fl=t("It is common to apply some data augmentations to an image dataset to make a model more robust against overfitting. In this guide, you\u2019ll use the "),Ie=o("a"),sa=o("code"),Cl=t("ColorJitter"),Ll=t(" function from "),Te=o("a"),zl=t("torchvision"),Ol=t(" to randomly change the color properties of an image, but you can also use any image library you like."),Va=m(),u(qe.$$.fragment),Ka=m(),E=o("p"),Nl=t("Now create two preprocessing functions to prepare the images and annotations for the model. These functions convert the images into "),aa=o("code"),Bl=t("pixel_values"),Hl=t(" and annotations to "),ta=o("code"),Ml=t("labels"),Ul=t(". For the training set, "),la=o("code"),Yl=t("jitter"),Gl=t(" is applied before providing the images to the image processor. For the test set, the image processor crops and normalizes the "),na=o("code"),Jl=t("images"),Rl=t(", and only crops the "),oa=o("code"),Wl=t("labels"),Vl=t(" because no data augmentation is applied during testing."),Qa=m(),u(Ae.$$.fragment),Xa=m(),H=o("p"),Kl=t("To apply the "),ra=o("code"),Ql=t("jitter"),Xl=t(" over the entire dataset, use the \u{1F917} Datasets "),Se=o("a"),Zl=t("set_transform"),en=t(" function. The transform is applied on the fly which is faster and consumes less disk space:"),Za=m(),u(De.$$.fragment),et=m(),K=o("h2"),le=o("a"),ia=o("span"),u(Fe.$$.fragment),sn=m(),pa=o("span"),an=t("Evaluate"),st=m(),S=o("p"),tn=t("Including a metric during training is often helpful for evaluating your model\u2019s performance. You can quickly load a evaluation method with the \u{1F917} "),Ce=o("a"),ln=t("Evaluate"),nn=t(" library. For this task, load the "),Le=o("a"),on=t("mean Intersection over Union"),rn=t(" (IoU) metric (see the \u{1F917} Evaluate "),ze=o("a"),pn=t("quick tour"),mn=t(" to learn more about how to load and compute a metric):"),at=m(),u(Oe.$$.fragment),tt=m(),M=o("p"),cn=t("Then create a function to "),Ne=o("a"),hn=t("compute"),un=t(" the metrics. Your predictions need to be converted to logits first, and then reshaped to match the size of the labels before you can call "),Be=o("a"),fn=t("compute"),gn=t(":"),lt=m(),u(He.$$.fragment),nt=m(),ne=o("p"),dn=t("Your "),ma=o("code"),_n=t("compute_metrics"),bn=t(" function is ready to go now, and you\u2019ll return to it when you setup your training."),ot=m(),Q=o("h2"),oe=o("a"),ca=o("span"),u(Me.$$.fragment),vn=m(),ha=o("span"),jn=t("Train"),rt=m(),u(re.$$.fragment),it=m(),ie=o("p"),yn=t("You\u2019re ready to start training your model now! Load SegFormer with "),fs=o("a"),$n=t("AutoModelForSemanticSegmentation"),wn=t(", and pass the model the mapping between label ids and label classes:"),pt=m(),u(Ue.$$.fragment),mt=m(),gs=o("p"),xn=t("At this point, only three steps remain:"),ct=m(),U=o("ol"),y=o("li"),kn=t("Define your training hyperparameters in "),ds=o("a"),En=t("TrainingArguments"),Pn=t(". It is important you don\u2019t remove unused columns because this\u2019ll drop the "),ua=o("code"),In=t("image"),Tn=t(" column. Without the "),fa=o("code"),qn=t("image"),An=t(" column, you can\u2019t create "),ga=o("code"),Sn=t("pixel_values"),Dn=t(". Set "),da=o("code"),Fn=t("remove_unused_columns=False"),Cn=t(" to prevent this behavior! The only other required parameter is "),_a=o("code"),Ln=t("output_dir"),zn=t(" which specifies where to save your model. You\u2019ll push this model to the Hub by setting "),ba=o("code"),On=t("push_to_hub=True"),Nn=t(" (you need to be signed in to Hugging Face to upload your model). At the end of each epoch, the "),_s=o("a"),Bn=t("Trainer"),Hn=t(" will evaluate the IoU metric and save the training checkpoint."),Mn=m(),X=o("li"),Un=t("Pass the training arguments to "),bs=o("a"),Yn=t("Trainer"),Gn=t(" along with the model, dataset, tokenizer, data collator, and "),va=o("code"),Jn=t("compute_metrics"),Rn=t(" function."),Wn=m(),Ye=o("li"),Vn=t("Call "),vs=o("a"),Kn=t("train()"),Qn=t(" to finetune your model."),ht=m(),u(Ge.$$.fragment),ut=m(),pe=o("p"),Xn=t("Once training is completed, share your model to the Hub with the "),js=o("a"),Zn=t("push_to_hub()"),eo=t(" method so everyone can use your model:"),ft=m(),u(Je.$$.fragment),gt=m(),Z=o("h2"),me=o("a"),ja=o("span"),u(Re.$$.fragment),so=m(),ya=o("span"),ao=t("Inference"),dt=m(),ys=o("p"),to=t("Great, now that you\u2019ve finetuned a model, you can use it for inference!"),_t=m(),$s=o("p"),lo=t("Load an image for inference:"),bt=m(),u(We.$$.fragment),vt=m(),Ve=o("div"),ws=o("img"),jt=m(),Y=o("p"),no=t("The simplest way to try out your finetuned model for inference is to use it in a "),xs=o("a"),oo=t("pipeline()"),ro=t(". Instantiate a "),$a=o("code"),io=t("pipeline"),po=t(" for image segmentation with your model, and pass your image to it:"),yt=m(),u(Ke.$$.fragment),$t=m(),G=o("p"),mo=t("You can also manually replicate the results of the "),wa=o("code"),co=t("pipeline"),ho=t(" if you\u2019d like. Process the image with an image processor and place the "),xa=o("code"),uo=t("pixel_values"),fo=t(" on a GPU:"),wt=m(),u(Qe.$$.fragment),xt=m(),ce=o("p"),go=t("Pass your input to the model and return the "),ka=o("code"),_o=t("logits"),bo=t(":"),kt=m(),u(Xe.$$.fragment),Et=m(),ks=o("p"),vo=t("Next, rescale the logits to the original image size:"),Pt=m(),u(Ze.$$.fragment),It=m(),he=o("p"),jo=t("To visualize the results, load the "),es=o("a"),yo=t("dataset color palette"),$o=t(" that maps each class to their RGB values. Then you can combine and plot your image and the predicted segmentation map:"),Tt=m(),u(ss.$$.fragment),qt=m(),as=o("div"),Es=o("img"),this.h()},l(e){const n=ai('[data-svelte="svelte-1phssyn"]',document.head);v=r(n,"META",{name:!0,content:!0}),n.forEach(a),q=c(e),j=r(e,"H1",{class:!0});var ts=i(j);k=r(ts,"A",{id:!0,class:!0,href:!0});var Ea=i(k);I=r(Ea,"SPAN",{});var Po=i(I);f(w.$$.fragment,Po),Po.forEach(a),Ea.forEach(a),P=c(ts),A=r(ts,"SPAN",{});var Io=i(A);J=l(Io,"Semantic segmentation"),Io.forEach(a),ts.forEach(a),T=c(e),f(F.$$.fragment,e),fe=c(e),f(ge.$$.fragment,e),Pa=c(e),os=r(e,"P",{});var To=i(os);Yt=l(To,"Semantic segmentation assigns a label or class to each individual pixel of an image. There are several types of segmentation, and in the case of semantic segmentation, no distinction is made between unique instances of the same object. Both objects are given the same label (for example, \u201Ccar\u201D instead of \u201Ccar-1\u201D and \u201Ccar-2\u201D). Common real-world applications of semantic segmentation include training self-driving cars to identify pedestrians and important traffic information, identifying cells and abnormalities in medical imagery, and monitoring environmental changes from satellite imagery."),To.forEach(a),Ia=c(e),rs=r(e,"P",{});var qo=i(rs);Gt=l(qo,"This guide will show you how to:"),qo.forEach(a),Ta=c(e),ee=r(e,"OL",{});var St=i(ee);R=r(St,"LI",{});var Ps=i(R);Jt=l(Ps,"Finetune "),de=r(Ps,"A",{href:!0,rel:!0});var Ao=i(de);Rt=l(Ao,"SegFormer"),Ao.forEach(a),Wt=l(Ps," on the "),_e=r(Ps,"A",{href:!0,rel:!0});var So=i(_e);Vt=l(So,"SceneParse150"),So.forEach(a),Kt=l(Ps," dataset."),Ps.forEach(a),Qt=c(St),Bs=r(St,"LI",{});var Do=i(Bs);Xt=l(Do,"Use your finetuned model for inference."),Do.forEach(a),St.forEach(a),qa=c(e),f(se.$$.fragment,e),Aa=c(e),is=r(e,"P",{});var Fo=i(is);Zt=l(Fo,"Before you begin, make sure you have all the necessary libraries installed:"),Fo.forEach(a),Sa=c(e),f(be.$$.fragment,e),Da=c(e),ps=r(e,"P",{});var Co=i(ps);el=l(Co,"We encourage you to login to your Hugging Face account so you can upload and share your model with the community. When prompted, enter your token to login:"),Co.forEach(a),Fa=c(e),f(ve.$$.fragment,e),Ca=c(e),W=r(e,"H2",{class:!0});var Dt=i(W);ae=r(Dt,"A",{id:!0,class:!0,href:!0});var Lo=i(ae);Hs=r(Lo,"SPAN",{});var zo=i(Hs);f(je.$$.fragment,zo),zo.forEach(a),Lo.forEach(a),sl=c(Dt),Ms=r(Dt,"SPAN",{});var Oo=i(Ms);al=l(Oo,"Load SceneParse150 dataset"),Oo.forEach(a),Dt.forEach(a),La=c(e),ms=r(e,"P",{});var No=i(ms);tl=l(No,"Start by loading a smaller subset of the SceneParse150 dataset from the \u{1F917} Datasets library. This\u2019ll give you a chance to experiment and make sure everythings works before spending more time training on the full dataset."),No.forEach(a),za=c(e),f(ye.$$.fragment,e),Oa=c(e),C=r(e,"P",{});var Is=i(C);ll=l(Is,"Split the dataset\u2019s "),Us=r(Is,"CODE",{});var Bo=i(Us);nl=l(Bo,"train"),Bo.forEach(a),ol=l(Is," split into a train and test set with the "),$e=r(Is,"A",{href:!0,rel:!0});var Ho=i($e);rl=l(Ho,"train_test_split"),Ho.forEach(a),il=l(Is," method:"),Is.forEach(a),Na=c(e),f(we.$$.fragment,e),Ba=c(e),cs=r(e,"P",{});var Mo=i(cs);pl=l(Mo,"Then take a look at an example:"),Mo.forEach(a),Ha=c(e),f(xe.$$.fragment,e),Ma=c(e),L=r(e,"UL",{});var Ts=i(L);hs=r(Ts,"LI",{});var wo=i(hs);Ys=r(wo,"CODE",{});var Uo=i(Ys);ml=l(Uo,"image"),Uo.forEach(a),cl=l(wo,": a PIL image of the scene."),wo.forEach(a),hl=c(Ts),us=r(Ts,"LI",{});var xo=i(us);Gs=r(xo,"CODE",{});var Yo=i(Gs);ul=l(Yo,"annotation"),Yo.forEach(a),fl=l(xo,": a PIL image of the segmentation map, which is also the model\u2019s target."),xo.forEach(a),gl=c(Ts),z=r(Ts,"LI",{});var ls=i(z);Js=r(ls,"CODE",{});var Go=i(Js);dl=l(Go,"scene_category"),Go.forEach(a),_l=l(ls,": a category id that describes the image scene like \u201Ckitchen\u201D or \u201Coffice\u201D. In this guide, you\u2019ll only need "),Rs=r(ls,"CODE",{});var Jo=i(Rs);bl=l(Jo,"image"),Jo.forEach(a),vl=l(ls," and "),Ws=r(ls,"CODE",{});var Ro=i(Ws);jl=l(Ro,"annotation"),Ro.forEach(a),yl=l(ls,", both of which are PIL images."),ls.forEach(a),Ts.forEach(a),Ua=c(e),O=r(e,"P",{});var qs=i(O);$l=l(qs,"You\u2019ll also want to create a dictionary that maps a label id to a label class which will be useful when you set up the model later. Download the mappings from the Hub and create the "),Vs=r(qs,"CODE",{});var Wo=i(Vs);wl=l(Wo,"id2label"),Wo.forEach(a),xl=l(qs," and "),Ks=r(qs,"CODE",{});var Vo=i(Ks);kl=l(Vo,"label2id"),Vo.forEach(a),El=l(qs," dictionaries:"),qs.forEach(a),Ya=c(e),f(ke.$$.fragment,e),Ga=c(e),V=r(e,"H2",{class:!0});var Ft=i(V);te=r(Ft,"A",{id:!0,class:!0,href:!0});var Ko=i(te);Qs=r(Ko,"SPAN",{});var Qo=i(Qs);f(Ee.$$.fragment,Qo),Qo.forEach(a),Ko.forEach(a),Pl=c(Ft),Xs=r(Ft,"SPAN",{});var Xo=i(Xs);Il=l(Xo,"Preprocess"),Xo.forEach(a),Ft.forEach(a),Ja=c(e),N=r(e,"P",{});var As=i(N);Tl=l(As,"The next step is to load a SegFormer image processor to prepare the images and annotations for the model. Some datasets, like this one, use the zero-index as the background class. However, the background class isn\u2019t actually included in the 150 classes, so you\u2019ll need to set "),Zs=r(As,"CODE",{});var Zo=i(Zs);ql=l(Zo,"reduce_labels=True"),Zo.forEach(a),Al=l(As," to subtract one from all the labels. The zero-index is replaced by "),ea=r(As,"CODE",{});var er=i(ea);Sl=l(er,"255"),er.forEach(a),Dl=l(As," so it\u2019s ignored by SegFormer\u2019s loss function:"),As.forEach(a),Ra=c(e),f(Pe.$$.fragment,e),Wa=c(e),B=r(e,"P",{});var Ss=i(B);Fl=l(Ss,"It is common to apply some data augmentations to an image dataset to make a model more robust against overfitting. In this guide, you\u2019ll use the "),Ie=r(Ss,"A",{href:!0,rel:!0});var sr=i(Ie);sa=r(sr,"CODE",{});var ar=i(sa);Cl=l(ar,"ColorJitter"),ar.forEach(a),sr.forEach(a),Ll=l(Ss," function from "),Te=r(Ss,"A",{href:!0,rel:!0});var tr=i(Te);zl=l(tr,"torchvision"),tr.forEach(a),Ol=l(Ss," to randomly change the color properties of an image, but you can also use any image library you like."),Ss.forEach(a),Va=c(e),f(qe.$$.fragment,e),Ka=c(e),E=r(e,"P",{});var D=i(E);Nl=l(D,"Now create two preprocessing functions to prepare the images and annotations for the model. These functions convert the images into "),aa=r(D,"CODE",{});var lr=i(aa);Bl=l(lr,"pixel_values"),lr.forEach(a),Hl=l(D," and annotations to "),ta=r(D,"CODE",{});var nr=i(ta);Ml=l(nr,"labels"),nr.forEach(a),Ul=l(D,". For the training set, "),la=r(D,"CODE",{});var or=i(la);Yl=l(or,"jitter"),or.forEach(a),Gl=l(D," is applied before providing the images to the image processor. For the test set, the image processor crops and normalizes the "),na=r(D,"CODE",{});var rr=i(na);Jl=l(rr,"images"),rr.forEach(a),Rl=l(D,", and only crops the "),oa=r(D,"CODE",{});var ir=i(oa);Wl=l(ir,"labels"),ir.forEach(a),Vl=l(D," because no data augmentation is applied during testing."),D.forEach(a),Qa=c(e),f(Ae.$$.fragment,e),Xa=c(e),H=r(e,"P",{});var Ds=i(H);Kl=l(Ds,"To apply the "),ra=r(Ds,"CODE",{});var pr=i(ra);Ql=l(pr,"jitter"),pr.forEach(a),Xl=l(Ds," over the entire dataset, use the \u{1F917} Datasets "),Se=r(Ds,"A",{href:!0,rel:!0});var mr=i(Se);Zl=l(mr,"set_transform"),mr.forEach(a),en=l(Ds," function. The transform is applied on the fly which is faster and consumes less disk space:"),Ds.forEach(a),Za=c(e),f(De.$$.fragment,e),et=c(e),K=r(e,"H2",{class:!0});var Ct=i(K);le=r(Ct,"A",{id:!0,class:!0,href:!0});var cr=i(le);ia=r(cr,"SPAN",{});var hr=i(ia);f(Fe.$$.fragment,hr),hr.forEach(a),cr.forEach(a),sn=c(Ct),pa=r(Ct,"SPAN",{});var ur=i(pa);an=l(ur,"Evaluate"),ur.forEach(a),Ct.forEach(a),st=c(e),S=r(e,"P",{});var ue=i(S);tn=l(ue,"Including a metric during training is often helpful for evaluating your model\u2019s performance. You can quickly load a evaluation method with the \u{1F917} "),Ce=r(ue,"A",{href:!0,rel:!0});var fr=i(Ce);ln=l(fr,"Evaluate"),fr.forEach(a),nn=l(ue," library. For this task, load the "),Le=r(ue,"A",{href:!0,rel:!0});var gr=i(Le);on=l(gr,"mean Intersection over Union"),gr.forEach(a),rn=l(ue," (IoU) metric (see the \u{1F917} Evaluate "),ze=r(ue,"A",{href:!0,rel:!0});var dr=i(ze);pn=l(dr,"quick tour"),dr.forEach(a),mn=l(ue," to learn more about how to load and compute a metric):"),ue.forEach(a),at=c(e),f(Oe.$$.fragment,e),tt=c(e),M=r(e,"P",{});var Fs=i(M);cn=l(Fs,"Then create a function to "),Ne=r(Fs,"A",{href:!0,rel:!0});var _r=i(Ne);hn=l(_r,"compute"),_r.forEach(a),un=l(Fs," the metrics. Your predictions need to be converted to logits first, and then reshaped to match the size of the labels before you can call "),Be=r(Fs,"A",{href:!0,rel:!0});var br=i(Be);fn=l(br,"compute"),br.forEach(a),gn=l(Fs,":"),Fs.forEach(a),lt=c(e),f(He.$$.fragment,e),nt=c(e),ne=r(e,"P",{});var Lt=i(ne);dn=l(Lt,"Your "),ma=r(Lt,"CODE",{});var vr=i(ma);_n=l(vr,"compute_metrics"),vr.forEach(a),bn=l(Lt," function is ready to go now, and you\u2019ll return to it when you setup your training."),Lt.forEach(a),ot=c(e),Q=r(e,"H2",{class:!0});var zt=i(Q);oe=r(zt,"A",{id:!0,class:!0,href:!0});var jr=i(oe);ca=r(jr,"SPAN",{});var yr=i(ca);f(Me.$$.fragment,yr),yr.forEach(a),jr.forEach(a),vn=c(zt),ha=r(zt,"SPAN",{});var $r=i(ha);jn=l($r,"Train"),$r.forEach(a),zt.forEach(a),rt=c(e),f(re.$$.fragment,e),it=c(e),ie=r(e,"P",{});var Ot=i(ie);yn=l(Ot,"You\u2019re ready to start training your model now! Load SegFormer with "),fs=r(Ot,"A",{href:!0});var wr=i(fs);$n=l(wr,"AutoModelForSemanticSegmentation"),wr.forEach(a),wn=l(Ot,", and pass the model the mapping between label ids and label classes:"),Ot.forEach(a),pt=c(e),f(Ue.$$.fragment,e),mt=c(e),gs=r(e,"P",{});var xr=i(gs);xn=l(xr,"At this point, only three steps remain:"),xr.forEach(a),ct=c(e),U=r(e,"OL",{});var Cs=i(U);y=r(Cs,"LI",{});var x=i(y);kn=l(x,"Define your training hyperparameters in "),ds=r(x,"A",{href:!0});var kr=i(ds);En=l(kr,"TrainingArguments"),kr.forEach(a),Pn=l(x,". It is important you don\u2019t remove unused columns because this\u2019ll drop the "),ua=r(x,"CODE",{});var Er=i(ua);In=l(Er,"image"),Er.forEach(a),Tn=l(x," column. Without the "),fa=r(x,"CODE",{});var Pr=i(fa);qn=l(Pr,"image"),Pr.forEach(a),An=l(x," column, you can\u2019t create "),ga=r(x,"CODE",{});var Ir=i(ga);Sn=l(Ir,"pixel_values"),Ir.forEach(a),Dn=l(x,". Set "),da=r(x,"CODE",{});var Tr=i(da);Fn=l(Tr,"remove_unused_columns=False"),Tr.forEach(a),Cn=l(x," to prevent this behavior! The only other required parameter is "),_a=r(x,"CODE",{});var qr=i(_a);Ln=l(qr,"output_dir"),qr.forEach(a),zn=l(x," which specifies where to save your model. You\u2019ll push this model to the Hub by setting "),ba=r(x,"CODE",{});var Ar=i(ba);On=l(Ar,"push_to_hub=True"),Ar.forEach(a),Nn=l(x," (you need to be signed in to Hugging Face to upload your model). At the end of each epoch, the "),_s=r(x,"A",{href:!0});var Sr=i(_s);Bn=l(Sr,"Trainer"),Sr.forEach(a),Hn=l(x," will evaluate the IoU metric and save the training checkpoint."),x.forEach(a),Mn=c(Cs),X=r(Cs,"LI",{});var Ls=i(X);Un=l(Ls,"Pass the training arguments to "),bs=r(Ls,"A",{href:!0});var Dr=i(bs);Yn=l(Dr,"Trainer"),Dr.forEach(a),Gn=l(Ls," along with the model, dataset, tokenizer, data collator, and "),va=r(Ls,"CODE",{});var Fr=i(va);Jn=l(Fr,"compute_metrics"),Fr.forEach(a),Rn=l(Ls," function."),Ls.forEach(a),Wn=c(Cs),Ye=r(Cs,"LI",{});var Nt=i(Ye);Vn=l(Nt,"Call "),vs=r(Nt,"A",{href:!0});var Cr=i(vs);Kn=l(Cr,"train()"),Cr.forEach(a),Qn=l(Nt," to finetune your model."),Nt.forEach(a),Cs.forEach(a),ht=c(e),f(Ge.$$.fragment,e),ut=c(e),pe=r(e,"P",{});var Bt=i(pe);Xn=l(Bt,"Once training is completed, share your model to the Hub with the "),js=r(Bt,"A",{href:!0});var Lr=i(js);Zn=l(Lr,"push_to_hub()"),Lr.forEach(a),eo=l(Bt," method so everyone can use your model:"),Bt.forEach(a),ft=c(e),f(Je.$$.fragment,e),gt=c(e),Z=r(e,"H2",{class:!0});var Ht=i(Z);me=r(Ht,"A",{id:!0,class:!0,href:!0});var zr=i(me);ja=r(zr,"SPAN",{});var Or=i(ja);f(Re.$$.fragment,Or),Or.forEach(a),zr.forEach(a),so=c(Ht),ya=r(Ht,"SPAN",{});var Nr=i(ya);ao=l(Nr,"Inference"),Nr.forEach(a),Ht.forEach(a),dt=c(e),ys=r(e,"P",{});var Br=i(ys);to=l(Br,"Great, now that you\u2019ve finetuned a model, you can use it for inference!"),Br.forEach(a),_t=c(e),$s=r(e,"P",{});var Hr=i($s);lo=l(Hr,"Load an image for inference:"),Hr.forEach(a),bt=c(e),f(We.$$.fragment,e),vt=c(e),Ve=r(e,"DIV",{class:!0});var Mr=i(Ve);ws=r(Mr,"IMG",{src:!0,alt:!0}),Mr.forEach(a),jt=c(e),Y=r(e,"P",{});var zs=i(Y);no=l(zs,"The simplest way to try out your finetuned model for inference is to use it in a "),xs=r(zs,"A",{href:!0});var Ur=i(xs);oo=l(Ur,"pipeline()"),Ur.forEach(a),ro=l(zs,". Instantiate a "),$a=r(zs,"CODE",{});var Yr=i($a);io=l(Yr,"pipeline"),Yr.forEach(a),po=l(zs," for image segmentation with your model, and pass your image to it:"),zs.forEach(a),yt=c(e),f(Ke.$$.fragment,e),$t=c(e),G=r(e,"P",{});var Os=i(G);mo=l(Os,"You can also manually replicate the results of the "),wa=r(Os,"CODE",{});var Gr=i(wa);co=l(Gr,"pipeline"),Gr.forEach(a),ho=l(Os," if you\u2019d like. Process the image with an image processor and place the "),xa=r(Os,"CODE",{});var Jr=i(xa);uo=l(Jr,"pixel_values"),Jr.forEach(a),fo=l(Os," on a GPU:"),Os.forEach(a),wt=c(e),f(Qe.$$.fragment,e),xt=c(e),ce=r(e,"P",{});var Mt=i(ce);go=l(Mt,"Pass your input to the model and return the "),ka=r(Mt,"CODE",{});var Rr=i(ka);_o=l(Rr,"logits"),Rr.forEach(a),bo=l(Mt,":"),Mt.forEach(a),kt=c(e),f(Xe.$$.fragment,e),Et=c(e),ks=r(e,"P",{});var Wr=i(ks);vo=l(Wr,"Next, rescale the logits to the original image size:"),Wr.forEach(a),Pt=c(e),f(Ze.$$.fragment,e),It=c(e),he=r(e,"P",{});var Ut=i(he);jo=l(Ut,"To visualize the results, load the "),es=r(Ut,"A",{href:!0,rel:!0});var Vr=i(es);yo=l(Vr,"dataset color palette"),Vr.forEach(a),$o=l(Ut," that maps each class to their RGB values. Then you can combine and plot your image and the predicted segmentation map:"),Ut.forEach(a),Tt=c(e),f(ss.$$.fragment,e),qt=c(e),as=r(e,"DIV",{class:!0});var Kr=i(as);Es=r(Kr,"IMG",{src:!0,alt:!0}),Kr.forEach(a),this.h()},h(){h(v,"name","hf:doc:metadata"),h(v,"content",JSON.stringify(pi)),h(k,"id","semantic-segmentation"),h(k,"class","header-link block pr-1.5 text-lg no-hover:hidden with-hover:absolute with-hover:p-1.5 with-hover:opacity-0 with-hover:group-hover:opacity-100 with-hover:right-full"),h(k,"href","#semantic-segmentation"),h(j,"class","relative group"),h(de,"href","https://huggingface.co/docs/transformers/main/en/model_doc/segformer#segformer"),h(de,"rel","nofollow"),h(_e,"href","https://huggingface.co/datasets/scene_parse_150"),h(_e,"rel","nofollow"),h(ae,"id","load-sceneparse150-dataset"),h(ae,"class","header-link block pr-1.5 text-lg no-hover:hidden with-hover:absolute with-hover:p-1.5 with-hover:opacity-0 with-hover:group-hover:opacity-100 with-hover:right-full"),h(ae,"href","#load-sceneparse150-dataset"),h(W,"class","relative group"),h($e,"href","https://huggingface.co/docs/datasets/v2.7.1/en/package_reference/main_classes#datasets.Dataset.train_test_split"),h($e,"rel","nofollow"),h(te,"id","preprocess"),h(te,"class","header-link block pr-1.5 text-lg no-hover:hidden with-hover:absolute with-hover:p-1.5 with-hover:opacity-0 with-hover:group-hover:opacity-100 with-hover:right-full"),h(te,"href","#preprocess"),h(V,"class","relative group"),h(Ie,"href","https://pytorch.org/vision/stable/generated/torchvision.transforms.ColorJitter.html"),h(Ie,"rel","nofollow"),h(Te,"href","https://pytorch.org/vision/stable/index.html"),h(Te,"rel","nofollow"),h(Se,"href","https://huggingface.co/docs/datasets/v2.7.1/en/package_reference/main_classes#datasets.Dataset.set_transform"),h(Se,"rel","nofollow"),h(le,"id","evaluate"),h(le,"class","header-link block pr-1.5 text-lg no-hover:hidden with-hover:absolute with-hover:p-1.5 with-hover:opacity-0 with-hover:group-hover:opacity-100 with-hover:right-full"),h(le,"href","#evaluate"),h(K,"class","relative group"),h(Ce,"href","https://huggingface.co/docs/evaluate/index"),h(Ce,"rel","nofollow"),h(Le,"href","https://huggingface.co/spaces/evaluate-metric/accuracy"),h(Le,"rel","nofollow"),h(ze,"href","https://huggingface.co/docs/evaluate/a_quick_tour"),h(ze,"rel","nofollow"),h(Ne,"href","https://huggingface.co/docs/evaluate/v0.3.0/en/package_reference/main_classes#evaluate.EvaluationModule.compute"),h(Ne,"rel","nofollow"),h(Be,"href","https://huggingface.co/docs/evaluate/v0.3.0/en/package_reference/main_classes#evaluate.EvaluationModule.compute"),h(Be,"rel","nofollow"),h(oe,"id","train"),h(oe,"class","header-link block pr-1.5 text-lg no-hover:hidden with-hover:absolute with-hover:p-1.5 with-hover:opacity-0 with-hover:group-hover:opacity-100 with-hover:right-full"),h(oe,"href","#train"),h(Q,"class","relative group"),h(fs,"href","/docs/transformers/v4.25.1/en/model_doc/auto#transformers.AutoModelForSemanticSegmentation"),h(ds,"href","/docs/transformers/v4.25.1/en/main_classes/trainer#transformers.TrainingArguments"),h(_s,"href","/docs/transformers/v4.25.1/en/main_classes/trainer#transformers.Trainer"),h(bs,"href","/docs/transformers/v4.25.1/en/main_classes/trainer#transformers.Trainer"),h(vs,"href","/docs/transformers/v4.25.1/en/main_classes/trainer#transformers.Trainer.train"),h(js,"href","/docs/transformers/v4.25.1/en/main_classes/trainer#transformers.Trainer.push_to_hub"),h(me,"id","inference"),h(me,"class","header-link block pr-1.5 text-lg no-hover:hidden with-hover:absolute with-hover:p-1.5 with-hover:opacity-0 with-hover:group-hover:opacity-100 with-hover:right-full"),h(me,"href","#inference"),h(Z,"class","relative group"),Qr(ws.src,ko="https://huggingface.co/datasets/huggingface/documentation-images/resolve/main/semantic-seg-image.png")||h(ws,"src",ko),h(ws,"alt","Image of bedroom"),h(Ve,"class","flex justify-center"),h(xs,"href","/docs/transformers/v4.25.1/en/main_classes/pipelines#transformers.pipeline"),h(es,"href","https://github.com/tensorflow/models/blob/3f1ca33afe3c1631b733ea7e40c294273b9e406d/research/deeplab/utils/get_dataset_colormap.py#L51"),h(es,"rel","nofollow"),Qr(Es.src,Eo="https://huggingface.co/datasets/huggingface/documentation-images/resolve/main/semantic-seg-preds.png")||h(Es,"src",Eo),h(Es,"alt","Image of bedroom overlaid with segmentation map"),h(as,"class","flex justify-center")},m(e,n){s(document.head,v),p(e,q,n),p(e,j,n),s(j,k),s(k,I),g(w,I,null),s(j,P),s(j,A),s(A,J),p(e,T,n),g(F,e,n),p(e,fe,n),g(ge,e,n),p(e,Pa,n),p(e,os,n),s(os,Yt),p(e,Ia,n),p(e,rs,n),s(rs,Gt),p(e,Ta,n),p(e,ee,n),s(ee,R),s(R,Jt),s(R,de),s(de,Rt),s(R,Wt),s(R,_e),s(_e,Vt),s(R,Kt),s(ee,Qt),s(ee,Bs),s(Bs,Xt),p(e,qa,n),g(se,e,n),p(e,Aa,n),p(e,is,n),s(is,Zt),p(e,Sa,n),g(be,e,n),p(e,Da,n),p(e,ps,n),s(ps,el),p(e,Fa,n),g(ve,e,n),p(e,Ca,n),p(e,W,n),s(W,ae),s(ae,Hs),g(je,Hs,null),s(W,sl),s(W,Ms),s(Ms,al),p(e,La,n),p(e,ms,n),s(ms,tl),p(e,za,n),g(ye,e,n),p(e,Oa,n),p(e,C,n),s(C,ll),s(C,Us),s(Us,nl),s(C,ol),s(C,$e),s($e,rl),s(C,il),p(e,Na,n),g(we,e,n),p(e,Ba,n),p(e,cs,n),s(cs,pl),p(e,Ha,n),g(xe,e,n),p(e,Ma,n),p(e,L,n),s(L,hs),s(hs,Ys),s(Ys,ml),s(hs,cl),s(L,hl),s(L,us),s(us,Gs),s(Gs,ul),s(us,fl),s(L,gl),s(L,z),s(z,Js),s(Js,dl),s(z,_l),s(z,Rs),s(Rs,bl),s(z,vl),s(z,Ws),s(Ws,jl),s(z,yl),p(e,Ua,n),p(e,O,n),s(O,$l),s(O,Vs),s(Vs,wl),s(O,xl),s(O,Ks),s(Ks,kl),s(O,El),p(e,Ya,n),g(ke,e,n),p(e,Ga,n),p(e,V,n),s(V,te),s(te,Qs),g(Ee,Qs,null),s(V,Pl),s(V,Xs),s(Xs,Il),p(e,Ja,n),p(e,N,n),s(N,Tl),s(N,Zs),s(Zs,ql),s(N,Al),s(N,ea),s(ea,Sl),s(N,Dl),p(e,Ra,n),g(Pe,e,n),p(e,Wa,n),p(e,B,n),s(B,Fl),s(B,Ie),s(Ie,sa),s(sa,Cl),s(B,Ll),s(B,Te),s(Te,zl),s(B,Ol),p(e,Va,n),g(qe,e,n),p(e,Ka,n),p(e,E,n),s(E,Nl),s(E,aa),s(aa,Bl),s(E,Hl),s(E,ta),s(ta,Ml),s(E,Ul),s(E,la),s(la,Yl),s(E,Gl),s(E,na),s(na,Jl),s(E,Rl),s(E,oa),s(oa,Wl),s(E,Vl),p(e,Qa,n),g(Ae,e,n),p(e,Xa,n),p(e,H,n),s(H,Kl),s(H,ra),s(ra,Ql),s(H,Xl),s(H,Se),s(Se,Zl),s(H,en),p(e,Za,n),g(De,e,n),p(e,et,n),p(e,K,n),s(K,le),s(le,ia),g(Fe,ia,null),s(K,sn),s(K,pa),s(pa,an),p(e,st,n),p(e,S,n),s(S,tn),s(S,Ce),s(Ce,ln),s(S,nn),s(S,Le),s(Le,on),s(S,rn),s(S,ze),s(ze,pn),s(S,mn),p(e,at,n),g(Oe,e,n),p(e,tt,n),p(e,M,n),s(M,cn),s(M,Ne),s(Ne,hn),s(M,un),s(M,Be),s(Be,fn),s(M,gn),p(e,lt,n),g(He,e,n),p(e,nt,n),p(e,ne,n),s(ne,dn),s(ne,ma),s(ma,_n),s(ne,bn),p(e,ot,n),p(e,Q,n),s(Q,oe),s(oe,ca),g(Me,ca,null),s(Q,vn),s(Q,ha),s(ha,jn),p(e,rt,n),g(re,e,n),p(e,it,n),p(e,ie,n),s(ie,yn),s(ie,fs),s(fs,$n),s(ie,wn),p(e,pt,n),g(Ue,e,n),p(e,mt,n),p(e,gs,n),s(gs,xn),p(e,ct,n),p(e,U,n),s(U,y),s(y,kn),s(y,ds),s(ds,En),s(y,Pn),s(y,ua),s(ua,In),s(y,Tn),s(y,fa),s(fa,qn),s(y,An),s(y,ga),s(ga,Sn),s(y,Dn),s(y,da),s(da,Fn),s(y,Cn),s(y,_a),s(_a,Ln),s(y,zn),s(y,ba),s(ba,On),s(y,Nn),s(y,_s),s(_s,Bn),s(y,Hn),s(U,Mn),s(U,X),s(X,Un),s(X,bs),s(bs,Yn),s(X,Gn),s(X,va),s(va,Jn),s(X,Rn),s(U,Wn),s(U,Ye),s(Ye,Vn),s(Ye,vs),s(vs,Kn),s(Ye,Qn),p(e,ht,n),g(Ge,e,n),p(e,ut,n),p(e,pe,n),s(pe,Xn),s(pe,js),s(js,Zn),s(pe,eo),p(e,ft,n),g(Je,e,n),p(e,gt,n),p(e,Z,n),s(Z,me),s(me,ja),g(Re,ja,null),s(Z,so),s(Z,ya),s(ya,ao),p(e,dt,n),p(e,ys,n),s(ys,to),p(e,_t,n),p(e,$s,n),s($s,lo),p(e,bt,n),g(We,e,n),p(e,vt,n),p(e,Ve,n),s(Ve,ws),p(e,jt,n),p(e,Y,n),s(Y,no),s(Y,xs),s(xs,oo),s(Y,ro),s(Y,$a),s($a,io),s(Y,po),p(e,yt,n),g(Ke,e,n),p(e,$t,n),p(e,G,n),s(G,mo),s(G,wa),s(wa,co),s(G,ho),s(G,xa),s(xa,uo),s(G,fo),p(e,wt,n),g(Qe,e,n),p(e,xt,n),p(e,ce,n),s(ce,go),s(ce,ka),s(ka,_o),s(ce,bo),p(e,kt,n),g(Xe,e,n),p(e,Et,n),p(e,ks,n),s(ks,vo),p(e,Pt,n),g(Ze,e,n),p(e,It,n),p(e,he,n),s(he,jo),s(he,es),s(es,yo),s(he,$o),p(e,Tt,n),g(ss,e,n),p(e,qt,n),p(e,as,n),s(as,Es),At=!0},p(e,[n]){const ts={};n&2&&(ts.$$scope={dirty:n,ctx:e}),se.$set(ts);const Ea={};n&2&&(Ea.$$scope={dirty:n,ctx:e}),re.$set(Ea)},i(e){At||(d(w.$$.fragment,e),d(F.$$.fragment,e),d(ge.$$.fragment,e),d(se.$$.fragment,e),d(be.$$.fragment,e),d(ve.$$.fragment,e),d(je.$$.fragment,e),d(ye.$$.fragment,e),d(we.$$.fragment,e),d(xe.$$.fragment,e),d(ke.$$.fragment,e),d(Ee.$$.fragment,e),d(Pe.$$.fragment,e),d(qe.$$.fragment,e),d(Ae.$$.fragment,e),d(De.$$.fragment,e),d(Fe.$$.fragment,e),d(Oe.$$.fragment,e),d(He.$$.fragment,e),d(Me.$$.fragment,e),d(re.$$.fragment,e),d(Ue.$$.fragment,e),d(Ge.$$.fragment,e),d(Je.$$.fragment,e),d(Re.$$.fragment,e),d(We.$$.fragment,e),d(Ke.$$.fragment,e),d(Qe.$$.fragment,e),d(Xe.$$.fragment,e),d(Ze.$$.fragment,e),d(ss.$$.fragment,e),At=!0)},o(e){_(w.$$.fragment,e),_(F.$$.fragment,e),_(ge.$$.fragment,e),_(se.$$.fragment,e),_(be.$$.fragment,e),_(ve.$$.fragment,e),_(je.$$.fragment,e),_(ye.$$.fragment,e),_(we.$$.fragment,e),_(xe.$$.fragment,e),_(ke.$$.fragment,e),_(Ee.$$.fragment,e),_(Pe.$$.fragment,e),_(qe.$$.fragment,e),_(Ae.$$.fragment,e),_(De.$$.fragment,e),_(Fe.$$.fragment,e),_(Oe.$$.fragment,e),_(He.$$.fragment,e),_(Me.$$.fragment,e),_(re.$$.fragment,e),_(Ue.$$.fragment,e),_(Ge.$$.fragment,e),_(Je.$$.fragment,e),_(Re.$$.fragment,e),_(We.$$.fragment,e),_(Ke.$$.fragment,e),_(Qe.$$.fragment,e),_(Xe.$$.fragment,e),_(Ze.$$.fragment,e),_(ss.$$.fragment,e),At=!1},d(e){a(v),e&&a(q),e&&a(j),b(w),e&&a(T),b(F,e),e&&a(fe),b(ge,e),e&&a(Pa),e&&a(os),e&&a(Ia),e&&a(rs),e&&a(Ta),e&&a(ee),e&&a(qa),b(se,e),e&&a(Aa),e&&a(is),e&&a(Sa),b(be,e),e&&a(Da),e&&a(ps),e&&a(Fa),b(ve,e),e&&a(Ca),e&&a(W),b(je),e&&a(La),e&&a(ms),e&&a(za),b(ye,e),e&&a(Oa),e&&a(C),e&&a(Na),b(we,e),e&&a(Ba),e&&a(cs),e&&a(Ha),b(xe,e),e&&a(Ma),e&&a(L),e&&a(Ua),e&&a(O),e&&a(Ya),b(ke,e),e&&a(Ga),e&&a(V),b(Ee),e&&a(Ja),e&&a(N),e&&a(Ra),b(Pe,e),e&&a(Wa),e&&a(B),e&&a(Va),b(qe,e),e&&a(Ka),e&&a(E),e&&a(Qa),b(Ae,e),e&&a(Xa),e&&a(H),e&&a(Za),b(De,e),e&&a(et),e&&a(K),b(Fe),e&&a(st),e&&a(S),e&&a(at),b(Oe,e),e&&a(tt),e&&a(M),e&&a(lt),b(He,e),e&&a(nt),e&&a(ne),e&&a(ot),e&&a(Q),b(Me),e&&a(rt),b(re,e),e&&a(it),e&&a(ie),e&&a(pt),b(Ue,e),e&&a(mt),e&&a(gs),e&&a(ct),e&&a(U),e&&a(ht),b(Ge,e),e&&a(ut),e&&a(pe),e&&a(ft),b(Je,e),e&&a(gt),e&&a(Z),b(Re),e&&a(dt),e&&a(ys),e&&a(_t),e&&a($s),e&&a(bt),b(We,e),e&&a(vt),e&&a(Ve),e&&a(jt),e&&a(Y),e&&a(yt),b(Ke,e),e&&a($t),e&&a(G),e&&a(wt),b(Qe,e),e&&a(xt),e&&a(ce),e&&a(kt),b(Xe,e),e&&a(Et),e&&a(ks),e&&a(Pt),b(Ze,e),e&&a(It),e&&a(he),e&&a(Tt),b(ss,e),e&&a(qt),e&&a(as)}}}const pi={local:"semantic-segmentation",sections:[{local:"load-sceneparse150-dataset",title:"Load SceneParse150 dataset"},{local:"preprocess",title:"Preprocess"},{local:"evaluate",title:"Evaluate"},{local:"train",title:"Train"},{local:"inference",title:"Inference"}],title:"Semantic segmentation"};function mi(ns){return ti(()=>{new URLSearchParams(window.location.search).get("fw")}),[]}class _i extends Zr{constructor(v){super();ei(this,v,mi,ii,si,{})}}export{_i as default,pi as metadata};
