import{s as xa,o as Ga,n as ps}from"../chunks/scheduler.9bc65507.js";import{S as Xa,i as Ra,g as M,s as i,u as f,A as Ya,h as u,f as a,c,j as H,v as j,y as T,k as F,o as N,a as l,w as y,d as w,t as J,x as b,m as Va,n as Fa}from"../chunks/index.78c82d43.js";import{T as oa}from"../chunks/Tip.87d55b76.js";import{Y as Na}from"../chunks/Youtube.b19762b6.js";import{I as ne}from"../chunks/IconCopyLink.bedaa44d.js";import{C as X}from"../chunks/CodeBlock.73e038be.js";import{D as Aa}from"../chunks/DocNotebookDropdown.31840a23.js";import{F as Js,M as bs}from"../chunks/Markdown.1b9b4e1c.js";function Ha(k){let t,m,e='<a href="../model_doc/beit">BEiT</a>, <a href="../model_doc/data2vec-vision">Data2VecVision</a>, <a href="../model_doc/dpt">DPT</a>, <a href="../model_doc/mobilenet_v2">MobileNetV2</a>, <a href="../model_doc/mobilevit">MobileViT</a>, <a href="../model_doc/mobilevitv2">MobileViTV2</a>, <a href="../model_doc/segformer">SegFormer</a>, <a href="../model_doc/upernet">UPerNet</a>';return{c(){t=Va(`The task illustrated in this tutorial is supported by the following model architectures:

`),m=M("p"),m.innerHTML=e},l(o){t=Fa(o,`The task illustrated in this tutorial is supported by the following model architectures:

`),m=u(o,"P",{"data-svelte-h":!0}),T(m)!=="svelte-19l83ao"&&(m.innerHTML=e)},m(o,d){l(o,t,d),l(o,m,d)},p:ps,d(o){o&&(a(t),a(m))}}}function za(k){let t,m='It is common to apply some data augmentations to an image dataset to make a model more robust against overfitting. In this guide, you’ll use the <a href="https://pytorch.org/vision/stable/generated/torchvision.transforms.ColorJitter.html" rel="nofollow"><code>ColorJitter</code></a> function from <a href="https://pytorch.org/vision/stable/index.html" rel="nofollow">torchvision</a> to randomly change the color properties of an image, but you can also use any image library you like.',e,o,d,U,V="Now create two preprocessing functions to prepare the images and annotations for the model. These functions convert the images into <code>pixel_values</code> and annotations to <code>labels</code>. For the training set, <code>jitter</code> is applied before providing the images to the image processor. For the test set, the image processor crops and normalizes the <code>images</code>, and only crops the <code>labels</code> because no data augmentation is applied during testing.",W,C,R,v,Y='To apply the <code>jitter</code> over the entire dataset, use the 🤗 Datasets <a href="https://huggingface.co/docs/datasets/v2.14.5/en/package_reference/main_classes#datasets.Dataset.set_transform" rel="nofollow">set_transform</a> function. The transform is applied on the fly which is faster and consumes less disk space:',B,I,G;return o=new X({props:{code:"ZnJvbSUyMHRvcmNodmlzaW9uLnRyYW5zZm9ybXMlMjBpbXBvcnQlMjBDb2xvckppdHRlciUwQSUwQWppdHRlciUyMCUzRCUyMENvbG9ySml0dGVyKGJyaWdodG5lc3MlM0QwLjI1JTJDJTIwY29udHJhc3QlM0QwLjI1JTJDJTIwc2F0dXJhdGlvbiUzRDAuMjUlMkMlMjBodWUlM0QwLjEp",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>)`,wrap:!1}}),C=new X({props:{code:"ZGVmJTIwdHJhaW5fdHJhbnNmb3JtcyhleGFtcGxlX2JhdGNoKSUzQSUwQSUyMCUyMCUyMCUyMGltYWdlcyUyMCUzRCUyMCU1QmppdHRlcih4KSUyMGZvciUyMHglMjBpbiUyMGV4YW1wbGVfYmF0Y2glNUIlMjJpbWFnZSUyMiU1RCU1RCUwQSUyMCUyMCUyMCUyMGxhYmVscyUyMCUzRCUyMCU1QnglMjBmb3IlMjB4JTIwaW4lMjBleGFtcGxlX2JhdGNoJTVCJTIyYW5ub3RhdGlvbiUyMiU1RCU1RCUwQSUyMCUyMCUyMCUyMGlucHV0cyUyMCUzRCUyMGltYWdlX3Byb2Nlc3NvcihpbWFnZXMlMkMlMjBsYWJlbHMpJTBBJTIwJTIwJTIwJTIwcmV0dXJuJTIwaW5wdXRzJTBBJTBBJTBBZGVmJTIwdmFsX3RyYW5zZm9ybXMoZXhhbXBsZV9iYXRjaCklM0ElMEElMjAlMjAlMjAlMjBpbWFnZXMlMjAlM0QlMjAlNUJ4JTIwZm9yJTIweCUyMGluJTIwZXhhbXBsZV9iYXRjaCU1QiUyMmltYWdlJTIyJTVEJTVEJTBBJTIwJTIwJTIwJTIwbGFiZWxzJTIwJTNEJTIwJTVCeCUyMGZvciUyMHglMjBpbiUyMGV4YW1wbGVfYmF0Y2glNUIlMjJhbm5vdGF0aW9uJTIyJTVEJTVEJTBBJTIwJTIwJTIwJTIwaW5wdXRzJTIwJTNEJTIwaW1hZ2VfcHJvY2Vzc29yKGltYWdlcyUyQyUyMGxhYmVscyklMEElMjAlMjAlMjAlMjByZXR1cm4lMjBpbnB1dHM=",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 = image_processor(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 = image_processor(images, labels)
<span class="hljs-meta">... </span>    <span class="hljs-keyword">return</span> inputs`,wrap:!1}}),I=new X({props:{code:"dHJhaW5fZHMuc2V0X3RyYW5zZm9ybSh0cmFpbl90cmFuc2Zvcm1zKSUwQXRlc3RfZHMuc2V0X3RyYW5zZm9ybSh2YWxfdHJhbnNmb3Jtcyk=",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)`,wrap:!1}}),{c(){t=M("p"),t.innerHTML=m,e=i(),f(o.$$.fragment),d=i(),U=M("p"),U.innerHTML=V,W=i(),f(C.$$.fragment),R=i(),v=M("p"),v.innerHTML=Y,B=i(),f(I.$$.fragment)},l(r){t=u(r,"P",{"data-svelte-h":!0}),T(t)!=="svelte-43dxhy"&&(t.innerHTML=m),e=c(r),j(o.$$.fragment,r),d=c(r),U=u(r,"P",{"data-svelte-h":!0}),T(U)!=="svelte-qerdt3"&&(U.innerHTML=V),W=c(r),j(C.$$.fragment,r),R=c(r),v=u(r,"P",{"data-svelte-h":!0}),T(v)!=="svelte-1i0lv5j"&&(v.innerHTML=Y),B=c(r),j(I.$$.fragment,r)},m(r,$){l(r,t,$),l(r,e,$),y(o,r,$),l(r,d,$),l(r,U,$),l(r,W,$),y(C,r,$),l(r,R,$),l(r,v,$),l(r,B,$),y(I,r,$),G=!0},p:ps,i(r){G||(w(o.$$.fragment,r),w(C.$$.fragment,r),w(I.$$.fragment,r),G=!0)},o(r){J(o.$$.fragment,r),J(C.$$.fragment,r),J(I.$$.fragment,r),G=!1},d(r){r&&(a(t),a(e),a(d),a(U),a(W),a(R),a(v),a(B)),b(o,r),b(C,r),b(I,r)}}}function Ea(k){let t,m;return t=new bs({props:{$$slots:{default:[za]},$$scope:{ctx:k}}}),{c(){f(t.$$.fragment)},l(e){j(t.$$.fragment,e)},m(e,o){y(t,e,o),m=!0},p(e,o){const d={};o&2&&(d.$$scope={dirty:o,ctx:e}),t.$set(d)},i(e){m||(w(t.$$.fragment,e),m=!0)},o(e){J(t.$$.fragment,e),m=!1},d(e){b(t,e)}}}function Qa(k){let t,m=`It is common to apply some data augmentations to an image dataset to make a model more robust against overfitting.
In this guide, you’ll use <a href="https://www.tensorflow.org/api_docs/python/tf/image" rel="nofollow"><code>tf.image</code></a> to randomly change the color properties of an image, but you can also use any image
library you like.
Define two separate transformation functions:`,e,o,d="<li>training data transformations that include image augmentation</li> <li>validation data transformations that only transpose the images, since computer vision models in 🤗 Transformers expect channels-first layout</li>",U,V,W,C,R=`Next, create two preprocessing functions to prepare batches of images and annotations for the model. These functions apply
the image transformations and use the earlier loaded <code>image_processor</code> to convert the images into <code>pixel_values</code> and
annotations to <code>labels</code>. <code>ImageProcessor</code> also takes care of resizing and normalizing the images.`,v,Y,B,I,G=`To apply the preprocessing transformations over the entire dataset, use the 🤗 Datasets <a href="https://huggingface.co/docs/datasets/v2.14.5/en/package_reference/main_classes#datasets.Dataset.set_transform" rel="nofollow">set_transform</a> function.
The transform is applied on the fly which is faster and consumes less disk space:`,r,$,A;return V=new X({props:{code:"aW1wb3J0JTIwdGVuc29yZmxvdyUyMGFzJTIwdGYlMEElMEElMEFkZWYlMjBhdWdfdHJhbnNmb3JtcyhpbWFnZSklM0ElMEElMjAlMjAlMjAlMjBpbWFnZSUyMCUzRCUyMHRmLmtlcmFzLnV0aWxzLmltZ190b19hcnJheShpbWFnZSklMEElMjAlMjAlMjAlMjBpbWFnZSUyMCUzRCUyMHRmLmltYWdlLnJhbmRvbV9icmlnaHRuZXNzKGltYWdlJTJDJTIwMC4yNSklMEElMjAlMjAlMjAlMjBpbWFnZSUyMCUzRCUyMHRmLmltYWdlLnJhbmRvbV9jb250cmFzdChpbWFnZSUyQyUyMDAuNSUyQyUyMDIuMCklMEElMjAlMjAlMjAlMjBpbWFnZSUyMCUzRCUyMHRmLmltYWdlLnJhbmRvbV9zYXR1cmF0aW9uKGltYWdlJTJDJTIwMC43NSUyQyUyMDEuMjUpJTBBJTIwJTIwJTIwJTIwaW1hZ2UlMjAlM0QlMjB0Zi5pbWFnZS5yYW5kb21faHVlKGltYWdlJTJDJTIwMC4xKSUwQSUyMCUyMCUyMCUyMGltYWdlJTIwJTNEJTIwdGYudHJhbnNwb3NlKGltYWdlJTJDJTIwKDIlMkMlMjAwJTJDJTIwMSkpJTBBJTIwJTIwJTIwJTIwcmV0dXJuJTIwaW1hZ2UlMEElMEElMEFkZWYlMjB0cmFuc2Zvcm1zKGltYWdlKSUzQSUwQSUyMCUyMCUyMCUyMGltYWdlJTIwJTNEJTIwdGYua2VyYXMudXRpbHMuaW1nX3RvX2FycmF5KGltYWdlKSUwQSUyMCUyMCUyMCUyMGltYWdlJTIwJTNEJTIwdGYudHJhbnNwb3NlKGltYWdlJTJDJTIwKDIlMkMlMjAwJTJDJTIwMSkpJTBBJTIwJTIwJTIwJTIwcmV0dXJuJTIwaW1hZ2U=",highlighted:`<span class="hljs-meta">&gt;&gt;&gt; </span><span class="hljs-keyword">import</span> tensorflow <span class="hljs-keyword">as</span> tf


<span class="hljs-meta">&gt;&gt;&gt; </span><span class="hljs-keyword">def</span> <span class="hljs-title function_">aug_transforms</span>(<span class="hljs-params">image</span>):
<span class="hljs-meta">... </span>    image = tf.keras.utils.img_to_array(image)
<span class="hljs-meta">... </span>    image = tf.image.random_brightness(image, <span class="hljs-number">0.25</span>)
<span class="hljs-meta">... </span>    image = tf.image.random_contrast(image, <span class="hljs-number">0.5</span>, <span class="hljs-number">2.0</span>)
<span class="hljs-meta">... </span>    image = tf.image.random_saturation(image, <span class="hljs-number">0.75</span>, <span class="hljs-number">1.25</span>)
<span class="hljs-meta">... </span>    image = tf.image.random_hue(image, <span class="hljs-number">0.1</span>)
<span class="hljs-meta">... </span>    image = tf.transpose(image, (<span class="hljs-number">2</span>, <span class="hljs-number">0</span>, <span class="hljs-number">1</span>))
<span class="hljs-meta">... </span>    <span class="hljs-keyword">return</span> image


<span class="hljs-meta">&gt;&gt;&gt; </span><span class="hljs-keyword">def</span> <span class="hljs-title function_">transforms</span>(<span class="hljs-params">image</span>):
<span class="hljs-meta">... </span>    image = tf.keras.utils.img_to_array(image)
<span class="hljs-meta">... </span>    image = tf.transpose(image, (<span class="hljs-number">2</span>, <span class="hljs-number">0</span>, <span class="hljs-number">1</span>))
<span class="hljs-meta">... </span>    <span class="hljs-keyword">return</span> image`,wrap:!1}}),Y=new X({props:{code:"ZGVmJTIwdHJhaW5fdHJhbnNmb3JtcyhleGFtcGxlX2JhdGNoKSUzQSUwQSUyMCUyMCUyMCUyMGltYWdlcyUyMCUzRCUyMCU1QmF1Z190cmFuc2Zvcm1zKHguY29udmVydCglMjJSR0IlMjIpKSUyMGZvciUyMHglMjBpbiUyMGV4YW1wbGVfYmF0Y2glNUIlMjJpbWFnZSUyMiU1RCU1RCUwQSUyMCUyMCUyMCUyMGxhYmVscyUyMCUzRCUyMCU1QnglMjBmb3IlMjB4JTIwaW4lMjBleGFtcGxlX2JhdGNoJTVCJTIyYW5ub3RhdGlvbiUyMiU1RCU1RCUwQSUyMCUyMCUyMCUyMGlucHV0cyUyMCUzRCUyMGltYWdlX3Byb2Nlc3NvcihpbWFnZXMlMkMlMjBsYWJlbHMpJTBBJTIwJTIwJTIwJTIwcmV0dXJuJTIwaW5wdXRzJTBBJTBBJTBBZGVmJTIwdmFsX3RyYW5zZm9ybXMoZXhhbXBsZV9iYXRjaCklM0ElMEElMjAlMjAlMjAlMjBpbWFnZXMlMjAlM0QlMjAlNUJ0cmFuc2Zvcm1zKHguY29udmVydCglMjJSR0IlMjIpKSUyMGZvciUyMHglMjBpbiUyMGV4YW1wbGVfYmF0Y2glNUIlMjJpbWFnZSUyMiU1RCU1RCUwQSUyMCUyMCUyMCUyMGxhYmVscyUyMCUzRCUyMCU1QnglMjBmb3IlMjB4JTIwaW4lMjBleGFtcGxlX2JhdGNoJTVCJTIyYW5ub3RhdGlvbiUyMiU1RCU1RCUwQSUyMCUyMCUyMCUyMGlucHV0cyUyMCUzRCUyMGltYWdlX3Byb2Nlc3NvcihpbWFnZXMlMkMlMjBsYWJlbHMpJTBBJTIwJTIwJTIwJTIwcmV0dXJuJTIwaW5wdXRz",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 = [aug_transforms(x.convert(<span class="hljs-string">&quot;RGB&quot;</span>)) <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 = image_processor(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 = [transforms(x.convert(<span class="hljs-string">&quot;RGB&quot;</span>)) <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 = image_processor(images, labels)
<span class="hljs-meta">... </span>    <span class="hljs-keyword">return</span> inputs`,wrap:!1}}),$=new X({props:{code:"dHJhaW5fZHMuc2V0X3RyYW5zZm9ybSh0cmFpbl90cmFuc2Zvcm1zKSUwQXRlc3RfZHMuc2V0X3RyYW5zZm9ybSh2YWxfdHJhbnNmb3Jtcyk=",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)`,wrap:!1}}),{c(){t=M("p"),t.innerHTML=m,e=i(),o=M("ul"),o.innerHTML=d,U=i(),f(V.$$.fragment),W=i(),C=M("p"),C.innerHTML=R,v=i(),f(Y.$$.fragment),B=i(),I=M("p"),I.innerHTML=G,r=i(),f($.$$.fragment)},l(g){t=u(g,"P",{"data-svelte-h":!0}),T(t)!=="svelte-1rj6vla"&&(t.innerHTML=m),e=c(g),o=u(g,"UL",{"data-svelte-h":!0}),T(o)!=="svelte-lmmfid"&&(o.innerHTML=d),U=c(g),j(V.$$.fragment,g),W=c(g),C=u(g,"P",{"data-svelte-h":!0}),T(C)!=="svelte-hpi41l"&&(C.innerHTML=R),v=c(g),j(Y.$$.fragment,g),B=c(g),I=u(g,"P",{"data-svelte-h":!0}),T(I)!=="svelte-1if23t4"&&(I.innerHTML=G),r=c(g),j($.$$.fragment,g)},m(g,x){l(g,t,x),l(g,e,x),l(g,o,x),l(g,U,x),y(V,g,x),l(g,W,x),l(g,C,x),l(g,v,x),y(Y,g,x),l(g,B,x),l(g,I,x),l(g,r,x),y($,g,x),A=!0},p:ps,i(g){A||(w(V.$$.fragment,g),w(Y.$$.fragment,g),w($.$$.fragment,g),A=!0)},o(g){J(V.$$.fragment,g),J(Y.$$.fragment,g),J($.$$.fragment,g),A=!1},d(g){g&&(a(t),a(e),a(o),a(U),a(W),a(C),a(v),a(B),a(I),a(r)),b(V,g),b(Y,g),b($,g)}}}function Sa(k){let t,m;return t=new bs({props:{$$slots:{default:[Qa]},$$scope:{ctx:k}}}),{c(){f(t.$$.fragment)},l(e){j(t.$$.fragment,e)},m(e,o){y(t,e,o),m=!0},p(e,o){const d={};o&2&&(d.$$scope={dirty:o,ctx:e}),t.$set(d)},i(e){m||(w(t.$$.fragment,e),m=!0)},o(e){J(t.$$.fragment,e),m=!1},d(e){b(t,e)}}}function La(k){let t,m;return t=new X({props:{code:"aW1wb3J0JTIwbnVtcHklMjBhcyUyMG5wJTBBaW1wb3J0JTIwdG9yY2glMEFmcm9tJTIwdG9yY2glMjBpbXBvcnQlMjBubiUwQSUwQWRlZiUyMGNvbXB1dGVfbWV0cmljcyhldmFsX3ByZWQpJTNBJTBBJTIwJTIwJTIwJTIwd2l0aCUyMHRvcmNoLm5vX2dyYWQoKSUzQSUwQSUyMCUyMCUyMCUyMCUyMCUyMCUyMCUyMGxvZ2l0cyUyQyUyMGxhYmVscyUyMCUzRCUyMGV2YWxfcHJlZCUwQSUyMCUyMCUyMCUyMCUyMCUyMCUyMCUyMGxvZ2l0c190ZW5zb3IlMjAlM0QlMjB0b3JjaC5mcm9tX251bXB5KGxvZ2l0cyklMEElMjAlMjAlMjAlMjAlMjAlMjAlMjAlMjBsb2dpdHNfdGVuc29yJTIwJTNEJTIwbm4uZnVuY3Rpb25hbC5pbnRlcnBvbGF0ZSglMEElMjAlMjAlMjAlMjAlMjAlMjAlMjAlMjAlMjAlMjAlMjAlMjBsb2dpdHNfdGVuc29yJTJDJTBBJTIwJTIwJTIwJTIwJTIwJTIwJTIwJTIwJTIwJTIwJTIwJTIwc2l6ZSUzRGxhYmVscy5zaGFwZSU1Qi0yJTNBJTVEJTJDJTBBJTIwJTIwJTIwJTIwJTIwJTIwJTIwJTIwJTIwJTIwJTIwJTIwbW9kZSUzRCUyMmJpbGluZWFyJTIyJTJDJTBBJTIwJTIwJTIwJTIwJTIwJTIwJTIwJTIwJTIwJTIwJTIwJTIwYWxpZ25fY29ybmVycyUzREZhbHNlJTJDJTBBJTIwJTIwJTIwJTIwJTIwJTIwJTIwJTIwKS5hcmdtYXgoZGltJTNEMSklMEElMEElMjAlMjAlMjAlMjAlMjAlMjAlMjAlMjBwcmVkX2xhYmVscyUyMCUzRCUyMGxvZ2l0c190ZW5zb3IuZGV0YWNoKCkuY3B1KCkubnVtcHkoKSUwQSUyMCUyMCUyMCUyMCUyMCUyMCUyMCUyMG1ldHJpY3MlMjAlM0QlMjBtZXRyaWMuY29tcHV0ZSglMEElMjAlMjAlMjAlMjAlMjAlMjAlMjAlMjAlMjAlMjAlMjAlMjBwcmVkaWN0aW9ucyUzRHByZWRfbGFiZWxzJTJDJTBBJTIwJTIwJTIwJTIwJTIwJTIwJTIwJTIwJTIwJTIwJTIwJTIwcmVmZXJlbmNlcyUzRGxhYmVscyUyQyUwQSUyMCUyMCUyMCUyMCUyMCUyMCUyMCUyMCUyMCUyMCUyMCUyMG51bV9sYWJlbHMlM0RudW1fbGFiZWxzJTJDJTBBJTIwJTIwJTIwJTIwJTIwJTIwJTIwJTIwJTIwJTIwJTIwJTIwaWdub3JlX2luZGV4JTNEMjU1JTJDJTBBJTIwJTIwJTIwJTIwJTIwJTIwJTIwJTIwJTIwJTIwJTIwJTIwcmVkdWNlX2xhYmVscyUzREZhbHNlJTJDJTBBJTIwJTIwJTIwJTIwJTIwJTIwJTIwJTIwKSUwQSUyMCUyMCUyMCUyMCUyMCUyMCUyMCUyMGZvciUyMGtleSUyQyUyMHZhbHVlJTIwaW4lMjBtZXRyaWNzLml0ZW1zKCklM0ElMEElMjAlMjAlMjAlMjAlMjAlMjAlMjAlMjAlMjAlMjAlMjAlMjBpZiUyMHR5cGUodmFsdWUpJTIwaXMlMjBucC5uZGFycmF5JTNBJTBBJTIwJTIwJTIwJTIwJTIwJTIwJTIwJTIwJTIwJTIwJTIwJTIwJTIwJTIwJTIwJTIwbWV0cmljcyU1QmtleSU1RCUyMCUzRCUyMHZhbHVlLnRvbGlzdCgpJTBBJTIwJTIwJTIwJTIwJTIwJTIwJTIwJTIwcmV0dXJuJTIwbWV0cmljcw==",highlighted:`<span class="hljs-meta">&gt;&gt;&gt; </span><span class="hljs-keyword">import</span> numpy <span class="hljs-keyword">as</span> np
<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> torch <span class="hljs-keyword">import</span> nn

<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`,wrap:!1}}),{c(){f(t.$$.fragment)},l(e){j(t.$$.fragment,e)},m(e,o){y(t,e,o),m=!0},p:ps,i(e){m||(w(t.$$.fragment,e),m=!0)},o(e){J(t.$$.fragment,e),m=!1},d(e){b(t,e)}}}function Da(k){let t,m;return t=new bs({props:{$$slots:{default:[La]},$$scope:{ctx:k}}}),{c(){f(t.$$.fragment)},l(e){j(t.$$.fragment,e)},m(e,o){y(t,e,o),m=!0},p(e,o){const d={};o&2&&(d.$$scope={dirty:o,ctx:e}),t.$set(d)},i(e){m||(w(t.$$.fragment,e),m=!0)},o(e){J(t.$$.fragment,e),m=!1},d(e){b(t,e)}}}function qa(k){let t,m;return t=new X({props:{code:"ZGVmJTIwY29tcHV0ZV9tZXRyaWNzKGV2YWxfcHJlZCklM0ElMEElMjAlMjAlMjAlMjBsb2dpdHMlMkMlMjBsYWJlbHMlMjAlM0QlMjBldmFsX3ByZWQlMEElMjAlMjAlMjAlMjBsb2dpdHMlMjAlM0QlMjB0Zi50cmFuc3Bvc2UobG9naXRzJTJDJTIwcGVybSUzRCU1QjAlMkMlMjAyJTJDJTIwMyUyQyUyMDElNUQpJTBBJTIwJTIwJTIwJTIwbG9naXRzX3Jlc2l6ZWQlMjAlM0QlMjB0Zi5pbWFnZS5yZXNpemUoJTBBJTIwJTIwJTIwJTIwJTIwJTIwJTIwJTIwbG9naXRzJTJDJTBBJTIwJTIwJTIwJTIwJTIwJTIwJTIwJTIwc2l6ZSUzRHRmLnNoYXBlKGxhYmVscyklNUIxJTNBJTVEJTJDJTBBJTIwJTIwJTIwJTIwJTIwJTIwJTIwJTIwbWV0aG9kJTNEJTIyYmlsaW5lYXIlMjIlMkMlMEElMjAlMjAlMjAlMjApJTBBJTBBJTIwJTIwJTIwJTIwcHJlZF9sYWJlbHMlMjAlM0QlMjB0Zi5hcmdtYXgobG9naXRzX3Jlc2l6ZWQlMkMlMjBheGlzJTNELTEpJTBBJTIwJTIwJTIwJTIwbWV0cmljcyUyMCUzRCUyMG1ldHJpYy5jb21wdXRlKCUwQSUyMCUyMCUyMCUyMCUyMCUyMCUyMCUyMHByZWRpY3Rpb25zJTNEcHJlZF9sYWJlbHMlMkMlMEElMjAlMjAlMjAlMjAlMjAlMjAlMjAlMjByZWZlcmVuY2VzJTNEbGFiZWxzJTJDJTBBJTIwJTIwJTIwJTIwJTIwJTIwJTIwJTIwbnVtX2xhYmVscyUzRG51bV9sYWJlbHMlMkMlMEElMjAlMjAlMjAlMjAlMjAlMjAlMjAlMjBpZ25vcmVfaW5kZXglM0QtMSUyQyUwQSUyMCUyMCUyMCUyMCUyMCUyMCUyMCUyMHJlZHVjZV9sYWJlbHMlM0RpbWFnZV9wcm9jZXNzb3IuZG9fcmVkdWNlX2xhYmVscyUyQyUwQSUyMCUyMCUyMCUyMCklMEElMEElMjAlMjAlMjAlMjBwZXJfY2F0ZWdvcnlfYWNjdXJhY3klMjAlM0QlMjBtZXRyaWNzLnBvcCglMjJwZXJfY2F0ZWdvcnlfYWNjdXJhY3klMjIpLnRvbGlzdCgpJTBBJTIwJTIwJTIwJTIwcGVyX2NhdGVnb3J5X2lvdSUyMCUzRCUyMG1ldHJpY3MucG9wKCUyMnBlcl9jYXRlZ29yeV9pb3UlMjIpLnRvbGlzdCgpJTBBJTBBJTIwJTIwJTIwJTIwbWV0cmljcy51cGRhdGUoJTdCZiUyMmFjY3VyYWN5XyU3QmlkMmxhYmVsJTVCaSU1RCU3RCUyMiUzQSUyMHYlMjBmb3IlMjBpJTJDJTIwdiUyMGluJTIwZW51bWVyYXRlKHBlcl9jYXRlZ29yeV9hY2N1cmFjeSklN0QpJTBBJTIwJTIwJTIwJTIwbWV0cmljcy51cGRhdGUoJTdCZiUyMmlvdV8lN0JpZDJsYWJlbCU1QmklNUQlN0QlMjIlM0ElMjB2JTIwZm9yJTIwaSUyQyUyMHYlMjBpbiUyMGVudW1lcmF0ZShwZXJfY2F0ZWdvcnlfaW91KSU3RCklMEElMjAlMjAlMjAlMjByZXR1cm4lMjAlN0IlMjJ2YWxfJTIyJTIwJTJCJTIwayUzQSUyMHYlMjBmb3IlMjBrJTJDJTIwdiUyMGluJTIwbWV0cmljcy5pdGVtcygpJTdE",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>    logits, labels = eval_pred
<span class="hljs-meta">... </span>    logits = tf.transpose(logits, perm=[<span class="hljs-number">0</span>, <span class="hljs-number">2</span>, <span class="hljs-number">3</span>, <span class="hljs-number">1</span>])
<span class="hljs-meta">... </span>    logits_resized = tf.image.resize(
<span class="hljs-meta">... </span>        logits,
<span class="hljs-meta">... </span>        size=tf.shape(labels)[<span class="hljs-number">1</span>:],
<span class="hljs-meta">... </span>        method=<span class="hljs-string">&quot;bilinear&quot;</span>,
<span class="hljs-meta">... </span>    )

<span class="hljs-meta">... </span>    pred_labels = tf.argmax(logits_resized, axis=-<span class="hljs-number">1</span>)
<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">1</span>,
<span class="hljs-meta">... </span>        reduce_labels=image_processor.do_reduce_labels,
<span class="hljs-meta">... </span>    )

<span class="hljs-meta">... </span>    per_category_accuracy = metrics.pop(<span class="hljs-string">&quot;per_category_accuracy&quot;</span>).tolist()
<span class="hljs-meta">... </span>    per_category_iou = metrics.pop(<span class="hljs-string">&quot;per_category_iou&quot;</span>).tolist()

<span class="hljs-meta">... </span>    metrics.update({<span class="hljs-string">f&quot;accuracy_<span class="hljs-subst">{id2label[i]}</span>&quot;</span>: v <span class="hljs-keyword">for</span> i, v <span class="hljs-keyword">in</span> <span class="hljs-built_in">enumerate</span>(per_category_accuracy)})
<span class="hljs-meta">... </span>    metrics.update({<span class="hljs-string">f&quot;iou_<span class="hljs-subst">{id2label[i]}</span>&quot;</span>: v <span class="hljs-keyword">for</span> i, v <span class="hljs-keyword">in</span> <span class="hljs-built_in">enumerate</span>(per_category_iou)})
<span class="hljs-meta">... </span>    <span class="hljs-keyword">return</span> {<span class="hljs-string">&quot;val_&quot;</span> + k: v <span class="hljs-keyword">for</span> k, v <span class="hljs-keyword">in</span> metrics.items()}`,wrap:!1}}),{c(){f(t.$$.fragment)},l(e){j(t.$$.fragment,e)},m(e,o){y(t,e,o),m=!0},p:ps,i(e){m||(w(t.$$.fragment,e),m=!0)},o(e){J(t.$$.fragment,e),m=!1},d(e){b(t,e)}}}function Pa(k){let t,m;return t=new bs({props:{$$slots:{default:[qa]},$$scope:{ctx:k}}}),{c(){f(t.$$.fragment)},l(e){j(t.$$.fragment,e)},m(e,o){y(t,e,o),m=!0},p(e,o){const d={};o&2&&(d.$$scope={dirty:o,ctx:e}),t.$set(d)},i(e){m||(w(t.$$.fragment,e),m=!0)},o(e){J(t.$$.fragment,e),m=!1},d(e){b(t,e)}}}function Ka(k){let t,m='If you aren’t familiar with finetuning a model with the <a href="/docs/transformers/v4.34.0/en/main_classes/trainer#transformers.Trainer">Trainer</a>, take a look at the basic tutorial <a href="../training#finetune-with-trainer">here</a>!';return{c(){t=M("p"),t.innerHTML=m},l(e){t=u(e,"P",{"data-svelte-h":!0}),T(t)!=="svelte-1i97uds"&&(t.innerHTML=m)},m(e,o){l(e,t,o)},p:ps,d(e){e&&a(t)}}}function Oa(k){let t,m,e,o='You’re ready to start training your model now! Load SegFormer with <a href="/docs/transformers/v4.34.0/en/model_doc/auto#transformers.AutoModelForSemanticSegmentation">AutoModelForSemanticSegmentation</a>, and pass the model the mapping between label ids and label classes:',d,U,V,W,C="At this point, only three steps remain:",R,v,Y='<li>Define your training hyperparameters in <a href="/docs/transformers/v4.34.0/en/main_classes/trainer#transformers.TrainingArguments">TrainingArguments</a>. It is important you don’t remove unused columns because this’ll drop the <code>image</code> column. Without the <code>image</code> column, you can’t create <code>pixel_values</code>. Set <code>remove_unused_columns=False</code> to prevent this behavior! The only other required parameter is <code>output_dir</code> which specifies where to save your model. You’ll push this model to the Hub by setting <code>push_to_hub=True</code> (you need to be signed in to Hugging Face to upload your model). At the end of each epoch, the <a href="/docs/transformers/v4.34.0/en/main_classes/trainer#transformers.Trainer">Trainer</a> will evaluate the IoU metric and save the training checkpoint.</li> <li>Pass the training arguments to <a href="/docs/transformers/v4.34.0/en/main_classes/trainer#transformers.Trainer">Trainer</a> along with the model, dataset, tokenizer, data collator, and <code>compute_metrics</code> function.</li> <li>Call <a href="/docs/transformers/v4.34.0/en/main_classes/trainer#transformers.Trainer.train">train()</a> to finetune your model.</li>',B,I,G,r,$='Once training is completed, share your model to the Hub with the <a href="/docs/transformers/v4.34.0/en/main_classes/trainer#transformers.Trainer.push_to_hub">push_to_hub()</a> method so everyone can use your model:',A,g,x;return t=new oa({props:{$$slots:{default:[Ka]},$$scope:{ctx:k}}}),U=new X({props:{code:"ZnJvbSUyMHRyYW5zZm9ybWVycyUyMGltcG9ydCUyMEF1dG9Nb2RlbEZvclNlbWFudGljU2VnbWVudGF0aW9uJTJDJTIwVHJhaW5pbmdBcmd1bWVudHMlMkMlMjBUcmFpbmVyJTBBJTBBbW9kZWwlMjAlM0QlMjBBdXRvTW9kZWxGb3JTZW1hbnRpY1NlZ21lbnRhdGlvbi5mcm9tX3ByZXRyYWluZWQoY2hlY2twb2ludCUyQyUyMGlkMmxhYmVsJTNEaWQybGFiZWwlMkMlMjBsYWJlbDJpZCUzRGxhYmVsMmlkKQ==",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>model = AutoModelForSemanticSegmentation.from_pretrained(checkpoint, id2label=id2label, label2id=label2id)`,wrap:!1}}),I=new X({props:{code:"dHJhaW5pbmdfYXJncyUyMCUzRCUyMFRyYWluaW5nQXJndW1lbnRzKCUwQSUyMCUyMCUyMCUyMG91dHB1dF9kaXIlM0QlMjJzZWdmb3JtZXItYjAtc2NlbmUtcGFyc2UtMTUwJTIyJTJDJTBBJTIwJTIwJTIwJTIwbGVhcm5pbmdfcmF0ZSUzRDZlLTUlMkMlMEElMjAlMjAlMjAlMjBudW1fdHJhaW5fZXBvY2hzJTNENTAlMkMlMEElMjAlMjAlMjAlMjBwZXJfZGV2aWNlX3RyYWluX2JhdGNoX3NpemUlM0QyJTJDJTBBJTIwJTIwJTIwJTIwcGVyX2RldmljZV9ldmFsX2JhdGNoX3NpemUlM0QyJTJDJTBBJTIwJTIwJTIwJTIwc2F2ZV90b3RhbF9saW1pdCUzRDMlMkMlMEElMjAlMjAlMjAlMjBldmFsdWF0aW9uX3N0cmF0ZWd5JTNEJTIyc3RlcHMlMjIlMkMlMEElMjAlMjAlMjAlMjBzYXZlX3N0cmF0ZWd5JTNEJTIyc3RlcHMlMjIlMkMlMEElMjAlMjAlMjAlMjBzYXZlX3N0ZXBzJTNEMjAlMkMlMEElMjAlMjAlMjAlMjBldmFsX3N0ZXBzJTNEMjAlMkMlMEElMjAlMjAlMjAlMjBsb2dnaW5nX3N0ZXBzJTNEMSUyQyUwQSUyMCUyMCUyMCUyMGV2YWxfYWNjdW11bGF0aW9uX3N0ZXBzJTNENSUyQyUwQSUyMCUyMCUyMCUyMHJlbW92ZV91bnVzZWRfY29sdW1ucyUzREZhbHNlJTJDJTBBJTIwJTIwJTIwJTIwcHVzaF90b19odWIlM0RUcnVlJTJDJTBBKSUwQSUwQXRyYWluZXIlMjAlM0QlMjBUcmFpbmVyKCUwQSUyMCUyMCUyMCUyMG1vZGVsJTNEbW9kZWwlMkMlMEElMjAlMjAlMjAlMjBhcmdzJTNEdHJhaW5pbmdfYXJncyUyQyUwQSUyMCUyMCUyMCUyMHRyYWluX2RhdGFzZXQlM0R0cmFpbl9kcyUyQyUwQSUyMCUyMCUyMCUyMGV2YWxfZGF0YXNldCUzRHRlc3RfZHMlMkMlMEElMjAlMjAlMjAlMjBjb21wdXRlX21ldHJpY3MlM0Rjb21wdXRlX21ldHJpY3MlMkMlMEEpJTBBJTBBdHJhaW5lci50cmFpbigp",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()`,wrap:!1}}),g=new X({props:{code:"dHJhaW5lci5wdXNoX3RvX2h1Yigp",highlighted:'<span class="hljs-meta">&gt;&gt;&gt; </span>trainer.push_to_hub()',wrap:!1}}),{c(){f(t.$$.fragment),m=i(),e=M("p"),e.innerHTML=o,d=i(),f(U.$$.fragment),V=i(),W=M("p"),W.textContent=C,R=i(),v=M("ol"),v.innerHTML=Y,B=i(),f(I.$$.fragment),G=i(),r=M("p"),r.innerHTML=$,A=i(),f(g.$$.fragment)},l(p){j(t.$$.fragment,p),m=c(p),e=u(p,"P",{"data-svelte-h":!0}),T(e)!=="svelte-r9lche"&&(e.innerHTML=o),d=c(p),j(U.$$.fragment,p),V=c(p),W=u(p,"P",{"data-svelte-h":!0}),T(W)!=="svelte-l42k0i"&&(W.textContent=C),R=c(p),v=u(p,"OL",{"data-svelte-h":!0}),T(v)!=="svelte-1fwzkdi"&&(v.innerHTML=Y),B=c(p),j(I.$$.fragment,p),G=c(p),r=u(p,"P",{"data-svelte-h":!0}),T(r)!=="svelte-cv8z08"&&(r.innerHTML=$),A=c(p),j(g.$$.fragment,p)},m(p,_){y(t,p,_),l(p,m,_),l(p,e,_),l(p,d,_),y(U,p,_),l(p,V,_),l(p,W,_),l(p,R,_),l(p,v,_),l(p,B,_),y(I,p,_),l(p,G,_),l(p,r,_),l(p,A,_),y(g,p,_),x=!0},p(p,_){const z={};_&2&&(z.$$scope={dirty:_,ctx:p}),t.$set(z)},i(p){x||(w(t.$$.fragment,p),w(U.$$.fragment,p),w(I.$$.fragment,p),w(g.$$.fragment,p),x=!0)},o(p){J(t.$$.fragment,p),J(U.$$.fragment,p),J(I.$$.fragment,p),J(g.$$.fragment,p),x=!1},d(p){p&&(a(m),a(e),a(d),a(V),a(W),a(R),a(v),a(B),a(G),a(r),a(A)),b(t,p),b(U,p),b(I,p),b(g,p)}}}function st(k){let t,m;return t=new bs({props:{$$slots:{default:[Oa]},$$scope:{ctx:k}}}),{c(){f(t.$$.fragment)},l(e){j(t.$$.fragment,e)},m(e,o){y(t,e,o),m=!0},p(e,o){const d={};o&2&&(d.$$scope={dirty:o,ctx:e}),t.$set(d)},i(e){m||(w(t.$$.fragment,e),m=!0)},o(e){J(t.$$.fragment,e),m=!1},d(e){b(t,e)}}}function et(k){let t,m='If you are unfamiliar with fine-tuning a model with Keras, check out the <a href="./training#train-a-tensorflow-model-with-keras">basic tutorial</a> first!';return{c(){t=M("p"),t.innerHTML=m},l(e){t=u(e,"P",{"data-svelte-h":!0}),T(t)!=="svelte-1egt5s9"&&(t.innerHTML=m)},m(e,o){l(e,t,o)},p:ps,d(e){e&&a(t)}}}function at(k){let t,m,e,o="To fine-tune a model in TensorFlow, follow these steps:",d,U,V="<li>Define the training hyperparameters, and set up an optimizer and a learning rate schedule.</li> <li>Instantiate a pretrained model.</li> <li>Convert a 🤗 Dataset to a <code>tf.data.Dataset</code>.</li> <li>Compile your model.</li> <li>Add callbacks to calculate metrics and upload your model to 🤗 Hub</li> <li>Use the <code>fit()</code> method to run the training.</li>",W,C,R="Start by defining the hyperparameters, optimizer and learning rate schedule:",v,Y,B,I,G=`Then, load SegFormer with <a href="/docs/transformers/v4.34.0/en/model_doc/auto#transformers.TFAutoModelForSemanticSegmentation">TFAutoModelForSemanticSegmentation</a> along with the label mappings, and compile it with the
optimizer. Note that Transformers models all have a default task-relevant loss function, so you don’t need to specify one unless you want to:`,r,$,A,g,x='Convert your datasets to the <code>tf.data.Dataset</code> format using the <a href="https://huggingface.co/docs/datasets/v2.14.5/en/package_reference/main_classes#datasets.Dataset.to_tf_dataset" rel="nofollow">to_tf_dataset</a> and the <a href="/docs/transformers/v4.34.0/en/main_classes/data_collator#transformers.DefaultDataCollator">DefaultDataCollator</a>:',p,_,z,O,Ts=`To compute the accuracy from the predictions and push your model to the 🤗 Hub, use <a href="../main_classes/keras_callbacks">Keras callbacks</a>.
Pass your <code>compute_metrics</code> function to <a href="/docs/transformers/v4.34.0/en/main_classes/keras_callbacks#transformers.KerasMetricCallback">KerasMetricCallback</a>,
and use the <a href="/docs/transformers/v4.34.0/en/main_classes/keras_callbacks#transformers.PushToHubCallback">PushToHubCallback</a> to upload the model:`,E,Q,S,ss,Us=`Finally, you are ready to train your model! Call <code>fit()</code> with your training and validation datasets, the number of epochs,
and your callbacks to fine-tune the model:`,L,D,q,es,$s="Congratulations! You have fine-tuned your model and shared it on the 🤗 Hub. You can now use it for inference!",P;return t=new oa({props:{$$slots:{default:[et]},$$scope:{ctx:k}}}),Y=new X({props:{code:"ZnJvbSUyMHRyYW5zZm9ybWVycyUyMGltcG9ydCUyMGNyZWF0ZV9vcHRpbWl6ZXIlMEElMEFiYXRjaF9zaXplJTIwJTNEJTIwMiUwQW51bV9lcG9jaHMlMjAlM0QlMjA1MCUwQW51bV90cmFpbl9zdGVwcyUyMCUzRCUyMGxlbih0cmFpbl9kcyklMjAqJTIwbnVtX2Vwb2NocyUwQWxlYXJuaW5nX3JhdGUlMjAlM0QlMjA2ZS01JTBBd2VpZ2h0X2RlY2F5X3JhdGUlMjAlM0QlMjAwLjAxJTBBJTBBb3B0aW1pemVyJTJDJTIwbHJfc2NoZWR1bGUlMjAlM0QlMjBjcmVhdGVfb3B0aW1pemVyKCUwQSUyMCUyMCUyMCUyMGluaXRfbHIlM0RsZWFybmluZ19yYXRlJTJDJTBBJTIwJTIwJTIwJTIwbnVtX3RyYWluX3N0ZXBzJTNEbnVtX3RyYWluX3N0ZXBzJTJDJTBBJTIwJTIwJTIwJTIwd2VpZ2h0X2RlY2F5X3JhdGUlM0R3ZWlnaHRfZGVjYXlfcmF0ZSUyQyUwQSUyMCUyMCUyMCUyMG51bV93YXJtdXBfc3RlcHMlM0QwJTJDJTBBKQ==",highlighted:`<span class="hljs-meta">&gt;&gt;&gt; </span><span class="hljs-keyword">from</span> transformers <span class="hljs-keyword">import</span> create_optimizer

<span class="hljs-meta">&gt;&gt;&gt; </span>batch_size = <span class="hljs-number">2</span>
<span class="hljs-meta">&gt;&gt;&gt; </span>num_epochs = <span class="hljs-number">50</span>
<span class="hljs-meta">&gt;&gt;&gt; </span>num_train_steps = <span class="hljs-built_in">len</span>(train_ds) * num_epochs
<span class="hljs-meta">&gt;&gt;&gt; </span>learning_rate = <span class="hljs-number">6e-5</span>
<span class="hljs-meta">&gt;&gt;&gt; </span>weight_decay_rate = <span class="hljs-number">0.01</span>

<span class="hljs-meta">&gt;&gt;&gt; </span>optimizer, lr_schedule = create_optimizer(
<span class="hljs-meta">... </span>    init_lr=learning_rate,
<span class="hljs-meta">... </span>    num_train_steps=num_train_steps,
<span class="hljs-meta">... </span>    weight_decay_rate=weight_decay_rate,
<span class="hljs-meta">... </span>    num_warmup_steps=<span class="hljs-number">0</span>,
<span class="hljs-meta">... </span>)`,wrap:!1}}),$=new X({props:{code:"ZnJvbSUyMHRyYW5zZm9ybWVycyUyMGltcG9ydCUyMFRGQXV0b01vZGVsRm9yU2VtYW50aWNTZWdtZW50YXRpb24lMEElMEFtb2RlbCUyMCUzRCUyMFRGQXV0b01vZGVsRm9yU2VtYW50aWNTZWdtZW50YXRpb24uZnJvbV9wcmV0cmFpbmVkKCUwQSUyMCUyMCUyMCUyMGNoZWNrcG9pbnQlMkMlMEElMjAlMjAlMjAlMjBpZDJsYWJlbCUzRGlkMmxhYmVsJTJDJTBBJTIwJTIwJTIwJTIwbGFiZWwyaWQlM0RsYWJlbDJpZCUyQyUwQSklMEFtb2RlbC5jb21waWxlKG9wdGltaXplciUzRG9wdGltaXplciklMjAlMjAlMjMlMjBObyUyMGxvc3MlMjBhcmd1bWVudCE=",highlighted:`<span class="hljs-meta">&gt;&gt;&gt; </span><span class="hljs-keyword">from</span> transformers <span class="hljs-keyword">import</span> TFAutoModelForSemanticSegmentation

<span class="hljs-meta">&gt;&gt;&gt; </span>model = TFAutoModelForSemanticSegmentation.from_pretrained(
<span class="hljs-meta">... </span>    checkpoint,
<span class="hljs-meta">... </span>    id2label=id2label,
<span class="hljs-meta">... </span>    label2id=label2id,
<span class="hljs-meta">... </span>)
<span class="hljs-meta">&gt;&gt;&gt; </span>model.<span class="hljs-built_in">compile</span>(optimizer=optimizer)  <span class="hljs-comment"># No loss argument!</span>`,wrap:!1}}),_=new X({props:{code:"ZnJvbSUyMHRyYW5zZm9ybWVycyUyMGltcG9ydCUyMERlZmF1bHREYXRhQ29sbGF0b3IlMEElMEFkYXRhX2NvbGxhdG9yJTIwJTNEJTIwRGVmYXVsdERhdGFDb2xsYXRvcihyZXR1cm5fdGVuc29ycyUzRCUyMnRmJTIyKSUwQSUwQXRmX3RyYWluX2RhdGFzZXQlMjAlM0QlMjB0cmFpbl9kcy50b190Zl9kYXRhc2V0KCUwQSUyMCUyMCUyMCUyMGNvbHVtbnMlM0QlNUIlMjJwaXhlbF92YWx1ZXMlMjIlMkMlMjAlMjJsYWJlbCUyMiU1RCUyQyUwQSUyMCUyMCUyMCUyMHNodWZmbGUlM0RUcnVlJTJDJTBBJTIwJTIwJTIwJTIwYmF0Y2hfc2l6ZSUzRGJhdGNoX3NpemUlMkMlMEElMjAlMjAlMjAlMjBjb2xsYXRlX2ZuJTNEZGF0YV9jb2xsYXRvciUyQyUwQSklMEElMEF0Zl9ldmFsX2RhdGFzZXQlMjAlM0QlMjB0ZXN0X2RzLnRvX3RmX2RhdGFzZXQoJTBBJTIwJTIwJTIwJTIwY29sdW1ucyUzRCU1QiUyMnBpeGVsX3ZhbHVlcyUyMiUyQyUyMCUyMmxhYmVsJTIyJTVEJTJDJTBBJTIwJTIwJTIwJTIwc2h1ZmZsZSUzRFRydWUlMkMlMEElMjAlMjAlMjAlMjBiYXRjaF9zaXplJTNEYmF0Y2hfc2l6ZSUyQyUwQSUyMCUyMCUyMCUyMGNvbGxhdGVfZm4lM0RkYXRhX2NvbGxhdG9yJTJDJTBBKQ==",highlighted:`<span class="hljs-meta">&gt;&gt;&gt; </span><span class="hljs-keyword">from</span> transformers <span class="hljs-keyword">import</span> DefaultDataCollator

<span class="hljs-meta">&gt;&gt;&gt; </span>data_collator = DefaultDataCollator(return_tensors=<span class="hljs-string">&quot;tf&quot;</span>)

<span class="hljs-meta">&gt;&gt;&gt; </span>tf_train_dataset = train_ds.to_tf_dataset(
<span class="hljs-meta">... </span>    columns=[<span class="hljs-string">&quot;pixel_values&quot;</span>, <span class="hljs-string">&quot;label&quot;</span>],
<span class="hljs-meta">... </span>    shuffle=<span class="hljs-literal">True</span>,
<span class="hljs-meta">... </span>    batch_size=batch_size,
<span class="hljs-meta">... </span>    collate_fn=data_collator,
<span class="hljs-meta">... </span>)

<span class="hljs-meta">&gt;&gt;&gt; </span>tf_eval_dataset = test_ds.to_tf_dataset(
<span class="hljs-meta">... </span>    columns=[<span class="hljs-string">&quot;pixel_values&quot;</span>, <span class="hljs-string">&quot;label&quot;</span>],
<span class="hljs-meta">... </span>    shuffle=<span class="hljs-literal">True</span>,
<span class="hljs-meta">... </span>    batch_size=batch_size,
<span class="hljs-meta">... </span>    collate_fn=data_collator,
<span class="hljs-meta">... </span>)`,wrap:!1}}),Q=new X({props:{code:"ZnJvbSUyMHRyYW5zZm9ybWVycy5rZXJhc19jYWxsYmFja3MlMjBpbXBvcnQlMjBLZXJhc01ldHJpY0NhbGxiYWNrJTJDJTIwUHVzaFRvSHViQ2FsbGJhY2slMEElMEFtZXRyaWNfY2FsbGJhY2slMjAlM0QlMjBLZXJhc01ldHJpY0NhbGxiYWNrKCUwQSUyMCUyMCUyMCUyMG1ldHJpY19mbiUzRGNvbXB1dGVfbWV0cmljcyUyQyUyMGV2YWxfZGF0YXNldCUzRHRmX2V2YWxfZGF0YXNldCUyQyUyMGJhdGNoX3NpemUlM0RiYXRjaF9zaXplJTJDJTIwbGFiZWxfY29scyUzRCU1QiUyMmxhYmVscyUyMiU1RCUwQSklMEElMEFwdXNoX3RvX2h1Yl9jYWxsYmFjayUyMCUzRCUyMFB1c2hUb0h1YkNhbGxiYWNrKG91dHB1dF9kaXIlM0QlMjJzY2VuZV9zZWdtZW50YXRpb24lMjIlMkMlMjB0b2tlbml6ZXIlM0RpbWFnZV9wcm9jZXNzb3IpJTBBJTBBY2FsbGJhY2tzJTIwJTNEJTIwJTVCbWV0cmljX2NhbGxiYWNrJTJDJTIwcHVzaF90b19odWJfY2FsbGJhY2slNUQ=",highlighted:`<span class="hljs-meta">&gt;&gt;&gt; </span><span class="hljs-keyword">from</span> transformers.keras_callbacks <span class="hljs-keyword">import</span> KerasMetricCallback, PushToHubCallback

<span class="hljs-meta">&gt;&gt;&gt; </span>metric_callback = KerasMetricCallback(
<span class="hljs-meta">... </span>    metric_fn=compute_metrics, eval_dataset=tf_eval_dataset, batch_size=batch_size, label_cols=[<span class="hljs-string">&quot;labels&quot;</span>]
<span class="hljs-meta">... </span>)

<span class="hljs-meta">&gt;&gt;&gt; </span>push_to_hub_callback = PushToHubCallback(output_dir=<span class="hljs-string">&quot;scene_segmentation&quot;</span>, tokenizer=image_processor)

<span class="hljs-meta">&gt;&gt;&gt; </span>callbacks = [metric_callback, push_to_hub_callback]`,wrap:!1}}),D=new X({props:{code:"bW9kZWwuZml0KCUwQSUyMCUyMCUyMCUyMHRmX3RyYWluX2RhdGFzZXQlMkMlMEElMjAlMjAlMjAlMjB2YWxpZGF0aW9uX2RhdGElM0R0Zl9ldmFsX2RhdGFzZXQlMkMlMEElMjAlMjAlMjAlMjBjYWxsYmFja3MlM0RjYWxsYmFja3MlMkMlMEElMjAlMjAlMjAlMjBlcG9jaHMlM0RudW1fZXBvY2hzJTJDJTBBKQ==",highlighted:`<span class="hljs-meta">&gt;&gt;&gt; </span>model.fit(
<span class="hljs-meta">... </span>    tf_train_dataset,
<span class="hljs-meta">... </span>    validation_data=tf_eval_dataset,
<span class="hljs-meta">... </span>    callbacks=callbacks,
<span class="hljs-meta">... </span>    epochs=num_epochs,
<span class="hljs-meta">... </span>)`,wrap:!1}}),{c(){f(t.$$.fragment),m=i(),e=M("p"),e.textContent=o,d=i(),U=M("ol"),U.innerHTML=V,W=i(),C=M("p"),C.textContent=R,v=i(),f(Y.$$.fragment),B=i(),I=M("p"),I.innerHTML=G,r=i(),f($.$$.fragment),A=i(),g=M("p"),g.innerHTML=x,p=i(),f(_.$$.fragment),z=i(),O=M("p"),O.innerHTML=Ts,E=i(),f(Q.$$.fragment),S=i(),ss=M("p"),ss.innerHTML=Us,L=i(),f(D.$$.fragment),q=i(),es=M("p"),es.textContent=$s},l(h){j(t.$$.fragment,h),m=c(h),e=u(h,"P",{"data-svelte-h":!0}),T(e)!=="svelte-s07fxj"&&(e.textContent=o),d=c(h),U=u(h,"OL",{"data-svelte-h":!0}),T(U)!=="svelte-1e3w1hr"&&(U.innerHTML=V),W=c(h),C=u(h,"P",{"data-svelte-h":!0}),T(C)!=="svelte-ccl3wn"&&(C.textContent=R),v=c(h),j(Y.$$.fragment,h),B=c(h),I=u(h,"P",{"data-svelte-h":!0}),T(I)!=="svelte-42cp9c"&&(I.innerHTML=G),r=c(h),j($.$$.fragment,h),A=c(h),g=u(h,"P",{"data-svelte-h":!0}),T(g)!=="svelte-4x4y3j"&&(g.innerHTML=x),p=c(h),j(_.$$.fragment,h),z=c(h),O=u(h,"P",{"data-svelte-h":!0}),T(O)!=="svelte-10i0jcl"&&(O.innerHTML=Ts),E=c(h),j(Q.$$.fragment,h),S=c(h),ss=u(h,"P",{"data-svelte-h":!0}),T(ss)!=="svelte-1occr1z"&&(ss.innerHTML=Us),L=c(h),j(D.$$.fragment,h),q=c(h),es=u(h,"P",{"data-svelte-h":!0}),T(es)!=="svelte-1r99pbn"&&(es.textContent=$s)},m(h,Z){y(t,h,Z),l(h,m,Z),l(h,e,Z),l(h,d,Z),l(h,U,Z),l(h,W,Z),l(h,C,Z),l(h,v,Z),y(Y,h,Z),l(h,B,Z),l(h,I,Z),l(h,r,Z),y($,h,Z),l(h,A,Z),l(h,g,Z),l(h,p,Z),y(_,h,Z),l(h,z,Z),l(h,O,Z),l(h,E,Z),y(Q,h,Z),l(h,S,Z),l(h,ss,Z),l(h,L,Z),y(D,h,Z),l(h,q,Z),l(h,es,Z),P=!0},p(h,Z){const K={};Z&2&&(K.$$scope={dirty:Z,ctx:h}),t.$set(K)},i(h){P||(w(t.$$.fragment,h),w(Y.$$.fragment,h),w($.$$.fragment,h),w(_.$$.fragment,h),w(Q.$$.fragment,h),w(D.$$.fragment,h),P=!0)},o(h){J(t.$$.fragment,h),J(Y.$$.fragment,h),J($.$$.fragment,h),J(_.$$.fragment,h),J(Q.$$.fragment,h),J(D.$$.fragment,h),P=!1},d(h){h&&(a(m),a(e),a(d),a(U),a(W),a(C),a(v),a(B),a(I),a(r),a(A),a(g),a(p),a(z),a(O),a(E),a(S),a(ss),a(L),a(q),a(es)),b(t,h),b(Y,h),b($,h),b(_,h),b(Q,h),b(D,h)}}}function tt(k){let t,m;return t=new bs({props:{$$slots:{default:[at]},$$scope:{ctx:k}}}),{c(){f(t.$$.fragment)},l(e){j(t.$$.fragment,e)},m(e,o){y(t,e,o),m=!0},p(e,o){const d={};o&2&&(d.$$scope={dirty:o,ctx:e}),t.$set(d)},i(e){m||(w(t.$$.fragment,e),m=!0)},o(e){J(t.$$.fragment,e),m=!1},d(e){b(t,e)}}}function lt(k){let t,m='The simplest way to try out your finetuned model for inference is to use it in a <a href="/docs/transformers/v4.34.0/en/main_classes/pipelines#transformers.pipeline">pipeline()</a>. Instantiate a <code>pipeline</code> for image segmentation with your model, and pass your image to it:',e,o,d,U,V="You can also manually replicate the results of the <code>pipeline</code> if you’d like. Process the image with an image processor and place the <code>pixel_values</code> on a GPU:",W,C,R,v,Y="Pass your input to the model and return the <code>logits</code>:",B,I,G,r,$="Next, rescale the logits to the original image size:",A,g,x;return o=new X({props:{code:"ZnJvbSUyMHRyYW5zZm9ybWVycyUyMGltcG9ydCUyMHBpcGVsaW5lJTBBJTBBc2VnbWVudGVyJTIwJTNEJTIwcGlwZWxpbmUoJTIyaW1hZ2Utc2VnbWVudGF0aW9uJTIyJTJDJTIwbW9kZWwlM0QlMjJteV9hd2Vzb21lX3NlZ19tb2RlbCUyMiklMEFzZWdtZW50ZXIoaW1hZ2Up",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;}]`,wrap:!1}}),C=new X({props:{code:"ZGV2aWNlJTIwJTNEJTIwdG9yY2guZGV2aWNlKCUyMmN1ZGElMjIlMjBpZiUyMHRvcmNoLmN1ZGEuaXNfYXZhaWxhYmxlKCklMjBlbHNlJTIwJTIyY3B1JTIyKSUyMCUyMCUyMyUyMHVzZSUyMEdQVSUyMGlmJTIwYXZhaWxhYmxlJTJDJTIwb3RoZXJ3aXNlJTIwdXNlJTIwYSUyMENQVSUwQWVuY29kaW5nJTIwJTNEJTIwaW1hZ2VfcHJvY2Vzc29yKGltYWdlJTJDJTIwcmV0dXJuX3RlbnNvcnMlM0QlMjJwdCUyMiklMEFwaXhlbF92YWx1ZXMlMjAlM0QlMjBlbmNvZGluZy5waXhlbF92YWx1ZXMudG8oZGV2aWNlKQ==",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 = image_processor(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)`,wrap:!1}}),I=new X({props:{code:"b3V0cHV0cyUyMCUzRCUyMG1vZGVsKHBpeGVsX3ZhbHVlcyUzRHBpeGVsX3ZhbHVlcyklMEFsb2dpdHMlMjAlM0QlMjBvdXRwdXRzLmxvZ2l0cy5jcHUoKQ==",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()`,wrap:!1}}),g=new X({props:{code:"dXBzYW1wbGVkX2xvZ2l0cyUyMCUzRCUyMG5uLmZ1bmN0aW9uYWwuaW50ZXJwb2xhdGUoJTBBJTIwJTIwJTIwJTIwbG9naXRzJTJDJTBBJTIwJTIwJTIwJTIwc2l6ZSUzRGltYWdlLnNpemUlNUIlM0ElM0EtMSU1RCUyQyUwQSUyMCUyMCUyMCUyMG1vZGUlM0QlMjJiaWxpbmVhciUyMiUyQyUwQSUyMCUyMCUyMCUyMGFsaWduX2Nvcm5lcnMlM0RGYWxzZSUyQyUwQSklMEElMEFwcmVkX3NlZyUyMCUzRCUyMHVwc2FtcGxlZF9sb2dpdHMuYXJnbWF4KGRpbSUzRDEpJTVCMCU1RA==",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>]`,wrap:!1}}),{c(){t=M("p"),t.innerHTML=m,e=i(),f(o.$$.fragment),d=i(),U=M("p"),U.innerHTML=V,W=i(),f(C.$$.fragment),R=i(),v=M("p"),v.innerHTML=Y,B=i(),f(I.$$.fragment),G=i(),r=M("p"),r.textContent=$,A=i(),f(g.$$.fragment)},l(p){t=u(p,"P",{"data-svelte-h":!0}),T(t)!=="svelte-wptfed"&&(t.innerHTML=m),e=c(p),j(o.$$.fragment,p),d=c(p),U=u(p,"P",{"data-svelte-h":!0}),T(U)!=="svelte-58ednc"&&(U.innerHTML=V),W=c(p),j(C.$$.fragment,p),R=c(p),v=u(p,"P",{"data-svelte-h":!0}),T(v)!=="svelte-oyplyw"&&(v.innerHTML=Y),B=c(p),j(I.$$.fragment,p),G=c(p),r=u(p,"P",{"data-svelte-h":!0}),T(r)!=="svelte-tk6q3q"&&(r.textContent=$),A=c(p),j(g.$$.fragment,p)},m(p,_){l(p,t,_),l(p,e,_),y(o,p,_),l(p,d,_),l(p,U,_),l(p,W,_),y(C,p,_),l(p,R,_),l(p,v,_),l(p,B,_),y(I,p,_),l(p,G,_),l(p,r,_),l(p,A,_),y(g,p,_),x=!0},p:ps,i(p){x||(w(o.$$.fragment,p),w(C.$$.fragment,p),w(I.$$.fragment,p),w(g.$$.fragment,p),x=!0)},o(p){J(o.$$.fragment,p),J(C.$$.fragment,p),J(I.$$.fragment,p),J(g.$$.fragment,p),x=!1},d(p){p&&(a(t),a(e),a(d),a(U),a(W),a(R),a(v),a(B),a(G),a(r),a(A)),b(o,p),b(C,p),b(I,p),b(g,p)}}}function nt(k){let t,m;return t=new bs({props:{$$slots:{default:[lt]},$$scope:{ctx:k}}}),{c(){f(t.$$.fragment)},l(e){j(t.$$.fragment,e)},m(e,o){y(t,e,o),m=!0},p(e,o){const d={};o&2&&(d.$$scope={dirty:o,ctx:e}),t.$set(d)},i(e){m||(w(t.$$.fragment,e),m=!0)},o(e){J(t.$$.fragment,e),m=!1},d(e){b(t,e)}}}function pt(k){let t,m="Load an image processor to preprocess the image and return the input as TensorFlow tensors:",e,o,d,U,V="Pass your input to the model and return the <code>logits</code>:",W,C,R,v,Y="Next, rescale the logits to the original image size and apply argmax on the class dimension:",B,I,G;return o=new X({props:{code:"ZnJvbSUyMHRyYW5zZm9ybWVycyUyMGltcG9ydCUyMEF1dG9JbWFnZVByb2Nlc3NvciUwQSUwQWltYWdlX3Byb2Nlc3NvciUyMCUzRCUyMEF1dG9JbWFnZVByb2Nlc3Nvci5mcm9tX3ByZXRyYWluZWQoJTIyTWFyaWFLJTJGc2NlbmVfc2VnbWVudGF0aW9uJTIyKSUwQWlucHV0cyUyMCUzRCUyMGltYWdlX3Byb2Nlc3NvcihpbWFnZSUyQyUyMHJldHVybl90ZW5zb3JzJTNEJTIydGYlMjIp",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>image_processor = AutoImageProcessor.from_pretrained(<span class="hljs-string">&quot;MariaK/scene_segmentation&quot;</span>)
<span class="hljs-meta">&gt;&gt;&gt; </span>inputs = image_processor(image, return_tensors=<span class="hljs-string">&quot;tf&quot;</span>)`,wrap:!1}}),C=new X({props:{code:"ZnJvbSUyMHRyYW5zZm9ybWVycyUyMGltcG9ydCUyMFRGQXV0b01vZGVsRm9yU2VtYW50aWNTZWdtZW50YXRpb24lMEElMEFtb2RlbCUyMCUzRCUyMFRGQXV0b01vZGVsRm9yU2VtYW50aWNTZWdtZW50YXRpb24uZnJvbV9wcmV0cmFpbmVkKCUyMk1hcmlhSyUyRnNjZW5lX3NlZ21lbnRhdGlvbiUyMiklMEFsb2dpdHMlMjAlM0QlMjBtb2RlbCgqKmlucHV0cykubG9naXRz",highlighted:`<span class="hljs-meta">&gt;&gt;&gt; </span><span class="hljs-keyword">from</span> transformers <span class="hljs-keyword">import</span> TFAutoModelForSemanticSegmentation

<span class="hljs-meta">&gt;&gt;&gt; </span>model = TFAutoModelForSemanticSegmentation.from_pretrained(<span class="hljs-string">&quot;MariaK/scene_segmentation&quot;</span>)
<span class="hljs-meta">&gt;&gt;&gt; </span>logits = model(**inputs).logits`,wrap:!1}}),I=new X({props:{code:"bG9naXRzJTIwJTNEJTIwdGYudHJhbnNwb3NlKGxvZ2l0cyUyQyUyMCU1QjAlMkMlMjAyJTJDJTIwMyUyQyUyMDElNUQpJTBBJTBBdXBzYW1wbGVkX2xvZ2l0cyUyMCUzRCUyMHRmLmltYWdlLnJlc2l6ZSglMEElMjAlMjAlMjAlMjBsb2dpdHMlMkMlMEElMjAlMjAlMjAlMjAlMjMlMjBXZSUyMHJldmVyc2UlMjB0aGUlMjBzaGFwZSUyMG9mJTIwJTYwaW1hZ2UlNjAlMjBiZWNhdXNlJTIwJTYwaW1hZ2Uuc2l6ZSU2MCUyMHJldHVybnMlMjB3aWR0aCUyMGFuZCUyMGhlaWdodC4lMEElMjAlMjAlMjAlMjBpbWFnZS5zaXplJTVCJTNBJTNBLTElNUQlMkMlMEEpJTBBJTBBcHJlZF9zZWclMjAlM0QlMjB0Zi5tYXRoLmFyZ21heCh1cHNhbXBsZWRfbG9naXRzJTJDJTIwYXhpcyUzRC0xKSU1QjAlNUQ=",highlighted:`<span class="hljs-meta">&gt;&gt;&gt; </span>logits = tf.transpose(logits, [<span class="hljs-number">0</span>, <span class="hljs-number">2</span>, <span class="hljs-number">3</span>, <span class="hljs-number">1</span>])

<span class="hljs-meta">&gt;&gt;&gt; </span>upsampled_logits = tf.image.resize(
<span class="hljs-meta">... </span>    logits,
<span class="hljs-meta">... </span>    <span class="hljs-comment"># We reverse the shape of \`image\` because \`image.size\` returns width and height.</span>
<span class="hljs-meta">... </span>    image.size[::-<span class="hljs-number">1</span>],
<span class="hljs-meta">... </span>)

<span class="hljs-meta">&gt;&gt;&gt; </span>pred_seg = tf.math.argmax(upsampled_logits, axis=-<span class="hljs-number">1</span>)[<span class="hljs-number">0</span>]`,wrap:!1}}),{c(){t=M("p"),t.textContent=m,e=i(),f(o.$$.fragment),d=i(),U=M("p"),U.innerHTML=V,W=i(),f(C.$$.fragment),R=i(),v=M("p"),v.textContent=Y,B=i(),f(I.$$.fragment)},l(r){t=u(r,"P",{"data-svelte-h":!0}),T(t)!=="svelte-1r2yss0"&&(t.textContent=m),e=c(r),j(o.$$.fragment,r),d=c(r),U=u(r,"P",{"data-svelte-h":!0}),T(U)!=="svelte-oyplyw"&&(U.innerHTML=V),W=c(r),j(C.$$.fragment,r),R=c(r),v=u(r,"P",{"data-svelte-h":!0}),T(v)!=="svelte-enih9r"&&(v.textContent=Y),B=c(r),j(I.$$.fragment,r)},m(r,$){l(r,t,$),l(r,e,$),y(o,r,$),l(r,d,$),l(r,U,$),l(r,W,$),y(C,r,$),l(r,R,$),l(r,v,$),l(r,B,$),y(I,r,$),G=!0},p:ps,i(r){G||(w(o.$$.fragment,r),w(C.$$.fragment,r),w(I.$$.fragment,r),G=!0)},o(r){J(o.$$.fragment,r),J(C.$$.fragment,r),J(I.$$.fragment,r),G=!1},d(r){r&&(a(t),a(e),a(d),a(U),a(W),a(R),a(v),a(B)),b(o,r),b(C,r),b(I,r)}}}function rt(k){let t,m;return t=new bs({props:{$$slots:{default:[pt]},$$scope:{ctx:k}}}),{c(){f(t.$$.fragment)},l(e){j(t.$$.fragment,e)},m(e,o){y(t,e,o),m=!0},p(e,o){const d={};o&2&&(d.$$scope={dirty:o,ctx:e}),t.$set(d)},i(e){m||(w(t.$$.fragment,e),m=!0)},o(e){J(t.$$.fragment,e),m=!1},d(e){b(t,e)}}}function ot(k){let t,m,e,o,d,U,V,W,C,R,v="Semantic segmentation",Y,B,I,G,r,$,A="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, “car” instead of “car-1” and “car-2”). 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.",g,x,p="This guide will show you how to:",_,z,O='<li>Finetune <a href="https://huggingface.co/docs/transformers/main/en/model_doc/segformer#segformer" rel="nofollow">SegFormer</a> on the <a href="https://huggingface.co/datasets/scene_parse_150" rel="nofollow">SceneParse150</a> dataset.</li> <li>Use your finetuned model for inference.</li>',Ts,E,Q,S,ss="Before you begin, make sure you have all the necessary libraries installed:",Us,L,D,q,es="We encourage you to log in to your Hugging Face account so you can upload and share your model with the community. When prompted, enter your token to log in:",$s,P,h,Z,K,pe,Is,ta,se,ia="Load SceneParse150 dataset",je,_s,ca="Start by loading a smaller subset of the SceneParse150 dataset from the 🤗 Datasets library. This’ll give you a chance to experiment and make sure everything works before spending more time training on the full dataset.",ye,Cs,we,vs,ma='Split the dataset’s <code>train</code> split into a train and test set with the <a href="https://huggingface.co/docs/datasets/v2.14.5/en/package_reference/main_classes#datasets.Dataset.train_test_split" rel="nofollow">train_test_split</a> method:',Je,ks,be,Ws,ha="Then take a look at an example:",Te,Zs,Ue,Bs,Ma="<li><code>image</code>: a PIL image of the scene.</li> <li><code>annotation</code>: a PIL image of the segmentation map, which is also the model’s target.</li> <li><code>scene_category</code>: a category id that describes the image scene like “kitchen” or “office”. In this guide, you’ll only need <code>image</code> and <code>annotation</code>, both of which are PIL images.</li>",$e,xs,ua="You’ll 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 <code>id2label</code> and <code>label2id</code> dictionaries:",Ie,Gs,_e,as,rs,re,Xs,la,ee,ga="Preprocess",Ce,Rs,da="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’t actually included in the 150 classes, so you’ll need to set <code>reduce_labels=True</code> to subtract one from all the labels. The zero-index is replaced by <code>255</code> so it’s ignored by SegFormer’s loss function:",ve,Ys,ke,os,We,is,Ze,ts,cs,oe,Vs,na,ae,fa="Evaluate",Be,Fs,ja='Including a metric during training is often helpful for evaluating your model’s performance. You can quickly load an evaluation method with the 🤗 <a href="https://huggingface.co/docs/evaluate/index" rel="nofollow">Evaluate</a> library. For this task, load the <a href="https://huggingface.co/spaces/evaluate-metric/accuracy" rel="nofollow">mean Intersection over Union</a> (IoU) metric (see the 🤗 Evaluate <a href="https://huggingface.co/docs/evaluate/a_quick_tour" rel="nofollow">quick tour</a> to learn more about how to load and compute a metric):',xe,Ns,Ge,As,ya=`Then create a function to <a href="https://huggingface.co/docs/evaluate/v0.4.0/en/package_reference/main_classes#evaluate.EvaluationModule.compute" rel="nofollow">compute</a> 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 <a href="https://huggingface.co/docs/evaluate/v0.4.0/en/package_reference/main_classes#evaluate.EvaluationModule.compute" rel="nofollow">compute</a>:`,Xe,ms,Re,hs,Ye,Hs,wa="Your <code>compute_metrics</code> function is ready to go now, and you’ll return to it when you setup your training.",Ve,ls,Ms,ie,zs,pa,te,Ja="Train",Fe,us,Ne,gs,Ae,ns,ds,ce,Es,ra,le,ba="Inference",He,Qs,Ta="Great, now that you’ve finetuned a model, you can use it for inference!",ze,Ss,Ua="Load an image for inference:",Ee,Ls,Qe,fs,$a='<img src="https://huggingface.co/datasets/huggingface/documentation-images/resolve/main/semantic-seg-image.png" alt="Image of bedroom"/>',Se,js,Le,ys,De,Ds,Ia='To visualize the results, load the <a href="https://github.com/tensorflow/models/blob/3f1ca33afe3c1631b733ea7e40c294273b9e406d/research/deeplab/utils/get_dataset_colormap.py#L51" rel="nofollow">dataset color palette</a> as <code>ade_palette()</code> that maps each class to their RGB values. Then you can combine and plot your image and the predicted segmentation map:',qe,qs,Pe,ws,_a='<img src="https://huggingface.co/datasets/huggingface/documentation-images/resolve/main/semantic-seg-preds.png" alt="Image of bedroom overlaid with segmentation map"/>',Ke,me,Oe;return W=new ne({}),B=new Aa({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"}]}}),G=new Na({props:{id:"dKE8SIt9C-w"}}),E=new oa({props:{$$slots:{default:[Ha]},$$scope:{ctx:k}}}),L=new X({props:{code:"cGlwJTIwaW5zdGFsbCUyMC1xJTIwZGF0YXNldHMlMjB0cmFuc2Zvcm1lcnMlMjBldmFsdWF0ZQ==",highlighted:"pip install -q datasets transformers evaluate",wrap:!1}}),P=new X({props:{code:"ZnJvbSUyMGh1Z2dpbmdmYWNlX2h1YiUyMGltcG9ydCUyMG5vdGVib29rX2xvZ2luJTBBJTBBbm90ZWJvb2tfbG9naW4oKQ==",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()`,wrap:!1}}),Is=new ne({}),Cs=new X({props:{code:"ZnJvbSUyMGRhdGFzZXRzJTIwaW1wb3J0JTIwbG9hZF9kYXRhc2V0JTBBJTBBZHMlMjAlM0QlMjBsb2FkX2RhdGFzZXQoJTIyc2NlbmVfcGFyc2VfMTUwJTIyJTJDJTIwc3BsaXQlM0QlMjJ0cmFpbiU1QiUzQTUwJTVEJTIyKQ==",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>)`,wrap:!1}}),ks=new X({props:{code:"ZHMlMjAlM0QlMjBkcy50cmFpbl90ZXN0X3NwbGl0KHRlc3Rfc2l6ZSUzRDAuMiklMEF0cmFpbl9kcyUyMCUzRCUyMGRzJTVCJTIydHJhaW4lMjIlNUQlMEF0ZXN0X2RzJTIwJTNEJTIwZHMlNUIlMjJ0ZXN0JTIyJTVE",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>]`,wrap:!1}}),Zs=new X({props:{code:"dHJhaW5fZHMlNUIwJTVE",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>}`,wrap:!1}}),Gs=new X({props:{code:"aW1wb3J0JTIwanNvbiUwQWZyb20lMjBodWdnaW5nZmFjZV9odWIlMjBpbXBvcnQlMjBjYWNoZWRfZG93bmxvYWQlMkMlMjBoZl9odWJfdXJsJTBBJTBBcmVwb19pZCUyMCUzRCUyMCUyMmh1Z2dpbmdmYWNlJTJGbGFiZWwtZmlsZXMlMjIlMEFmaWxlbmFtZSUyMCUzRCUyMCUyMmFkZTIway1pZDJsYWJlbC5qc29uJTIyJTBBaWQybGFiZWwlMjAlM0QlMjBqc29uLmxvYWQob3BlbihjYWNoZWRfZG93bmxvYWQoaGZfaHViX3VybChyZXBvX2lkJTJDJTIwZmlsZW5hbWUlMkMlMjByZXBvX3R5cGUlM0QlMjJkYXRhc2V0JTIyKSklMkMlMjAlMjJyJTIyKSklMEFpZDJsYWJlbCUyMCUzRCUyMCU3QmludChrKSUzQSUyMHYlMjBmb3IlMjBrJTJDJTIwdiUyMGluJTIwaWQybGFiZWwuaXRlbXMoKSU3RCUwQWxhYmVsMmlkJTIwJTNEJTIwJTdCdiUzQSUyMGslMjBmb3IlMjBrJTJDJTIwdiUyMGluJTIwaWQybGFiZWwuaXRlbXMoKSU3RCUwQW51bV9sYWJlbHMlMjAlM0QlMjBsZW4oaWQybGFiZWwp",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-id2label.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)`,wrap:!1}}),Xs=new ne({}),Ys=new X({props:{code:"ZnJvbSUyMHRyYW5zZm9ybWVycyUyMGltcG9ydCUyMEF1dG9JbWFnZVByb2Nlc3NvciUwQSUwQWNoZWNrcG9pbnQlMjAlM0QlMjAlMjJudmlkaWElMkZtaXQtYjAlMjIlMEFpbWFnZV9wcm9jZXNzb3IlMjAlM0QlMjBBdXRvSW1hZ2VQcm9jZXNzb3IuZnJvbV9wcmV0cmFpbmVkKGNoZWNrcG9pbnQlMkMlMjByZWR1Y2VfbGFiZWxzJTNEVHJ1ZSk=",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>checkpoint = <span class="hljs-string">&quot;nvidia/mit-b0&quot;</span>
<span class="hljs-meta">&gt;&gt;&gt; </span>image_processor = AutoImageProcessor.from_pretrained(checkpoint, reduce_labels=<span class="hljs-literal">True</span>)`,wrap:!1}}),os=new Js({props:{pytorch:!0,tensorflow:!1,jax:!1,$$slots:{pytorch:[Ea]},$$scope:{ctx:k}}}),is=new Js({props:{pytorch:!1,tensorflow:!0,jax:!1,$$slots:{tensorflow:[Sa]},$$scope:{ctx:k}}}),Vs=new ne({}),Ns=new X({props:{code:"aW1wb3J0JTIwZXZhbHVhdGUlMEElMEFtZXRyaWMlMjAlM0QlMjBldmFsdWF0ZS5sb2FkKCUyMm1lYW5faW91JTIyKQ==",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>)`,wrap:!1}}),ms=new Js({props:{pytorch:!0,tensorflow:!1,jax:!1,$$slots:{pytorch:[Da]},$$scope:{ctx:k}}}),hs=new Js({props:{pytorch:!1,tensorflow:!0,jax:!1,$$slots:{tensorflow:[Pa]},$$scope:{ctx:k}}}),zs=new ne({}),us=new Js({props:{pytorch:!0,tensorflow:!1,jax:!1,$$slots:{pytorch:[st]},$$scope:{ctx:k}}}),gs=new Js({props:{pytorch:!1,tensorflow:!0,jax:!1,$$slots:{tensorflow:[tt]},$$scope:{ctx:k}}}),Es=new ne({}),Ls=new X({props:{code:"aW1hZ2UlMjAlM0QlMjBkcyU1QjAlNUQlNUIlMjJpbWFnZSUyMiU1RCUwQWltYWdl",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`,wrap:!1}}),js=new Js({props:{pytorch:!0,tensorflow:!1,jax:!1,$$slots:{pytorch:[nt]},$$scope:{ctx:k}}}),ys=new Js({props:{pytorch:!1,tensorflow:!0,jax:!1,$$slots:{tensorflow:[rt]},$$scope:{ctx:k}}}),qs=new X({props:{code:"aW1wb3J0JTIwbWF0cGxvdGxpYi5weXBsb3QlMjBhcyUyMHBsdCUwQWltcG9ydCUyMG51bXB5JTIwYXMlMjBucCUwQSUwQWNvbG9yX3NlZyUyMCUzRCUyMG5wLnplcm9zKChwcmVkX3NlZy5zaGFwZSU1QjAlNUQlMkMlMjBwcmVkX3NlZy5zaGFwZSU1QjElNUQlMkMlMjAzKSUyQyUyMGR0eXBlJTNEbnAudWludDgpJTBBcGFsZXR0ZSUyMCUzRCUyMG5wLmFycmF5KGFkZV9wYWxldHRlKCkpJTBBZm9yJTIwbGFiZWwlMkMlMjBjb2xvciUyMGluJTIwZW51bWVyYXRlKHBhbGV0dGUpJTNBJTBBJTIwJTIwJTIwJTIwY29sb3Jfc2VnJTVCcHJlZF9zZWclMjAlM0QlM0QlMjBsYWJlbCUyQyUyMCUzQSU1RCUyMCUzRCUyMGNvbG9yJTBBY29sb3Jfc2VnJTIwJTNEJTIwY29sb3Jfc2VnJTVCLi4uJTJDJTIwJTNBJTNBLTElNUQlMjAlMjAlMjMlMjBjb252ZXJ0JTIwdG8lMjBCR1IlMEElMEFpbWclMjAlM0QlMjBucC5hcnJheShpbWFnZSklMjAqJTIwMC41JTIwJTJCJTIwY29sb3Jfc2VnJTIwKiUyMDAuNSUyMCUyMCUyMyUyMHBsb3QlMjB0aGUlMjBpbWFnZSUyMHdpdGglMjB0aGUlMjBzZWdtZW50YXRpb24lMjBtYXAlMEFpbWclMjAlM0QlMjBpbWcuYXN0eXBlKG5wLnVpbnQ4KSUwQSUwQXBsdC5maWd1cmUoZmlnc2l6ZSUzRCgxNSUyQyUyMDEwKSklMEFwbHQuaW1zaG93KGltZyklMEFwbHQuc2hvdygp",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><span class="hljs-keyword">import</span> numpy <span class="hljs-keyword">as</span> np

<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()`,wrap:!1}}),{c(){t=M("meta"),m=i(),e=M("p"),o=i(),d=M("h1"),U=M("a"),V=M("span"),f(W.$$.fragment),C=i(),R=M("span"),R.textContent=v,Y=i(),f(B.$$.fragment),I=i(),f(G.$$.fragment),r=i(),$=M("p"),$.textContent=A,g=i(),x=M("p"),x.textContent=p,_=i(),z=M("ol"),z.innerHTML=O,Ts=i(),f(E.$$.fragment),Q=i(),S=M("p"),S.textContent=ss,Us=i(),f(L.$$.fragment),D=i(),q=M("p"),q.textContent=es,$s=i(),f(P.$$.fragment),h=i(),Z=M("h2"),K=M("a"),pe=M("span"),f(Is.$$.fragment),ta=i(),se=M("span"),se.textContent=ia,je=i(),_s=M("p"),_s.textContent=ca,ye=i(),f(Cs.$$.fragment),we=i(),vs=M("p"),vs.innerHTML=ma,Je=i(),f(ks.$$.fragment),be=i(),Ws=M("p"),Ws.textContent=ha,Te=i(),f(Zs.$$.fragment),Ue=i(),Bs=M("ul"),Bs.innerHTML=Ma,$e=i(),xs=M("p"),xs.innerHTML=ua,Ie=i(),f(Gs.$$.fragment),_e=i(),as=M("h2"),rs=M("a"),re=M("span"),f(Xs.$$.fragment),la=i(),ee=M("span"),ee.textContent=ga,Ce=i(),Rs=M("p"),Rs.innerHTML=da,ve=i(),f(Ys.$$.fragment),ke=i(),f(os.$$.fragment),We=i(),f(is.$$.fragment),Ze=i(),ts=M("h2"),cs=M("a"),oe=M("span"),f(Vs.$$.fragment),na=i(),ae=M("span"),ae.textContent=fa,Be=i(),Fs=M("p"),Fs.innerHTML=ja,xe=i(),f(Ns.$$.fragment),Ge=i(),As=M("p"),As.innerHTML=ya,Xe=i(),f(ms.$$.fragment),Re=i(),f(hs.$$.fragment),Ye=i(),Hs=M("p"),Hs.innerHTML=wa,Ve=i(),ls=M("h2"),Ms=M("a"),ie=M("span"),f(zs.$$.fragment),pa=i(),te=M("span"),te.textContent=Ja,Fe=i(),f(us.$$.fragment),Ne=i(),f(gs.$$.fragment),Ae=i(),ns=M("h2"),ds=M("a"),ce=M("span"),f(Es.$$.fragment),ra=i(),le=M("span"),le.textContent=ba,He=i(),Qs=M("p"),Qs.textContent=Ta,ze=i(),Ss=M("p"),Ss.textContent=Ua,Ee=i(),f(Ls.$$.fragment),Qe=i(),fs=M("div"),fs.innerHTML=$a,Se=i(),f(js.$$.fragment),Le=i(),f(ys.$$.fragment),De=i(),Ds=M("p"),Ds.innerHTML=Ia,qe=i(),f(qs.$$.fragment),Pe=i(),ws=M("div"),ws.innerHTML=_a,Ke=i(),me=M("p"),this.h()},l(s){const n=Ya("svelte-1phssyn",document.head);t=u(n,"META",{name:!0,content:!0}),n.forEach(a),m=c(s),e=u(s,"P",{}),H(e).forEach(a),o=c(s),d=u(s,"H1",{class:!0});var Ps=H(d);U=u(Ps,"A",{id:!0,class:!0,href:!0});var he=H(U);V=u(he,"SPAN",{});var Me=H(V);j(W.$$.fragment,Me),Me.forEach(a),he.forEach(a),C=c(Ps),R=u(Ps,"SPAN",{"data-svelte-h":!0}),T(R)!=="svelte-6h5c9x"&&(R.textContent=v),Ps.forEach(a),Y=c(s),j(B.$$.fragment,s),I=c(s),j(G.$$.fragment,s),r=c(s),$=u(s,"P",{"data-svelte-h":!0}),T($)!=="svelte-1sbjiw"&&($.textContent=A),g=c(s),x=u(s,"P",{"data-svelte-h":!0}),T(x)!=="svelte-1aff4p7"&&(x.textContent=p),_=c(s),z=u(s,"OL",{"data-svelte-h":!0}),T(z)!=="svelte-u87rmm"&&(z.innerHTML=O),Ts=c(s),j(E.$$.fragment,s),Q=c(s),S=u(s,"P",{"data-svelte-h":!0}),T(S)!=="svelte-1c9nexd"&&(S.textContent=ss),Us=c(s),j(L.$$.fragment,s),D=c(s),q=u(s,"P",{"data-svelte-h":!0}),T(q)!=="svelte-27hn0u"&&(q.textContent=es),$s=c(s),j(P.$$.fragment,s),h=c(s),Z=u(s,"H2",{class:!0});var Ks=H(Z);K=u(Ks,"A",{id:!0,class:!0,href:!0});var ue=H(K);pe=u(ue,"SPAN",{});var ge=H(pe);j(Is.$$.fragment,ge),ge.forEach(a),ue.forEach(a),ta=c(Ks),se=u(Ks,"SPAN",{"data-svelte-h":!0}),T(se)!=="svelte-90yv5c"&&(se.textContent=ia),Ks.forEach(a),je=c(s),_s=u(s,"P",{"data-svelte-h":!0}),T(_s)!=="svelte-ldhwp2"&&(_s.textContent=ca),ye=c(s),j(Cs.$$.fragment,s),we=c(s),vs=u(s,"P",{"data-svelte-h":!0}),T(vs)!=="svelte-1izknij"&&(vs.innerHTML=ma),Je=c(s),j(ks.$$.fragment,s),be=c(s),Ws=u(s,"P",{"data-svelte-h":!0}),T(Ws)!=="svelte-1m91ua0"&&(Ws.textContent=ha),Te=c(s),j(Zs.$$.fragment,s),Ue=c(s),Bs=u(s,"UL",{"data-svelte-h":!0}),T(Bs)!=="svelte-1gb3b0f"&&(Bs.innerHTML=Ma),$e=c(s),xs=u(s,"P",{"data-svelte-h":!0}),T(xs)!=="svelte-j46pio"&&(xs.innerHTML=ua),Ie=c(s),j(Gs.$$.fragment,s),_e=c(s),as=u(s,"H2",{class:!0});var Os=H(as);rs=u(Os,"A",{id:!0,class:!0,href:!0});var de=H(rs);re=u(de,"SPAN",{});var fe=H(re);j(Xs.$$.fragment,fe),fe.forEach(a),de.forEach(a),la=c(Os),ee=u(Os,"SPAN",{"data-svelte-h":!0}),T(ee)!=="svelte-1cg9qj"&&(ee.textContent=ga),Os.forEach(a),Ce=c(s),Rs=u(s,"P",{"data-svelte-h":!0}),T(Rs)!=="svelte-7ebr"&&(Rs.innerHTML=da),ve=c(s),j(Ys.$$.fragment,s),ke=c(s),j(os.$$.fragment,s),We=c(s),j(is.$$.fragment,s),Ze=c(s),ts=u(s,"H2",{class:!0});var sa=H(ts);cs=u(sa,"A",{id:!0,class:!0,href:!0});var Ca=H(cs);oe=u(Ca,"SPAN",{});var va=H(oe);j(Vs.$$.fragment,va),va.forEach(a),Ca.forEach(a),na=c(sa),ae=u(sa,"SPAN",{"data-svelte-h":!0}),T(ae)!=="svelte-sh8s6s"&&(ae.textContent=fa),sa.forEach(a),Be=c(s),Fs=u(s,"P",{"data-svelte-h":!0}),T(Fs)!=="svelte-vg2xml"&&(Fs.innerHTML=ja),xe=c(s),j(Ns.$$.fragment,s),Ge=c(s),As=u(s,"P",{"data-svelte-h":!0}),T(As)!=="svelte-czaf8w"&&(As.innerHTML=ya),Xe=c(s),j(ms.$$.fragment,s),Re=c(s),j(hs.$$.fragment,s),Ye=c(s),Hs=u(s,"P",{"data-svelte-h":!0}),T(Hs)!=="svelte-183aynn"&&(Hs.innerHTML=wa),Ve=c(s),ls=u(s,"H2",{class:!0});var ea=H(ls);Ms=u(ea,"A",{id:!0,class:!0,href:!0});var ka=H(Ms);ie=u(ka,"SPAN",{});var Wa=H(ie);j(zs.$$.fragment,Wa),Wa.forEach(a),ka.forEach(a),pa=c(ea),te=u(ea,"SPAN",{"data-svelte-h":!0}),T(te)!=="svelte-5arm0l"&&(te.textContent=Ja),ea.forEach(a),Fe=c(s),j(us.$$.fragment,s),Ne=c(s),j(gs.$$.fragment,s),Ae=c(s),ns=u(s,"H2",{class:!0});var aa=H(ns);ds=u(aa,"A",{id:!0,class:!0,href:!0});var Za=H(ds);ce=u(Za,"SPAN",{});var Ba=H(ce);j(Es.$$.fragment,Ba),Ba.forEach(a),Za.forEach(a),ra=c(aa),le=u(aa,"SPAN",{"data-svelte-h":!0}),T(le)!=="svelte-199uz7g"&&(le.textContent=ba),aa.forEach(a),He=c(s),Qs=u(s,"P",{"data-svelte-h":!0}),T(Qs)!=="svelte-633ppb"&&(Qs.textContent=Ta),ze=c(s),Ss=u(s,"P",{"data-svelte-h":!0}),T(Ss)!=="svelte-1g0hugc"&&(Ss.textContent=Ua),Ee=c(s),j(Ls.$$.fragment,s),Qe=c(s),fs=u(s,"DIV",{class:!0,"data-svelte-h":!0}),T(fs)!=="svelte-11jfm1f"&&(fs.innerHTML=$a),Se=c(s),j(js.$$.fragment,s),Le=c(s),j(ys.$$.fragment,s),De=c(s),Ds=u(s,"P",{"data-svelte-h":!0}),T(Ds)!=="svelte-1ng77tx"&&(Ds.innerHTML=Ia),qe=c(s),j(qs.$$.fragment,s),Pe=c(s),ws=u(s,"DIV",{class:!0,"data-svelte-h":!0}),T(ws)!=="svelte-nsecok"&&(ws.innerHTML=_a),Ke=c(s),me=u(s,"P",{}),H(me).forEach(a),this.h()},h(){F(t,"name","hf:doc:metadata"),F(t,"content",JSON.stringify(it)),F(U,"id","semantic-segmentation"),F(U,"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"),F(U,"href","#semantic-segmentation"),F(d,"class","relative group"),F(K,"id","load-sceneparse150-dataset"),F(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"),F(K,"href","#load-sceneparse150-dataset"),F(Z,"class","relative group"),F(rs,"id","preprocess"),F(rs,"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"),F(rs,"href","#preprocess"),F(as,"class","relative group"),F(cs,"id","evaluate"),F(cs,"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"),F(cs,"href","#evaluate"),F(ts,"class","relative group"),F(Ms,"id","train"),F(Ms,"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"),F(Ms,"href","#train"),F(ls,"class","relative group"),F(ds,"id","inference"),F(ds,"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"),F(ds,"href","#inference"),F(ns,"class","relative group"),F(fs,"class","flex justify-center"),F(ws,"class","flex justify-center")},m(s,n){N(document.head,t),l(s,m,n),l(s,e,n),l(s,o,n),l(s,d,n),N(d,U),N(U,V),y(W,V,null),N(d,C),N(d,R),l(s,Y,n),y(B,s,n),l(s,I,n),y(G,s,n),l(s,r,n),l(s,$,n),l(s,g,n),l(s,x,n),l(s,_,n),l(s,z,n),l(s,Ts,n),y(E,s,n),l(s,Q,n),l(s,S,n),l(s,Us,n),y(L,s,n),l(s,D,n),l(s,q,n),l(s,$s,n),y(P,s,n),l(s,h,n),l(s,Z,n),N(Z,K),N(K,pe),y(Is,pe,null),N(Z,ta),N(Z,se),l(s,je,n),l(s,_s,n),l(s,ye,n),y(Cs,s,n),l(s,we,n),l(s,vs,n),l(s,Je,n),y(ks,s,n),l(s,be,n),l(s,Ws,n),l(s,Te,n),y(Zs,s,n),l(s,Ue,n),l(s,Bs,n),l(s,$e,n),l(s,xs,n),l(s,Ie,n),y(Gs,s,n),l(s,_e,n),l(s,as,n),N(as,rs),N(rs,re),y(Xs,re,null),N(as,la),N(as,ee),l(s,Ce,n),l(s,Rs,n),l(s,ve,n),y(Ys,s,n),l(s,ke,n),y(os,s,n),l(s,We,n),y(is,s,n),l(s,Ze,n),l(s,ts,n),N(ts,cs),N(cs,oe),y(Vs,oe,null),N(ts,na),N(ts,ae),l(s,Be,n),l(s,Fs,n),l(s,xe,n),y(Ns,s,n),l(s,Ge,n),l(s,As,n),l(s,Xe,n),y(ms,s,n),l(s,Re,n),y(hs,s,n),l(s,Ye,n),l(s,Hs,n),l(s,Ve,n),l(s,ls,n),N(ls,Ms),N(Ms,ie),y(zs,ie,null),N(ls,pa),N(ls,te),l(s,Fe,n),y(us,s,n),l(s,Ne,n),y(gs,s,n),l(s,Ae,n),l(s,ns,n),N(ns,ds),N(ds,ce),y(Es,ce,null),N(ns,ra),N(ns,le),l(s,He,n),l(s,Qs,n),l(s,ze,n),l(s,Ss,n),l(s,Ee,n),y(Ls,s,n),l(s,Qe,n),l(s,fs,n),l(s,Se,n),y(js,s,n),l(s,Le,n),y(ys,s,n),l(s,De,n),l(s,Ds,n),l(s,qe,n),y(qs,s,n),l(s,Pe,n),l(s,ws,n),l(s,Ke,n),l(s,me,n),Oe=!0},p(s,[n]){const Ps={};n&2&&(Ps.$$scope={dirty:n,ctx:s}),E.$set(Ps);const he={};n&2&&(he.$$scope={dirty:n,ctx:s}),os.$set(he);const Me={};n&2&&(Me.$$scope={dirty:n,ctx:s}),is.$set(Me);const Ks={};n&2&&(Ks.$$scope={dirty:n,ctx:s}),ms.$set(Ks);const ue={};n&2&&(ue.$$scope={dirty:n,ctx:s}),hs.$set(ue);const ge={};n&2&&(ge.$$scope={dirty:n,ctx:s}),us.$set(ge);const Os={};n&2&&(Os.$$scope={dirty:n,ctx:s}),gs.$set(Os);const de={};n&2&&(de.$$scope={dirty:n,ctx:s}),js.$set(de);const fe={};n&2&&(fe.$$scope={dirty:n,ctx:s}),ys.$set(fe)},i(s){Oe||(w(W.$$.fragment,s),w(B.$$.fragment,s),w(G.$$.fragment,s),w(E.$$.fragment,s),w(L.$$.fragment,s),w(P.$$.fragment,s),w(Is.$$.fragment,s),w(Cs.$$.fragment,s),w(ks.$$.fragment,s),w(Zs.$$.fragment,s),w(Gs.$$.fragment,s),w(Xs.$$.fragment,s),w(Ys.$$.fragment,s),w(os.$$.fragment,s),w(is.$$.fragment,s),w(Vs.$$.fragment,s),w(Ns.$$.fragment,s),w(ms.$$.fragment,s),w(hs.$$.fragment,s),w(zs.$$.fragment,s),w(us.$$.fragment,s),w(gs.$$.fragment,s),w(Es.$$.fragment,s),w(Ls.$$.fragment,s),w(js.$$.fragment,s),w(ys.$$.fragment,s),w(qs.$$.fragment,s),Oe=!0)},o(s){J(W.$$.fragment,s),J(B.$$.fragment,s),J(G.$$.fragment,s),J(E.$$.fragment,s),J(L.$$.fragment,s),J(P.$$.fragment,s),J(Is.$$.fragment,s),J(Cs.$$.fragment,s),J(ks.$$.fragment,s),J(Zs.$$.fragment,s),J(Gs.$$.fragment,s),J(Xs.$$.fragment,s),J(Ys.$$.fragment,s),J(os.$$.fragment,s),J(is.$$.fragment,s),J(Vs.$$.fragment,s),J(Ns.$$.fragment,s),J(ms.$$.fragment,s),J(hs.$$.fragment,s),J(zs.$$.fragment,s),J(us.$$.fragment,s),J(gs.$$.fragment,s),J(Es.$$.fragment,s),J(Ls.$$.fragment,s),J(js.$$.fragment,s),J(ys.$$.fragment,s),J(qs.$$.fragment,s),Oe=!1},d(s){s&&(a(m),a(e),a(o),a(d),a(Y),a(I),a(r),a($),a(g),a(x),a(_),a(z),a(Ts),a(Q),a(S),a(Us),a(D),a(q),a($s),a(h),a(Z),a(je),a(_s),a(ye),a(we),a(vs),a(Je),a(be),a(Ws),a(Te),a(Ue),a(Bs),a($e),a(xs),a(Ie),a(_e),a(as),a(Ce),a(Rs),a(ve),a(ke),a(We),a(Ze),a(ts),a(Be),a(Fs),a(xe),a(Ge),a(As),a(Xe),a(Re),a(Ye),a(Hs),a(Ve),a(ls),a(Fe),a(Ne),a(Ae),a(ns),a(He),a(Qs),a(ze),a(Ss),a(Ee),a(Qe),a(fs),a(Se),a(Le),a(De),a(Ds),a(qe),a(Pe),a(ws),a(Ke),a(me)),a(t),b(W),b(B,s),b(G,s),b(E,s),b(L,s),b(P,s),b(Is),b(Cs,s),b(ks,s),b(Zs,s),b(Gs,s),b(Xs),b(Ys,s),b(os,s),b(is,s),b(Vs),b(Ns,s),b(ms,s),b(hs,s),b(zs),b(us,s),b(gs,s),b(Es),b(Ls,s),b(js,s),b(ys,s),b(qs,s)}}}const it={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 ct(k){return Ga(()=>{new URLSearchParams(window.location.search).get("fw")}),[]}class yt extends Xa{constructor(t){super(),Ra(this,t,ct,ot,xa,{})}}export{yt as component};
