import{s as Le,o as De,n as hs}from"../chunks/scheduler.9bc65507.js";import{S as Pe,i as Ke,g as J,s as i,r as u,A as Oe,h as T,f as e,c as m,j as qe,u as d,x as _,k as Ue,y as sa,a,v as y,d as g,t as M,w as b,m as ea,n as aa}from"../chunks/index.707bf1b6.js";import{T as $e}from"../chunks/Tip.c2ecdbf4.js";import{Y as ta}from"../chunks/Youtube.e1129c6f.js";import{C as W}from"../chunks/CodeBlock.54a9f38d.js";import{D as la}from"../chunks/DocNotebookDropdown.41f65cb5.js";import{F as Rs,M as Bs}from"../chunks/Markdown.fef84341.js";import{H as xs}from"../chunks/Heading.342b1fa6.js";function na(X){let t,h,l='<a href="../model_doc/beit">BEiT</a>, <a href="../model_doc/bit">BiT</a>, <a href="../model_doc/convnext">ConvNeXT</a>, <a href="../model_doc/convnextv2">ConvNeXTV2</a>, <a href="../model_doc/cvt">CvT</a>, <a href="../model_doc/data2vec-vision">Data2VecVision</a>, <a href="../model_doc/deit">DeiT</a>, <a href="../model_doc/dinat">DiNAT</a>, <a href="../model_doc/dinov2">DINOv2</a>, <a href="../model_doc/efficientformer">EfficientFormer</a>, <a href="../model_doc/efficientnet">EfficientNet</a>, <a href="../model_doc/focalnet">FocalNet</a>, <a href="../model_doc/imagegpt">ImageGPT</a>, <a href="../model_doc/levit">LeViT</a>, <a href="../model_doc/mobilenet_v1">MobileNetV1</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/nat">NAT</a>, <a href="../model_doc/perceiver">Perceiver</a>, <a href="../model_doc/poolformer">PoolFormer</a>, <a href="../model_doc/pvt">PVT</a>, <a href="../model_doc/regnet">RegNet</a>, <a href="../model_doc/resnet">ResNet</a>, <a href="../model_doc/segformer">SegFormer</a>, <a href="../model_doc/swiftformer">SwiftFormer</a>, <a href="../model_doc/swin">Swin Transformer</a>, <a href="../model_doc/swinv2">Swin Transformer V2</a>, <a href="../model_doc/van">VAN</a>, <a href="../model_doc/vit">ViT</a>, <a href="../model_doc/vit_hybrid">ViT Hybrid</a>, <a href="../model_doc/vit_msn">ViTMSN</a>';return{c(){t=ea(`The task illustrated in this tutorial is supported by the following model architectures:

`),h=J("p"),h.innerHTML=l},l(c){t=aa(c,`The task illustrated in this tutorial is supported by the following model architectures:

`),h=T(c,"P",{"data-svelte-h":!0}),_(h)!=="svelte-6ce6f7"&&(h.innerHTML=l)},m(c,w){a(c,t,w),a(c,h,w)},p:hs,d(c){c&&(e(t),e(h))}}}function pa(X){let t,h='Apply some image transformations to the images to make the model more robust against overfitting. Here you’ll use torchvision’s <a href="https://pytorch.org/vision/stable/transforms.html" rel="nofollow"><code>transforms</code></a> module, but you can also use any image library you like.',l,c,w="Crop a random part of the image, resize it, and normalize it with the image mean and standard deviation:",C,Y,k,Z,F="Then create a preprocessing function to apply the transforms and return the <code>pixel_values</code> - the inputs to the model - of the image:",I,R,V,$,x='To apply the preprocessing function over the entire dataset, use 🤗 Datasets <a href="https://huggingface.co/docs/datasets/main/en/package_reference/main_classes#datasets.Dataset.with_transform" rel="nofollow">with_transform</a> method. The transforms are applied on the fly when you load an element of the dataset:',o,U,z,G,N='Now create a batch of examples using <a href="/docs/transformers/main/en/main_classes/data_collator#transformers.DefaultDataCollator">DefaultDataCollator</a>. Unlike other data collators in 🤗 Transformers, the <code>DefaultDataCollator</code> does not apply additional preprocessing such as padding.',p,j,E;return Y=new W({props:{code:"ZnJvbSUyMHRvcmNodmlzaW9uLnRyYW5zZm9ybXMlMjBpbXBvcnQlMjBSYW5kb21SZXNpemVkQ3JvcCUyQyUyMENvbXBvc2UlMkMlMjBOb3JtYWxpemUlMkMlMjBUb1RlbnNvciUwQSUwQW5vcm1hbGl6ZSUyMCUzRCUyME5vcm1hbGl6ZShtZWFuJTNEaW1hZ2VfcHJvY2Vzc29yLmltYWdlX21lYW4lMkMlMjBzdGQlM0RpbWFnZV9wcm9jZXNzb3IuaW1hZ2Vfc3RkKSUwQXNpemUlMjAlM0QlMjAoJTBBJTIwJTIwJTIwJTIwaW1hZ2VfcHJvY2Vzc29yLnNpemUlNUIlMjJzaG9ydGVzdF9lZGdlJTIyJTVEJTBBJTIwJTIwJTIwJTIwaWYlMjAlMjJzaG9ydGVzdF9lZGdlJTIyJTIwaW4lMjBpbWFnZV9wcm9jZXNzb3Iuc2l6ZSUwQSUyMCUyMCUyMCUyMGVsc2UlMjAoaW1hZ2VfcHJvY2Vzc29yLnNpemUlNUIlMjJoZWlnaHQlMjIlNUQlMkMlMjBpbWFnZV9wcm9jZXNzb3Iuc2l6ZSU1QiUyMndpZHRoJTIyJTVEKSUwQSklMEFfdHJhbnNmb3JtcyUyMCUzRCUyMENvbXBvc2UoJTVCUmFuZG9tUmVzaXplZENyb3Aoc2l6ZSklMkMlMjBUb1RlbnNvcigpJTJDJTIwbm9ybWFsaXplJTVEKQ==",highlighted:`<span class="hljs-meta">&gt;&gt;&gt; </span><span class="hljs-keyword">from</span> torchvision.transforms <span class="hljs-keyword">import</span> RandomResizedCrop, Compose, Normalize, ToTensor

<span class="hljs-meta">&gt;&gt;&gt; </span>normalize = Normalize(mean=image_processor.image_mean, std=image_processor.image_std)
<span class="hljs-meta">&gt;&gt;&gt; </span>size = (
<span class="hljs-meta">... </span>    image_processor.size[<span class="hljs-string">&quot;shortest_edge&quot;</span>]
<span class="hljs-meta">... </span>    <span class="hljs-keyword">if</span> <span class="hljs-string">&quot;shortest_edge&quot;</span> <span class="hljs-keyword">in</span> image_processor.size
<span class="hljs-meta">... </span>    <span class="hljs-keyword">else</span> (image_processor.size[<span class="hljs-string">&quot;height&quot;</span>], image_processor.size[<span class="hljs-string">&quot;width&quot;</span>])
<span class="hljs-meta">... </span>)
<span class="hljs-meta">&gt;&gt;&gt; </span>_transforms = Compose([RandomResizedCrop(size), ToTensor(), normalize])`,wrap:!1}}),R=new W({props:{code:"ZGVmJTIwdHJhbnNmb3JtcyhleGFtcGxlcyklM0ElMEElMjAlMjAlMjAlMjBleGFtcGxlcyU1QiUyMnBpeGVsX3ZhbHVlcyUyMiU1RCUyMCUzRCUyMCU1Ql90cmFuc2Zvcm1zKGltZy5jb252ZXJ0KCUyMlJHQiUyMikpJTIwZm9yJTIwaW1nJTIwaW4lMjBleGFtcGxlcyU1QiUyMmltYWdlJTIyJTVEJTVEJTBBJTIwJTIwJTIwJTIwZGVsJTIwZXhhbXBsZXMlNUIlMjJpbWFnZSUyMiU1RCUwQSUyMCUyMCUyMCUyMHJldHVybiUyMGV4YW1wbGVz",highlighted:`<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">examples</span>):
<span class="hljs-meta">... </span>    examples[<span class="hljs-string">&quot;pixel_values&quot;</span>] = [_transforms(img.convert(<span class="hljs-string">&quot;RGB&quot;</span>)) <span class="hljs-keyword">for</span> img <span class="hljs-keyword">in</span> examples[<span class="hljs-string">&quot;image&quot;</span>]]
<span class="hljs-meta">... </span>    <span class="hljs-keyword">del</span> examples[<span class="hljs-string">&quot;image&quot;</span>]
<span class="hljs-meta">... </span>    <span class="hljs-keyword">return</span> examples`,wrap:!1}}),U=new W({props:{code:"Zm9vZCUyMCUzRCUyMGZvb2Qud2l0aF90cmFuc2Zvcm0odHJhbnNmb3Jtcyk=",highlighted:'<span class="hljs-meta">&gt;&gt;&gt; </span>food = food.with_transform(transforms)',wrap:!1}}),j=new W({props:{code:"ZnJvbSUyMHRyYW5zZm9ybWVycyUyMGltcG9ydCUyMERlZmF1bHREYXRhQ29sbGF0b3IlMEElMEFkYXRhX2NvbGxhdG9yJTIwJTNEJTIwRGVmYXVsdERhdGFDb2xsYXRvcigp",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()`,wrap:!1}}),{c(){t=J("p"),t.innerHTML=h,l=i(),c=J("p"),c.textContent=w,C=i(),u(Y.$$.fragment),k=i(),Z=J("p"),Z.innerHTML=F,I=i(),u(R.$$.fragment),V=i(),$=J("p"),$.innerHTML=x,o=i(),u(U.$$.fragment),z=i(),G=J("p"),G.innerHTML=N,p=i(),u(j.$$.fragment)},l(f){t=T(f,"P",{"data-svelte-h":!0}),_(t)!=="svelte-1h04qv0"&&(t.innerHTML=h),l=m(f),c=T(f,"P",{"data-svelte-h":!0}),_(c)!=="svelte-1ocztfo"&&(c.textContent=w),C=m(f),d(Y.$$.fragment,f),k=m(f),Z=T(f,"P",{"data-svelte-h":!0}),_(Z)!=="svelte-q25jfj"&&(Z.innerHTML=F),I=m(f),d(R.$$.fragment,f),V=m(f),$=T(f,"P",{"data-svelte-h":!0}),_($)!=="svelte-7ormju"&&($.innerHTML=x),o=m(f),d(U.$$.fragment,f),z=m(f),G=T(f,"P",{"data-svelte-h":!0}),_(G)!=="svelte-mjzznk"&&(G.innerHTML=N),p=m(f),d(j.$$.fragment,f)},m(f,B){a(f,t,B),a(f,l,B),a(f,c,B),a(f,C,B),y(Y,f,B),a(f,k,B),a(f,Z,B),a(f,I,B),y(R,f,B),a(f,V,B),a(f,$,B),a(f,o,B),y(U,f,B),a(f,z,B),a(f,G,B),a(f,p,B),y(j,f,B),E=!0},p:hs,i(f){E||(g(Y.$$.fragment,f),g(R.$$.fragment,f),g(U.$$.fragment,f),g(j.$$.fragment,f),E=!0)},o(f){M(Y.$$.fragment,f),M(R.$$.fragment,f),M(U.$$.fragment,f),M(j.$$.fragment,f),E=!1},d(f){f&&(e(t),e(l),e(c),e(C),e(k),e(Z),e(I),e(V),e($),e(o),e(z),e(G),e(p)),b(Y,f),b(R,f),b(U,f),b(j,f)}}}function oa(X){let t,h;return t=new Bs({props:{$$slots:{default:[pa]},$$scope:{ctx:X}}}),{c(){u(t.$$.fragment)},l(l){d(t.$$.fragment,l)},m(l,c){y(t,l,c),h=!0},p(l,c){const w={};c&2&&(w.$$scope={dirty:c,ctx:l}),t.$set(w)},i(l){h||(g(t.$$.fragment,l),h=!0)},o(l){M(t.$$.fragment,l),h=!1},d(l){b(t,l)}}}function ra(X){let t,h=`To avoid overfitting and to make the model more robust, add some data augmentation to the training part of the dataset.
Here we use Keras preprocessing layers to define the transformations for the training data (includes data augmentation),
and transformations for the validation data (only center cropping, resizing and normalizing). You can use <code>tf.image</code>or
any other library you prefer.`,l,c,w,C,Y="Next, create functions to apply appropriate transformations to a batch of images, instead of one image at a time.",k,Z,F,I,R='Use 🤗 Datasets <a href="https://huggingface.co/docs/datasets/main/en/package_reference/main_classes#datasets.Dataset.set_transform" rel="nofollow">set_transform</a> to apply the transformations on the fly:',V,$,x,o,U=`As a final preprocessing step, create a batch of examples using <code>DefaultDataCollator</code>. Unlike other data collators in 🤗 Transformers, the
<code>DefaultDataCollator</code> does not apply additional preprocessing, such as padding.`,z,G,N;return c=new W({props:{code:"ZnJvbSUyMHRlbnNvcmZsb3clMjBpbXBvcnQlMjBrZXJhcyUwQWZyb20lMjB0ZW5zb3JmbG93LmtlcmFzJTIwaW1wb3J0JTIwbGF5ZXJzJTBBJTBBc2l6ZSUyMCUzRCUyMChpbWFnZV9wcm9jZXNzb3Iuc2l6ZSU1QiUyMmhlaWdodCUyMiU1RCUyQyUyMGltYWdlX3Byb2Nlc3Nvci5zaXplJTVCJTIyd2lkdGglMjIlNUQpJTBBJTBBdHJhaW5fZGF0YV9hdWdtZW50YXRpb24lMjAlM0QlMjBrZXJhcy5TZXF1ZW50aWFsKCUwQSUyMCUyMCUyMCUyMCU1QiUwQSUyMCUyMCUyMCUyMCUyMCUyMCUyMCUyMGxheWVycy5SYW5kb21Dcm9wKHNpemUlNUIwJTVEJTJDJTIwc2l6ZSU1QjElNUQpJTJDJTBBJTIwJTIwJTIwJTIwJTIwJTIwJTIwJTIwbGF5ZXJzLlJlc2NhbGluZyhzY2FsZSUzRDEuMCUyMCUyRiUyMDEyNy41JTJDJTIwb2Zmc2V0JTNELTEpJTJDJTBBJTIwJTIwJTIwJTIwJTIwJTIwJTIwJTIwbGF5ZXJzLlJhbmRvbUZsaXAoJTIyaG9yaXpvbnRhbCUyMiklMkMlMEElMjAlMjAlMjAlMjAlMjAlMjAlMjAlMjBsYXllcnMuUmFuZG9tUm90YXRpb24oZmFjdG9yJTNEMC4wMiklMkMlMEElMjAlMjAlMjAlMjAlMjAlMjAlMjAlMjBsYXllcnMuUmFuZG9tWm9vbShoZWlnaHRfZmFjdG9yJTNEMC4yJTJDJTIwd2lkdGhfZmFjdG9yJTNEMC4yKSUyQyUwQSUyMCUyMCUyMCUyMCU1RCUyQyUwQSUyMCUyMCUyMCUyMG5hbWUlM0QlMjJ0cmFpbl9kYXRhX2F1Z21lbnRhdGlvbiUyMiUyQyUwQSklMEElMEF2YWxfZGF0YV9hdWdtZW50YXRpb24lMjAlM0QlMjBrZXJhcy5TZXF1ZW50aWFsKCUwQSUyMCUyMCUyMCUyMCU1QiUwQSUyMCUyMCUyMCUyMCUyMCUyMCUyMCUyMGxheWVycy5DZW50ZXJDcm9wKHNpemUlNUIwJTVEJTJDJTIwc2l6ZSU1QjElNUQpJTJDJTBBJTIwJTIwJTIwJTIwJTIwJTIwJTIwJTIwbGF5ZXJzLlJlc2NhbGluZyhzY2FsZSUzRDEuMCUyMCUyRiUyMDEyNy41JTJDJTIwb2Zmc2V0JTNELTEpJTJDJTBBJTIwJTIwJTIwJTIwJTVEJTJDJTBBJTIwJTIwJTIwJTIwbmFtZSUzRCUyMnZhbF9kYXRhX2F1Z21lbnRhdGlvbiUyMiUyQyUwQSk=",highlighted:`<span class="hljs-meta">&gt;&gt;&gt; </span><span class="hljs-keyword">from</span> tensorflow <span class="hljs-keyword">import</span> keras
<span class="hljs-meta">&gt;&gt;&gt; </span><span class="hljs-keyword">from</span> tensorflow.keras <span class="hljs-keyword">import</span> layers

<span class="hljs-meta">&gt;&gt;&gt; </span>size = (image_processor.size[<span class="hljs-string">&quot;height&quot;</span>], image_processor.size[<span class="hljs-string">&quot;width&quot;</span>])

<span class="hljs-meta">&gt;&gt;&gt; </span>train_data_augmentation = keras.Sequential(
<span class="hljs-meta">... </span>    [
<span class="hljs-meta">... </span>        layers.RandomCrop(size[<span class="hljs-number">0</span>], size[<span class="hljs-number">1</span>]),
<span class="hljs-meta">... </span>        layers.Rescaling(scale=<span class="hljs-number">1.0</span> / <span class="hljs-number">127.5</span>, offset=-<span class="hljs-number">1</span>),
<span class="hljs-meta">... </span>        layers.RandomFlip(<span class="hljs-string">&quot;horizontal&quot;</span>),
<span class="hljs-meta">... </span>        layers.RandomRotation(factor=<span class="hljs-number">0.02</span>),
<span class="hljs-meta">... </span>        layers.RandomZoom(height_factor=<span class="hljs-number">0.2</span>, width_factor=<span class="hljs-number">0.2</span>),
<span class="hljs-meta">... </span>    ],
<span class="hljs-meta">... </span>    name=<span class="hljs-string">&quot;train_data_augmentation&quot;</span>,
<span class="hljs-meta">... </span>)

<span class="hljs-meta">&gt;&gt;&gt; </span>val_data_augmentation = keras.Sequential(
<span class="hljs-meta">... </span>    [
<span class="hljs-meta">... </span>        layers.CenterCrop(size[<span class="hljs-number">0</span>], size[<span class="hljs-number">1</span>]),
<span class="hljs-meta">... </span>        layers.Rescaling(scale=<span class="hljs-number">1.0</span> / <span class="hljs-number">127.5</span>, offset=-<span class="hljs-number">1</span>),
<span class="hljs-meta">... </span>    ],
<span class="hljs-meta">... </span>    name=<span class="hljs-string">&quot;val_data_augmentation&quot;</span>,
<span class="hljs-meta">... </span>)`,wrap:!1}}),Z=new W({props:{code:"aW1wb3J0JTIwbnVtcHklMjBhcyUyMG5wJTBBaW1wb3J0JTIwdGVuc29yZmxvdyUyMGFzJTIwdGYlMEFmcm9tJTIwUElMJTIwaW1wb3J0JTIwSW1hZ2UlMEElMEElMEFkZWYlMjBjb252ZXJ0X3RvX3RmX3RlbnNvcihpbWFnZSUzQSUyMEltYWdlKSUzQSUwQSUyMCUyMCUyMCUyMG5wX2ltYWdlJTIwJTNEJTIwbnAuYXJyYXkoaW1hZ2UpJTBBJTIwJTIwJTIwJTIwdGZfaW1hZ2UlMjAlM0QlMjB0Zi5jb252ZXJ0X3RvX3RlbnNvcihucF9pbWFnZSklMEElMjAlMjAlMjAlMjAlMjMlMjAlNjBleHBhbmRfZGltcygpJTYwJTIwaXMlMjB1c2VkJTIwdG8lMjBhZGQlMjBhJTIwYmF0Y2glMjBkaW1lbnNpb24lMjBzaW5jZSUwQSUyMCUyMCUyMCUyMCUyMyUyMHRoZSUyMFRGJTIwYXVnbWVudGF0aW9uJTIwbGF5ZXJzJTIwb3BlcmF0ZXMlMjBvbiUyMGJhdGNoZWQlMjBpbnB1dHMuJTBBJTIwJTIwJTIwJTIwcmV0dXJuJTIwdGYuZXhwYW5kX2RpbXModGZfaW1hZ2UlMkMlMjAwKSUwQSUwQSUwQWRlZiUyMHByZXByb2Nlc3NfdHJhaW4oZXhhbXBsZV9iYXRjaCklM0ElMEElMjAlMjAlMjAlMjAlMjIlMjIlMjJBcHBseSUyMHRyYWluX3RyYW5zZm9ybXMlMjBhY3Jvc3MlMjBhJTIwYmF0Y2guJTIyJTIyJTIyJTBBJTIwJTIwJTIwJTIwaW1hZ2VzJTIwJTNEJTIwJTVCJTBBJTIwJTIwJTIwJTIwJTIwJTIwJTIwJTIwdHJhaW5fZGF0YV9hdWdtZW50YXRpb24oY29udmVydF90b190Zl90ZW5zb3IoaW1hZ2UuY29udmVydCglMjJSR0IlMjIpKSklMjBmb3IlMjBpbWFnZSUyMGluJTIwZXhhbXBsZV9iYXRjaCU1QiUyMmltYWdlJTIyJTVEJTBBJTIwJTIwJTIwJTIwJTVEJTBBJTIwJTIwJTIwJTIwZXhhbXBsZV9iYXRjaCU1QiUyMnBpeGVsX3ZhbHVlcyUyMiU1RCUyMCUzRCUyMCU1QnRmLnRyYW5zcG9zZSh0Zi5zcXVlZXplKGltYWdlKSklMjBmb3IlMjBpbWFnZSUyMGluJTIwaW1hZ2VzJTVEJTBBJTIwJTIwJTIwJTIwcmV0dXJuJTIwZXhhbXBsZV9iYXRjaCUwQSUwQSUwQWRlZiUyMHByZXByb2Nlc3NfdmFsKGV4YW1wbGVfYmF0Y2gpJTNBJTBBJTIwJTIwJTIwJTIwJTIyJTIyJTIyQXBwbHklMjB2YWxfdHJhbnNmb3JtcyUyMGFjcm9zcyUyMGElMjBiYXRjaC4lMjIlMjIlMjIlMEElMjAlMjAlMjAlMjBpbWFnZXMlMjAlM0QlMjAlNUIlMEElMjAlMjAlMjAlMjAlMjAlMjAlMjAlMjB2YWxfZGF0YV9hdWdtZW50YXRpb24oY29udmVydF90b190Zl90ZW5zb3IoaW1hZ2UuY29udmVydCglMjJSR0IlMjIpKSklMjBmb3IlMjBpbWFnZSUyMGluJTIwZXhhbXBsZV9iYXRjaCU1QiUyMmltYWdlJTIyJTVEJTBBJTIwJTIwJTIwJTIwJTVEJTBBJTIwJTIwJTIwJTIwZXhhbXBsZV9iYXRjaCU1QiUyMnBpeGVsX3ZhbHVlcyUyMiU1RCUyMCUzRCUyMCU1QnRmLnRyYW5zcG9zZSh0Zi5zcXVlZXplKGltYWdlKSklMjBmb3IlMjBpbWFnZSUyMGluJTIwaW1hZ2VzJTVEJTBBJTIwJTIwJTIwJTIwcmV0dXJuJTIwZXhhbXBsZV9iYXRjaA==",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> tensorflow <span class="hljs-keyword">as</span> tf
<span class="hljs-meta">&gt;&gt;&gt; </span><span class="hljs-keyword">from</span> PIL <span class="hljs-keyword">import</span> Image


<span class="hljs-meta">&gt;&gt;&gt; </span><span class="hljs-keyword">def</span> <span class="hljs-title function_">convert_to_tf_tensor</span>(<span class="hljs-params">image: Image</span>):
<span class="hljs-meta">... </span>    np_image = np.array(image)
<span class="hljs-meta">... </span>    tf_image = tf.convert_to_tensor(np_image)
<span class="hljs-meta">... </span>    <span class="hljs-comment"># \`expand_dims()\` is used to add a batch dimension since</span>
<span class="hljs-meta">... </span>    <span class="hljs-comment"># the TF augmentation layers operates on batched inputs.</span>
<span class="hljs-meta">... </span>    <span class="hljs-keyword">return</span> tf.expand_dims(tf_image, <span class="hljs-number">0</span>)


<span class="hljs-meta">&gt;&gt;&gt; </span><span class="hljs-keyword">def</span> <span class="hljs-title function_">preprocess_train</span>(<span class="hljs-params">example_batch</span>):
<span class="hljs-meta">... </span>    <span class="hljs-string">&quot;&quot;&quot;Apply train_transforms across a batch.&quot;&quot;&quot;</span>
<span class="hljs-meta">... </span>    images = [
<span class="hljs-meta">... </span>        train_data_augmentation(convert_to_tf_tensor(image.convert(<span class="hljs-string">&quot;RGB&quot;</span>))) <span class="hljs-keyword">for</span> image <span class="hljs-keyword">in</span> example_batch[<span class="hljs-string">&quot;image&quot;</span>]
<span class="hljs-meta">... </span>    ]
<span class="hljs-meta">... </span>    example_batch[<span class="hljs-string">&quot;pixel_values&quot;</span>] = [tf.transpose(tf.squeeze(image)) <span class="hljs-keyword">for</span> image <span class="hljs-keyword">in</span> images]
<span class="hljs-meta">... </span>    <span class="hljs-keyword">return</span> example_batch


<span class="hljs-meta">... </span><span class="hljs-keyword">def</span> <span class="hljs-title function_">preprocess_val</span>(<span class="hljs-params">example_batch</span>):
<span class="hljs-meta">... </span>    <span class="hljs-string">&quot;&quot;&quot;Apply val_transforms across a batch.&quot;&quot;&quot;</span>
<span class="hljs-meta">... </span>    images = [
<span class="hljs-meta">... </span>        val_data_augmentation(convert_to_tf_tensor(image.convert(<span class="hljs-string">&quot;RGB&quot;</span>))) <span class="hljs-keyword">for</span> image <span class="hljs-keyword">in</span> example_batch[<span class="hljs-string">&quot;image&quot;</span>]
<span class="hljs-meta">... </span>    ]
<span class="hljs-meta">... </span>    example_batch[<span class="hljs-string">&quot;pixel_values&quot;</span>] = [tf.transpose(tf.squeeze(image)) <span class="hljs-keyword">for</span> image <span class="hljs-keyword">in</span> images]
<span class="hljs-meta">... </span>    <span class="hljs-keyword">return</span> example_batch`,wrap:!1}}),$=new W({props:{code:"Zm9vZCU1QiUyMnRyYWluJTIyJTVELnNldF90cmFuc2Zvcm0ocHJlcHJvY2Vzc190cmFpbiklMEFmb29kJTVCJTIydGVzdCUyMiU1RC5zZXRfdHJhbnNmb3JtKHByZXByb2Nlc3NfdmFsKQ==",highlighted:`food[<span class="hljs-string">&quot;train&quot;</span>].set_transform(preprocess_train)
food[<span class="hljs-string">&quot;test&quot;</span>].set_transform(preprocess_val)`,wrap:!1}}),G=new W({props:{code:"ZnJvbSUyMHRyYW5zZm9ybWVycyUyMGltcG9ydCUyMERlZmF1bHREYXRhQ29sbGF0b3IlMEElMEFkYXRhX2NvbGxhdG9yJTIwJTNEJTIwRGVmYXVsdERhdGFDb2xsYXRvcihyZXR1cm5fdGVuc29ycyUzRCUyMnRmJTIyKQ==",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>)`,wrap:!1}}),{c(){t=J("p"),t.innerHTML=h,l=i(),u(c.$$.fragment),w=i(),C=J("p"),C.textContent=Y,k=i(),u(Z.$$.fragment),F=i(),I=J("p"),I.innerHTML=R,V=i(),u($.$$.fragment),x=i(),o=J("p"),o.innerHTML=U,z=i(),u(G.$$.fragment)},l(p){t=T(p,"P",{"data-svelte-h":!0}),_(t)!=="svelte-134vg0e"&&(t.innerHTML=h),l=m(p),d(c.$$.fragment,p),w=m(p),C=T(p,"P",{"data-svelte-h":!0}),_(C)!=="svelte-kdpfis"&&(C.textContent=Y),k=m(p),d(Z.$$.fragment,p),F=m(p),I=T(p,"P",{"data-svelte-h":!0}),_(I)!=="svelte-1v4gef0"&&(I.innerHTML=R),V=m(p),d($.$$.fragment,p),x=m(p),o=T(p,"P",{"data-svelte-h":!0}),_(o)!=="svelte-j9ih75"&&(o.innerHTML=U),z=m(p),d(G.$$.fragment,p)},m(p,j){a(p,t,j),a(p,l,j),y(c,p,j),a(p,w,j),a(p,C,j),a(p,k,j),y(Z,p,j),a(p,F,j),a(p,I,j),a(p,V,j),y($,p,j),a(p,x,j),a(p,o,j),a(p,z,j),y(G,p,j),N=!0},p:hs,i(p){N||(g(c.$$.fragment,p),g(Z.$$.fragment,p),g($.$$.fragment,p),g(G.$$.fragment,p),N=!0)},o(p){M(c.$$.fragment,p),M(Z.$$.fragment,p),M($.$$.fragment,p),M(G.$$.fragment,p),N=!1},d(p){p&&(e(t),e(l),e(w),e(C),e(k),e(F),e(I),e(V),e(x),e(o),e(z)),b(c,p),b(Z,p),b($,p),b(G,p)}}}function ia(X){let t,h;return t=new Bs({props:{$$slots:{default:[ra]},$$scope:{ctx:X}}}),{c(){u(t.$$.fragment)},l(l){d(t.$$.fragment,l)},m(l,c){y(t,l,c),h=!0},p(l,c){const w={};c&2&&(w.$$scope={dirty:c,ctx:l}),t.$set(w)},i(l){h||(g(t.$$.fragment,l),h=!0)},o(l){M(t.$$.fragment,l),h=!1},d(l){b(t,l)}}}function ma(X){let t,h='If you aren’t familiar with finetuning a model with the <a href="/docs/transformers/main/en/main_classes/trainer#transformers.Trainer">Trainer</a>, take a look at the basic tutorial <a href="../training#train-with-pytorch-trainer">here</a>!';return{c(){t=J("p"),t.innerHTML=h},l(l){t=T(l,"P",{"data-svelte-h":!0}),_(t)!=="svelte-15s4um0"&&(t.innerHTML=h)},m(l,c){a(l,t,c)},p:hs,d(l){l&&e(t)}}}function ca(X){let t,h,l,c='You’re ready to start training your model now! Load ViT with <a href="/docs/transformers/main/en/model_doc/auto#transformers.AutoModelForImageClassification">AutoModelForImageClassification</a>. Specify the number of labels along with the number of expected labels, and the label mappings:',w,C,Y,k,Z="At this point, only three steps remain:",F,I,R='<li>Define your training hyperparameters in <a href="/docs/transformers/main/en/main_classes/trainer#transformers.TrainingArguments">TrainingArguments</a>. It is important you don’t remove unused columns because that’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/main/en/main_classes/trainer#transformers.Trainer">Trainer</a> will evaluate the accuracy and save the training checkpoint.</li> <li>Pass the training arguments to <a href="/docs/transformers/main/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/main/en/main_classes/trainer#transformers.Trainer.train">train()</a> to finetune your model.</li>',V,$,x,o,U='Once training is completed, share your model to the Hub with the <a href="/docs/transformers/main/en/main_classes/trainer#transformers.Trainer.push_to_hub">push_to_hub()</a> method so everyone can use your model:',z,G,N;return t=new $e({props:{$$slots:{default:[ma]},$$scope:{ctx:X}}}),C=new W({props:{code:"ZnJvbSUyMHRyYW5zZm9ybWVycyUyMGltcG9ydCUyMEF1dG9Nb2RlbEZvckltYWdlQ2xhc3NpZmljYXRpb24lMkMlMjBUcmFpbmluZ0FyZ3VtZW50cyUyQyUyMFRyYWluZXIlMEElMEFtb2RlbCUyMCUzRCUyMEF1dG9Nb2RlbEZvckltYWdlQ2xhc3NpZmljYXRpb24uZnJvbV9wcmV0cmFpbmVkKCUwQSUyMCUyMCUyMCUyMGNoZWNrcG9pbnQlMkMlMEElMjAlMjAlMjAlMjBudW1fbGFiZWxzJTNEbGVuKGxhYmVscyklMkMlMEElMjAlMjAlMjAlMjBpZDJsYWJlbCUzRGlkMmxhYmVsJTJDJTBBJTIwJTIwJTIwJTIwbGFiZWwyaWQlM0RsYWJlbDJpZCUyQyUwQSk=",highlighted:`<span class="hljs-meta">&gt;&gt;&gt; </span><span class="hljs-keyword">from</span> transformers <span class="hljs-keyword">import</span> AutoModelForImageClassification, TrainingArguments, Trainer

<span class="hljs-meta">&gt;&gt;&gt; </span>model = AutoModelForImageClassification.from_pretrained(
<span class="hljs-meta">... </span>    checkpoint,
<span class="hljs-meta">... </span>    num_labels=<span class="hljs-built_in">len</span>(labels),
<span class="hljs-meta">... </span>    id2label=id2label,
<span class="hljs-meta">... </span>    label2id=label2id,
<span class="hljs-meta">... </span>)`,wrap:!1}}),$=new W({props:{code:"dHJhaW5pbmdfYXJncyUyMCUzRCUyMFRyYWluaW5nQXJndW1lbnRzKCUwQSUyMCUyMCUyMCUyMG91dHB1dF9kaXIlM0QlMjJteV9hd2Vzb21lX2Zvb2RfbW9kZWwlMjIlMkMlMEElMjAlMjAlMjAlMjByZW1vdmVfdW51c2VkX2NvbHVtbnMlM0RGYWxzZSUyQyUwQSUyMCUyMCUyMCUyMGV2YWx1YXRpb25fc3RyYXRlZ3klM0QlMjJlcG9jaCUyMiUyQyUwQSUyMCUyMCUyMCUyMHNhdmVfc3RyYXRlZ3klM0QlMjJlcG9jaCUyMiUyQyUwQSUyMCUyMCUyMCUyMGxlYXJuaW5nX3JhdGUlM0Q1ZS01JTJDJTBBJTIwJTIwJTIwJTIwcGVyX2RldmljZV90cmFpbl9iYXRjaF9zaXplJTNEMTYlMkMlMEElMjAlMjAlMjAlMjBncmFkaWVudF9hY2N1bXVsYXRpb25fc3RlcHMlM0Q0JTJDJTBBJTIwJTIwJTIwJTIwcGVyX2RldmljZV9ldmFsX2JhdGNoX3NpemUlM0QxNiUyQyUwQSUyMCUyMCUyMCUyMG51bV90cmFpbl9lcG9jaHMlM0QzJTJDJTBBJTIwJTIwJTIwJTIwd2FybXVwX3JhdGlvJTNEMC4xJTJDJTBBJTIwJTIwJTIwJTIwbG9nZ2luZ19zdGVwcyUzRDEwJTJDJTBBJTIwJTIwJTIwJTIwbG9hZF9iZXN0X21vZGVsX2F0X2VuZCUzRFRydWUlMkMlMEElMjAlMjAlMjAlMjBtZXRyaWNfZm9yX2Jlc3RfbW9kZWwlM0QlMjJhY2N1cmFjeSUyMiUyQyUwQSUyMCUyMCUyMCUyMHB1c2hfdG9faHViJTNEVHJ1ZSUyQyUwQSklMEElMEF0cmFpbmVyJTIwJTNEJTIwVHJhaW5lciglMEElMjAlMjAlMjAlMjBtb2RlbCUzRG1vZGVsJTJDJTBBJTIwJTIwJTIwJTIwYXJncyUzRHRyYWluaW5nX2FyZ3MlMkMlMEElMjAlMjAlMjAlMjBkYXRhX2NvbGxhdG9yJTNEZGF0YV9jb2xsYXRvciUyQyUwQSUyMCUyMCUyMCUyMHRyYWluX2RhdGFzZXQlM0Rmb29kJTVCJTIydHJhaW4lMjIlNUQlMkMlMEElMjAlMjAlMjAlMjBldmFsX2RhdGFzZXQlM0Rmb29kJTVCJTIydGVzdCUyMiU1RCUyQyUwQSUyMCUyMCUyMCUyMHRva2VuaXplciUzRGltYWdlX3Byb2Nlc3NvciUyQyUwQSUyMCUyMCUyMCUyMGNvbXB1dGVfbWV0cmljcyUzRGNvbXB1dGVfbWV0cmljcyUyQyUwQSklMEElMEF0cmFpbmVyLnRyYWluKCk=",highlighted:`<span class="hljs-meta">&gt;&gt;&gt; </span>training_args = TrainingArguments(
<span class="hljs-meta">... </span>    output_dir=<span class="hljs-string">&quot;my_awesome_food_model&quot;</span>,
<span class="hljs-meta">... </span>    remove_unused_columns=<span class="hljs-literal">False</span>,
<span class="hljs-meta">... </span>    evaluation_strategy=<span class="hljs-string">&quot;epoch&quot;</span>,
<span class="hljs-meta">... </span>    save_strategy=<span class="hljs-string">&quot;epoch&quot;</span>,
<span class="hljs-meta">... </span>    learning_rate=<span class="hljs-number">5e-5</span>,
<span class="hljs-meta">... </span>    per_device_train_batch_size=<span class="hljs-number">16</span>,
<span class="hljs-meta">... </span>    gradient_accumulation_steps=<span class="hljs-number">4</span>,
<span class="hljs-meta">... </span>    per_device_eval_batch_size=<span class="hljs-number">16</span>,
<span class="hljs-meta">... </span>    num_train_epochs=<span class="hljs-number">3</span>,
<span class="hljs-meta">... </span>    warmup_ratio=<span class="hljs-number">0.1</span>,
<span class="hljs-meta">... </span>    logging_steps=<span class="hljs-number">10</span>,
<span class="hljs-meta">... </span>    load_best_model_at_end=<span class="hljs-literal">True</span>,
<span class="hljs-meta">... </span>    metric_for_best_model=<span class="hljs-string">&quot;accuracy&quot;</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>    data_collator=data_collator,
<span class="hljs-meta">... </span>    train_dataset=food[<span class="hljs-string">&quot;train&quot;</span>],
<span class="hljs-meta">... </span>    eval_dataset=food[<span class="hljs-string">&quot;test&quot;</span>],
<span class="hljs-meta">... </span>    tokenizer=image_processor,
<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 W({props:{code:"dHJhaW5lci5wdXNoX3RvX2h1Yigp",highlighted:'<span class="hljs-meta">&gt;&gt;&gt; </span>trainer.push_to_hub()',wrap:!1}}),{c(){u(t.$$.fragment),h=i(),l=J("p"),l.innerHTML=c,w=i(),u(C.$$.fragment),Y=i(),k=J("p"),k.textContent=Z,F=i(),I=J("ol"),I.innerHTML=R,V=i(),u($.$$.fragment),x=i(),o=J("p"),o.innerHTML=U,z=i(),u(G.$$.fragment)},l(p){d(t.$$.fragment,p),h=m(p),l=T(p,"P",{"data-svelte-h":!0}),_(l)!=="svelte-102tc3k"&&(l.innerHTML=c),w=m(p),d(C.$$.fragment,p),Y=m(p),k=T(p,"P",{"data-svelte-h":!0}),_(k)!=="svelte-l42k0i"&&(k.textContent=Z),F=m(p),I=T(p,"OL",{"data-svelte-h":!0}),_(I)!=="svelte-y766lh"&&(I.innerHTML=R),V=m(p),d($.$$.fragment,p),x=m(p),o=T(p,"P",{"data-svelte-h":!0}),_(o)!=="svelte-1v13hlo"&&(o.innerHTML=U),z=m(p),d(G.$$.fragment,p)},m(p,j){y(t,p,j),a(p,h,j),a(p,l,j),a(p,w,j),y(C,p,j),a(p,Y,j),a(p,k,j),a(p,F,j),a(p,I,j),a(p,V,j),y($,p,j),a(p,x,j),a(p,o,j),a(p,z,j),y(G,p,j),N=!0},p(p,j){const E={};j&2&&(E.$$scope={dirty:j,ctx:p}),t.$set(E)},i(p){N||(g(t.$$.fragment,p),g(C.$$.fragment,p),g($.$$.fragment,p),g(G.$$.fragment,p),N=!0)},o(p){M(t.$$.fragment,p),M(C.$$.fragment,p),M($.$$.fragment,p),M(G.$$.fragment,p),N=!1},d(p){p&&(e(h),e(l),e(w),e(Y),e(k),e(F),e(I),e(V),e(x),e(o),e(z)),b(t,p),b(C,p),b($,p),b(G,p)}}}function ha(X){let t,h;return t=new Bs({props:{$$slots:{default:[ca]},$$scope:{ctx:X}}}),{c(){u(t.$$.fragment)},l(l){d(t.$$.fragment,l)},m(l,c){y(t,l,c),h=!0},p(l,c){const w={};c&2&&(w.$$scope={dirty:c,ctx:l}),t.$set(w)},i(l){h||(g(t.$$.fragment,l),h=!0)},o(l){M(t.$$.fragment,l),h=!1},d(l){b(t,l)}}}function fa(X){let t,h='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=J("p"),t.innerHTML=h},l(l){t=T(l,"P",{"data-svelte-h":!0}),_(t)!=="svelte-1egt5s9"&&(t.innerHTML=h)},m(l,c){a(l,t,c)},p:hs,d(l){l&&e(t)}}}function ua(X){let t,h,l,c="To fine-tune a model in TensorFlow, follow these steps:",w,C,Y="<li>Define the training hyperparameters, and set up an optimizer and a learning rate schedule.</li> <li>Instantiate a pre-trained model.</li> <li>Convert a 🤗 Dataset to a <code>tf.data.Dataset</code>.</li> <li>Compile your model.</li> <li>Add callbacks and use the <code>fit()</code> method to run the training.</li> <li>Upload your model to 🤗 Hub to share with the community.</li>",k,Z,F="Start by defining the hyperparameters, optimizer and learning rate schedule:",I,R,V,$,x='Then, load ViT with <a href="/docs/transformers/main/en/model_doc/auto#transformers.TFAutoModelForImageClassification">TFAutoModelForImageClassification</a> along with the label mappings:',o,U,z,G,N='Convert your datasets to the <code>tf.data.Dataset</code> format using the <a href="https://huggingface.co/docs/datasets/main/en/package_reference/main_classes#datasets.Dataset.to_tf_dataset" rel="nofollow">to_tf_dataset</a> and your <code>data_collator</code>:',p,j,E,f,B="Configure the model for training with <code>compile()</code>:",K,H,fs,L,D=`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="../main_classes/keras_callbacks#transformers.KerasMetricCallback">KerasMetricCallback</a>,
and use the <a href="../main_classes/keras_callbacks#transformers.PushToHubCallback">PushToHubCallback</a> to upload the model:`,O,Q,ss,S,Ns=`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:`,es,A,as,q,zs="Congratulations! You have fine-tuned your model and shared it on the 🤗 Hub. You can now use it for inference!",ts;return t=new $e({props:{$$slots:{default:[fa]},$$scope:{ctx:X}}}),R=new W({props:{code:"ZnJvbSUyMHRyYW5zZm9ybWVycyUyMGltcG9ydCUyMGNyZWF0ZV9vcHRpbWl6ZXIlMEElMEFiYXRjaF9zaXplJTIwJTNEJTIwMTYlMEFudW1fZXBvY2hzJTIwJTNEJTIwNSUwQW51bV90cmFpbl9zdGVwcyUyMCUzRCUyMGxlbihmb29kJTVCJTIydHJhaW4lMjIlNUQpJTIwKiUyMG51bV9lcG9jaHMlMEFsZWFybmluZ19yYXRlJTIwJTNEJTIwM2UtNSUwQXdlaWdodF9kZWNheV9yYXRlJTIwJTNEJTIwMC4wMSUwQSUwQW9wdGltaXplciUyQyUyMGxyX3NjaGVkdWxlJTIwJTNEJTIwY3JlYXRlX29wdGltaXplciglMEElMjAlMjAlMjAlMjBpbml0X2xyJTNEbGVhcm5pbmdfcmF0ZSUyQyUwQSUyMCUyMCUyMCUyMG51bV90cmFpbl9zdGVwcyUzRG51bV90cmFpbl9zdGVwcyUyQyUwQSUyMCUyMCUyMCUyMHdlaWdodF9kZWNheV9yYXRlJTNEd2VpZ2h0X2RlY2F5X3JhdGUlMkMlMEElMjAlMjAlMjAlMjBudW1fd2FybXVwX3N0ZXBzJTNEMCUyQyUwQSk=",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">16</span>
<span class="hljs-meta">&gt;&gt;&gt; </span>num_epochs = <span class="hljs-number">5</span>
<span class="hljs-meta">&gt;&gt;&gt; </span>num_train_steps = <span class="hljs-built_in">len</span>(food[<span class="hljs-string">&quot;train&quot;</span>]) * num_epochs
<span class="hljs-meta">&gt;&gt;&gt; </span>learning_rate = <span class="hljs-number">3e-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}}),U=new W({props:{code:"ZnJvbSUyMHRyYW5zZm9ybWVycyUyMGltcG9ydCUyMFRGQXV0b01vZGVsRm9ySW1hZ2VDbGFzc2lmaWNhdGlvbiUwQSUwQW1vZGVsJTIwJTNEJTIwVEZBdXRvTW9kZWxGb3JJbWFnZUNsYXNzaWZpY2F0aW9uLmZyb21fcHJldHJhaW5lZCglMEElMjAlMjAlMjAlMjBjaGVja3BvaW50JTJDJTBBJTIwJTIwJTIwJTIwaWQybGFiZWwlM0RpZDJsYWJlbCUyQyUwQSUyMCUyMCUyMCUyMGxhYmVsMmlkJTNEbGFiZWwyaWQlMkMlMEEp",highlighted:`<span class="hljs-meta">&gt;&gt;&gt; </span><span class="hljs-keyword">from</span> transformers <span class="hljs-keyword">import</span> TFAutoModelForImageClassification

<span class="hljs-meta">&gt;&gt;&gt; </span>model = TFAutoModelForImageClassification.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>)`,wrap:!1}}),j=new W({props:{code:"JTIzJTIwY29udmVydGluZyUyMG91ciUyMHRyYWluJTIwZGF0YXNldCUyMHRvJTIwdGYuZGF0YS5EYXRhc2V0JTBBdGZfdHJhaW5fZGF0YXNldCUyMCUzRCUyMGZvb2QlNUIlMjJ0cmFpbiUyMiU1RC50b190Zl9kYXRhc2V0KCUwQSUyMCUyMCUyMCUyMGNvbHVtbnMlM0QlMjJwaXhlbF92YWx1ZXMlMjIlMkMlMjBsYWJlbF9jb2xzJTNEJTIybGFiZWwlMjIlMkMlMjBzaHVmZmxlJTNEVHJ1ZSUyQyUyMGJhdGNoX3NpemUlM0RiYXRjaF9zaXplJTJDJTIwY29sbGF0ZV9mbiUzRGRhdGFfY29sbGF0b3IlMEEpJTBBJTBBJTIzJTIwY29udmVydGluZyUyMG91ciUyMHRlc3QlMjBkYXRhc2V0JTIwdG8lMjB0Zi5kYXRhLkRhdGFzZXQlMEF0Zl9ldmFsX2RhdGFzZXQlMjAlM0QlMjBmb29kJTVCJTIydGVzdCUyMiU1RC50b190Zl9kYXRhc2V0KCUwQSUyMCUyMCUyMCUyMGNvbHVtbnMlM0QlMjJwaXhlbF92YWx1ZXMlMjIlMkMlMjBsYWJlbF9jb2xzJTNEJTIybGFiZWwlMjIlMkMlMjBzaHVmZmxlJTNEVHJ1ZSUyQyUyMGJhdGNoX3NpemUlM0RiYXRjaF9zaXplJTJDJTIwY29sbGF0ZV9mbiUzRGRhdGFfY29sbGF0b3IlMEEp",highlighted:`<span class="hljs-meta">&gt;&gt;&gt; </span><span class="hljs-comment"># converting our train dataset to tf.data.Dataset</span>
<span class="hljs-meta">&gt;&gt;&gt; </span>tf_train_dataset = food[<span class="hljs-string">&quot;train&quot;</span>].to_tf_dataset(
<span class="hljs-meta">... </span>    columns=<span class="hljs-string">&quot;pixel_values&quot;</span>, label_cols=<span class="hljs-string">&quot;label&quot;</span>, shuffle=<span class="hljs-literal">True</span>, batch_size=batch_size, collate_fn=data_collator
<span class="hljs-meta">... </span>)

<span class="hljs-meta">&gt;&gt;&gt; </span><span class="hljs-comment"># converting our test dataset to tf.data.Dataset</span>
<span class="hljs-meta">&gt;&gt;&gt; </span>tf_eval_dataset = food[<span class="hljs-string">&quot;test&quot;</span>].to_tf_dataset(
<span class="hljs-meta">... </span>    columns=<span class="hljs-string">&quot;pixel_values&quot;</span>, label_cols=<span class="hljs-string">&quot;label&quot;</span>, shuffle=<span class="hljs-literal">True</span>, batch_size=batch_size, collate_fn=data_collator
<span class="hljs-meta">... </span>)`,wrap:!1}}),H=new W({props:{code:"ZnJvbSUyMHRlbnNvcmZsb3cua2VyYXMubG9zc2VzJTIwaW1wb3J0JTIwU3BhcnNlQ2F0ZWdvcmljYWxDcm9zc2VudHJvcHklMEElMEFsb3NzJTIwJTNEJTIwdGYua2VyYXMubG9zc2VzLlNwYXJzZUNhdGVnb3JpY2FsQ3Jvc3NlbnRyb3B5KGZyb21fbG9naXRzJTNEVHJ1ZSklMEFtb2RlbC5jb21waWxlKG9wdGltaXplciUzRG9wdGltaXplciUyQyUyMGxvc3MlM0Rsb3NzKQ==",highlighted:`<span class="hljs-meta">&gt;&gt;&gt; </span><span class="hljs-keyword">from</span> tensorflow.keras.losses <span class="hljs-keyword">import</span> SparseCategoricalCrossentropy

<span class="hljs-meta">&gt;&gt;&gt; </span>loss = tf.keras.losses.SparseCategoricalCrossentropy(from_logits=<span class="hljs-literal">True</span>)
<span class="hljs-meta">&gt;&gt;&gt; </span>model.<span class="hljs-built_in">compile</span>(optimizer=optimizer, loss=loss)`,wrap:!1}}),Q=new W({props:{code:"ZnJvbSUyMHRyYW5zZm9ybWVycy5rZXJhc19jYWxsYmFja3MlMjBpbXBvcnQlMjBLZXJhc01ldHJpY0NhbGxiYWNrJTJDJTIwUHVzaFRvSHViQ2FsbGJhY2slMEElMEFtZXRyaWNfY2FsbGJhY2slMjAlM0QlMjBLZXJhc01ldHJpY0NhbGxiYWNrKG1ldHJpY19mbiUzRGNvbXB1dGVfbWV0cmljcyUyQyUyMGV2YWxfZGF0YXNldCUzRHRmX2V2YWxfZGF0YXNldCklMEFwdXNoX3RvX2h1Yl9jYWxsYmFjayUyMCUzRCUyMFB1c2hUb0h1YkNhbGxiYWNrKCUwQSUyMCUyMCUyMCUyMG91dHB1dF9kaXIlM0QlMjJmb29kX2NsYXNzaWZpZXIlMjIlMkMlMEElMjAlMjAlMjAlMjB0b2tlbml6ZXIlM0RpbWFnZV9wcm9jZXNzb3IlMkMlMEElMjAlMjAlMjAlMjBzYXZlX3N0cmF0ZWd5JTNEJTIybm8lMjIlMkMlMEEpJTBBY2FsbGJhY2tzJTIwJTNEJTIwJTVCbWV0cmljX2NhbGxiYWNrJTJDJTIwcHVzaF90b19odWJfY2FsbGJhY2slNUQ=",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(metric_fn=compute_metrics, eval_dataset=tf_eval_dataset)
<span class="hljs-meta">&gt;&gt;&gt; </span>push_to_hub_callback = PushToHubCallback(
<span class="hljs-meta">... </span>    output_dir=<span class="hljs-string">&quot;food_classifier&quot;</span>,
<span class="hljs-meta">... </span>    tokenizer=image_processor,
<span class="hljs-meta">... </span>    save_strategy=<span class="hljs-string">&quot;no&quot;</span>,
<span class="hljs-meta">... </span>)
<span class="hljs-meta">&gt;&gt;&gt; </span>callbacks = [metric_callback, push_to_hub_callback]`,wrap:!1}}),A=new W({props:{code:"bW9kZWwuZml0KHRmX3RyYWluX2RhdGFzZXQlMkMlMjB2YWxpZGF0aW9uX2RhdGElM0R0Zl9ldmFsX2RhdGFzZXQlMkMlMjBlcG9jaHMlM0RudW1fZXBvY2hzJTJDJTIwY2FsbGJhY2tzJTNEY2FsbGJhY2tzKQ==",highlighted:`<span class="hljs-meta">&gt;&gt;&gt; </span>model.fit(tf_train_dataset, validation_data=tf_eval_dataset, epochs=num_epochs, callbacks=callbacks)
Epoch <span class="hljs-number">1</span>/<span class="hljs-number">5</span>
<span class="hljs-number">250</span>/<span class="hljs-number">250</span> [==============================] - 313s 1s/step - loss: <span class="hljs-number">2.5623</span> - val_loss: <span class="hljs-number">1.4161</span> - accuracy: <span class="hljs-number">0.9290</span>
Epoch <span class="hljs-number">2</span>/<span class="hljs-number">5</span>
<span class="hljs-number">250</span>/<span class="hljs-number">250</span> [==============================] - 265s 1s/step - loss: <span class="hljs-number">0.9181</span> - val_loss: <span class="hljs-number">0.6808</span> - accuracy: <span class="hljs-number">0.9690</span>
Epoch <span class="hljs-number">3</span>/<span class="hljs-number">5</span>
<span class="hljs-number">250</span>/<span class="hljs-number">250</span> [==============================] - 252s 1s/step - loss: <span class="hljs-number">0.3910</span> - val_loss: <span class="hljs-number">0.4303</span> - accuracy: <span class="hljs-number">0.9820</span>
Epoch <span class="hljs-number">4</span>/<span class="hljs-number">5</span>
<span class="hljs-number">250</span>/<span class="hljs-number">250</span> [==============================] - 251s 1s/step - loss: <span class="hljs-number">0.2028</span> - val_loss: <span class="hljs-number">0.3191</span> - accuracy: <span class="hljs-number">0.9900</span>
Epoch <span class="hljs-number">5</span>/<span class="hljs-number">5</span>
<span class="hljs-number">250</span>/<span class="hljs-number">250</span> [==============================] - 238s 949ms/step - loss: <span class="hljs-number">0.1232</span> - val_loss: <span class="hljs-number">0.3259</span> - accuracy: <span class="hljs-number">0.9890</span>`,wrap:!1}}),{c(){u(t.$$.fragment),h=i(),l=J("p"),l.textContent=c,w=i(),C=J("ol"),C.innerHTML=Y,k=i(),Z=J("p"),Z.textContent=F,I=i(),u(R.$$.fragment),V=i(),$=J("p"),$.innerHTML=x,o=i(),u(U.$$.fragment),z=i(),G=J("p"),G.innerHTML=N,p=i(),u(j.$$.fragment),E=i(),f=J("p"),f.innerHTML=B,K=i(),u(H.$$.fragment),fs=i(),L=J("p"),L.innerHTML=D,O=i(),u(Q.$$.fragment),ss=i(),S=J("p"),S.innerHTML=Ns,es=i(),u(A.$$.fragment),as=i(),q=J("p"),q.textContent=zs},l(r){d(t.$$.fragment,r),h=m(r),l=T(r,"P",{"data-svelte-h":!0}),_(l)!=="svelte-s07fxj"&&(l.textContent=c),w=m(r),C=T(r,"OL",{"data-svelte-h":!0}),_(C)!=="svelte-1psiqa4"&&(C.innerHTML=Y),k=m(r),Z=T(r,"P",{"data-svelte-h":!0}),_(Z)!=="svelte-ccl3wn"&&(Z.textContent=F),I=m(r),d(R.$$.fragment,r),V=m(r),$=T(r,"P",{"data-svelte-h":!0}),_($)!=="svelte-tsyk51"&&($.innerHTML=x),o=m(r),d(U.$$.fragment,r),z=m(r),G=T(r,"P",{"data-svelte-h":!0}),_(G)!=="svelte-ca31ls"&&(G.innerHTML=N),p=m(r),d(j.$$.fragment,r),E=m(r),f=T(r,"P",{"data-svelte-h":!0}),_(f)!=="svelte-fhefbq"&&(f.innerHTML=B),K=m(r),d(H.$$.fragment,r),fs=m(r),L=T(r,"P",{"data-svelte-h":!0}),_(L)!=="svelte-887qtl"&&(L.innerHTML=D),O=m(r),d(Q.$$.fragment,r),ss=m(r),S=T(r,"P",{"data-svelte-h":!0}),_(S)!=="svelte-1occr1z"&&(S.innerHTML=Ns),es=m(r),d(A.$$.fragment,r),as=m(r),q=T(r,"P",{"data-svelte-h":!0}),_(q)!=="svelte-1r99pbn"&&(q.textContent=zs)},m(r,v){y(t,r,v),a(r,h,v),a(r,l,v),a(r,w,v),a(r,C,v),a(r,k,v),a(r,Z,v),a(r,I,v),y(R,r,v),a(r,V,v),a(r,$,v),a(r,o,v),y(U,r,v),a(r,z,v),a(r,G,v),a(r,p,v),y(j,r,v),a(r,E,v),a(r,f,v),a(r,K,v),y(H,r,v),a(r,fs,v),a(r,L,v),a(r,O,v),y(Q,r,v),a(r,ss,v),a(r,S,v),a(r,es,v),y(A,r,v),a(r,as,v),a(r,q,v),ts=!0},p(r,v){const P={};v&2&&(P.$$scope={dirty:v,ctx:r}),t.$set(P)},i(r){ts||(g(t.$$.fragment,r),g(R.$$.fragment,r),g(U.$$.fragment,r),g(j.$$.fragment,r),g(H.$$.fragment,r),g(Q.$$.fragment,r),g(A.$$.fragment,r),ts=!0)},o(r){M(t.$$.fragment,r),M(R.$$.fragment,r),M(U.$$.fragment,r),M(j.$$.fragment,r),M(H.$$.fragment,r),M(Q.$$.fragment,r),M(A.$$.fragment,r),ts=!1},d(r){r&&(e(h),e(l),e(w),e(C),e(k),e(Z),e(I),e(V),e($),e(o),e(z),e(G),e(p),e(E),e(f),e(K),e(fs),e(L),e(O),e(ss),e(S),e(es),e(as),e(q)),b(t,r),b(R,r),b(U,r),b(j,r),b(H,r),b(Q,r),b(A,r)}}}function da(X){let t,h;return t=new Bs({props:{$$slots:{default:[ua]},$$scope:{ctx:X}}}),{c(){u(t.$$.fragment)},l(l){d(t.$$.fragment,l)},m(l,c){y(t,l,c),h=!0},p(l,c){const w={};c&2&&(w.$$scope={dirty:c,ctx:l}),t.$set(w)},i(l){h||(g(t.$$.fragment,l),h=!0)},o(l){M(t.$$.fragment,l),h=!1},d(l){b(t,l)}}}function ya(X){let t,h='For a more in-depth example of how to finetune a model for image classification, take a look at the corresponding <a href="https://colab.research.google.com/github/huggingface/notebooks/blob/main/examples/image_classification.ipynb" rel="nofollow">PyTorch notebook</a>.';return{c(){t=J("p"),t.innerHTML=h},l(l){t=T(l,"P",{"data-svelte-h":!0}),_(t)!=="svelte-1gyicmz"&&(t.innerHTML=h)},m(l,c){a(l,t,c)},p:hs,d(l){l&&e(t)}}}function ga(X){let t,h="Load an image processor to preprocess the image and return the <code>input</code> as PyTorch tensors:",l,c,w,C,Y="Pass your inputs to the model and return the logits:",k,Z,F,I,R="Get the predicted label with the highest probability, and use the model’s <code>id2label</code> mapping to convert it to a label:",V,$,x;return c=new W({props:{code:"ZnJvbSUyMHRyYW5zZm9ybWVycyUyMGltcG9ydCUyMEF1dG9JbWFnZVByb2Nlc3NvciUwQWltcG9ydCUyMHRvcmNoJTBBJTBBaW1hZ2VfcHJvY2Vzc29yJTIwJTNEJTIwQXV0b0ltYWdlUHJvY2Vzc29yLmZyb21fcHJldHJhaW5lZCglMjJteV9hd2Vzb21lX2Zvb2RfbW9kZWwlMjIpJTBBaW5wdXRzJTIwJTNEJTIwaW1hZ2VfcHJvY2Vzc29yKGltYWdlJTJDJTIwcmV0dXJuX3RlbnNvcnMlM0QlMjJwdCUyMik=",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><span class="hljs-keyword">import</span> torch

<span class="hljs-meta">&gt;&gt;&gt; </span>image_processor = AutoImageProcessor.from_pretrained(<span class="hljs-string">&quot;my_awesome_food_model&quot;</span>)
<span class="hljs-meta">&gt;&gt;&gt; </span>inputs = image_processor(image, return_tensors=<span class="hljs-string">&quot;pt&quot;</span>)`,wrap:!1}}),Z=new W({props:{code:"ZnJvbSUyMHRyYW5zZm9ybWVycyUyMGltcG9ydCUyMEF1dG9Nb2RlbEZvckltYWdlQ2xhc3NpZmljYXRpb24lMEElMEFtb2RlbCUyMCUzRCUyMEF1dG9Nb2RlbEZvckltYWdlQ2xhc3NpZmljYXRpb24uZnJvbV9wcmV0cmFpbmVkKCUyMm15X2F3ZXNvbWVfZm9vZF9tb2RlbCUyMiklMEF3aXRoJTIwdG9yY2gubm9fZ3JhZCgpJTNBJTBBJTIwJTIwJTIwJTIwbG9naXRzJTIwJTNEJTIwbW9kZWwoKippbnB1dHMpLmxvZ2l0cw==",highlighted:`<span class="hljs-meta">&gt;&gt;&gt; </span><span class="hljs-keyword">from</span> transformers <span class="hljs-keyword">import</span> AutoModelForImageClassification

<span class="hljs-meta">&gt;&gt;&gt; </span>model = AutoModelForImageClassification.from_pretrained(<span class="hljs-string">&quot;my_awesome_food_model&quot;</span>)
<span class="hljs-meta">&gt;&gt;&gt; </span><span class="hljs-keyword">with</span> torch.no_grad():
<span class="hljs-meta">... </span>    logits = model(**inputs).logits`,wrap:!1}}),$=new W({props:{code:"cHJlZGljdGVkX2xhYmVsJTIwJTNEJTIwbG9naXRzLmFyZ21heCgtMSkuaXRlbSgpJTBBbW9kZWwuY29uZmlnLmlkMmxhYmVsJTVCcHJlZGljdGVkX2xhYmVsJTVE",highlighted:`<span class="hljs-meta">&gt;&gt;&gt; </span>predicted_label = logits.argmax(-<span class="hljs-number">1</span>).item()
<span class="hljs-meta">&gt;&gt;&gt; </span>model.config.id2label[predicted_label]
<span class="hljs-string">&#x27;beignets&#x27;</span>`,wrap:!1}}),{c(){t=J("p"),t.innerHTML=h,l=i(),u(c.$$.fragment),w=i(),C=J("p"),C.textContent=Y,k=i(),u(Z.$$.fragment),F=i(),I=J("p"),I.innerHTML=R,V=i(),u($.$$.fragment)},l(o){t=T(o,"P",{"data-svelte-h":!0}),_(t)!=="svelte-65kh0h"&&(t.innerHTML=h),l=m(o),d(c.$$.fragment,o),w=m(o),C=T(o,"P",{"data-svelte-h":!0}),_(C)!=="svelte-1at92g"&&(C.textContent=Y),k=m(o),d(Z.$$.fragment,o),F=m(o),I=T(o,"P",{"data-svelte-h":!0}),_(I)!=="svelte-uvq5m0"&&(I.innerHTML=R),V=m(o),d($.$$.fragment,o)},m(o,U){a(o,t,U),a(o,l,U),y(c,o,U),a(o,w,U),a(o,C,U),a(o,k,U),y(Z,o,U),a(o,F,U),a(o,I,U),a(o,V,U),y($,o,U),x=!0},p:hs,i(o){x||(g(c.$$.fragment,o),g(Z.$$.fragment,o),g($.$$.fragment,o),x=!0)},o(o){M(c.$$.fragment,o),M(Z.$$.fragment,o),M($.$$.fragment,o),x=!1},d(o){o&&(e(t),e(l),e(w),e(C),e(k),e(F),e(I),e(V)),b(c,o),b(Z,o),b($,o)}}}function Ma(X){let t,h;return t=new Bs({props:{$$slots:{default:[ga]},$$scope:{ctx:X}}}),{c(){u(t.$$.fragment)},l(l){d(t.$$.fragment,l)},m(l,c){y(t,l,c),h=!0},p(l,c){const w={};c&2&&(w.$$scope={dirty:c,ctx:l}),t.$set(w)},i(l){h||(g(t.$$.fragment,l),h=!0)},o(l){M(t.$$.fragment,l),h=!1},d(l){b(t,l)}}}function ba(X){let t,h="Load an image processor to preprocess the image and return the <code>input</code> as TensorFlow tensors:",l,c,w,C,Y="Pass your inputs to the model and return the logits:",k,Z,F,I,R="Get the predicted label with the highest probability, and use the model’s <code>id2label</code> mapping to convert it to a label:",V,$,x;return c=new W({props:{code:"ZnJvbSUyMHRyYW5zZm9ybWVycyUyMGltcG9ydCUyMEF1dG9JbWFnZVByb2Nlc3NvciUwQSUwQWltYWdlX3Byb2Nlc3NvciUyMCUzRCUyMEF1dG9JbWFnZVByb2Nlc3Nvci5mcm9tX3ByZXRyYWluZWQoJTIyTWFyaWFLJTJGZm9vZF9jbGFzc2lmaWVyJTIyKSUwQWlucHV0cyUyMCUzRCUyMGltYWdlX3Byb2Nlc3NvcihpbWFnZSUyQyUyMHJldHVybl90ZW5zb3JzJTNEJTIydGYlMjIp",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/food_classifier&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}}),Z=new W({props:{code:"ZnJvbSUyMHRyYW5zZm9ybWVycyUyMGltcG9ydCUyMFRGQXV0b01vZGVsRm9ySW1hZ2VDbGFzc2lmaWNhdGlvbiUwQSUwQW1vZGVsJTIwJTNEJTIwVEZBdXRvTW9kZWxGb3JJbWFnZUNsYXNzaWZpY2F0aW9uLmZyb21fcHJldHJhaW5lZCglMjJNYXJpYUslMkZmb29kX2NsYXNzaWZpZXIlMjIpJTBBbG9naXRzJTIwJTNEJTIwbW9kZWwoKippbnB1dHMpLmxvZ2l0cw==",highlighted:`<span class="hljs-meta">&gt;&gt;&gt; </span><span class="hljs-keyword">from</span> transformers <span class="hljs-keyword">import</span> TFAutoModelForImageClassification

<span class="hljs-meta">&gt;&gt;&gt; </span>model = TFAutoModelForImageClassification.from_pretrained(<span class="hljs-string">&quot;MariaK/food_classifier&quot;</span>)
<span class="hljs-meta">&gt;&gt;&gt; </span>logits = model(**inputs).logits`,wrap:!1}}),$=new W({props:{code:"cHJlZGljdGVkX2NsYXNzX2lkJTIwJTNEJTIwaW50KHRmLm1hdGguYXJnbWF4KGxvZ2l0cyUyQyUyMGF4aXMlM0QtMSklNUIwJTVEKSUwQW1vZGVsLmNvbmZpZy5pZDJsYWJlbCU1QnByZWRpY3RlZF9jbGFzc19pZCU1RA==",highlighted:`<span class="hljs-meta">&gt;&gt;&gt; </span>predicted_class_id = <span class="hljs-built_in">int</span>(tf.math.argmax(logits, axis=-<span class="hljs-number">1</span>)[<span class="hljs-number">0</span>])
<span class="hljs-meta">&gt;&gt;&gt; </span>model.config.id2label[predicted_class_id]
<span class="hljs-string">&#x27;beignets&#x27;</span>`,wrap:!1}}),{c(){t=J("p"),t.innerHTML=h,l=i(),u(c.$$.fragment),w=i(),C=J("p"),C.textContent=Y,k=i(),u(Z.$$.fragment),F=i(),I=J("p"),I.innerHTML=R,V=i(),u($.$$.fragment)},l(o){t=T(o,"P",{"data-svelte-h":!0}),_(t)!=="svelte-1l61n0d"&&(t.innerHTML=h),l=m(o),d(c.$$.fragment,o),w=m(o),C=T(o,"P",{"data-svelte-h":!0}),_(C)!=="svelte-1at92g"&&(C.textContent=Y),k=m(o),d(Z.$$.fragment,o),F=m(o),I=T(o,"P",{"data-svelte-h":!0}),_(I)!=="svelte-uvq5m0"&&(I.innerHTML=R),V=m(o),d($.$$.fragment,o)},m(o,U){a(o,t,U),a(o,l,U),y(c,o,U),a(o,w,U),a(o,C,U),a(o,k,U),y(Z,o,U),a(o,F,U),a(o,I,U),a(o,V,U),y($,o,U),x=!0},p:hs,i(o){x||(g(c.$$.fragment,o),g(Z.$$.fragment,o),g($.$$.fragment,o),x=!0)},o(o){M(c.$$.fragment,o),M(Z.$$.fragment,o),M($.$$.fragment,o),x=!1},d(o){o&&(e(t),e(l),e(w),e(C),e(k),e(F),e(I),e(V)),b(c,o),b(Z,o),b($,o)}}}function ja(X){let t,h;return t=new Bs({props:{$$slots:{default:[ba]},$$scope:{ctx:X}}}),{c(){u(t.$$.fragment)},l(l){d(t.$$.fragment,l)},m(l,c){y(t,l,c),h=!0},p(l,c){const w={};c&2&&(w.$$scope={dirty:c,ctx:l}),t.$set(w)},i(l){h||(g(t.$$.fragment,l),h=!0)},o(l){M(t.$$.fragment,l),h=!1},d(l){b(t,l)}}}function wa(X){let t,h,l,c,w,C,Y,k,Z,F,I,R=`Image classification assigns a label or class to an image. Unlike text or audio classification, the inputs are the
pixel values that comprise an image. There are many applications for image classification, such as detecting damage
after a natural disaster, monitoring crop health, or helping screen medical images for signs of disease.`,V,$,x="This guide illustrates how to:",o,U,z='<li>Fine-tune <a href="model_doc/vit">ViT</a> on the <a href="https://huggingface.co/datasets/food101" rel="nofollow">Food-101</a> dataset to classify a food item in an image.</li> <li>Use your fine-tuned model for inference.</li>',G,N,p,j,E="Before you begin, make sure you have all the necessary libraries installed:",f,B,K,H,fs="We encourage you to log in to your Hugging Face account to upload and share your model with the community. When prompted, enter your token to log in:",L,D,O,Q,ss,S,Ns=`Start by loading a smaller subset of the Food-101 dataset from the 🤗 Datasets library. This will give you a chance to
experiment and make sure everything works before spending more time training on the full dataset.`,es,A,as,q,zs='Split the dataset’s <code>train</code> split into a train and test set with the <a href="https://huggingface.co/docs/datasets/main/en/package_reference/main_classes#datasets.Dataset.train_test_split" rel="nofollow">train_test_split</a> method:',ts,r,v,P,_e="Then take a look at an example:",Hs,us,Qs,ds,Ze="Each example in the dataset has two fields:",Ss,ys,Ce="<li><code>image</code>: a PIL image of the food item</li> <li><code>label</code>: the label class of the food item</li>",As,gs,Ie=`To make it easier for the model to get the label name from the label id, create a dictionary that maps the label name
to an integer and vice versa:`,qs,Ms,Ls,bs,ve="Now you can convert the label id to a label name:",Ds,js,Ps,ws,Ks,Js,ke="The next step is to load a ViT image processor to process the image into a tensor:",Os,Ts,se,ls,ee,ns,ae,$s,te,Us,Ge=`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">accuracy</a> 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):`,le,_s,ne,Zs,We='Then create a function that passes your predictions and labels to <a href="https://huggingface.co/docs/evaluate/main/en/package_reference/main_classes#evaluate.EvaluationModule.compute" rel="nofollow">compute</a> to calculate the accuracy:',pe,Cs,oe,Is,Xe="Your <code>compute_metrics</code> function is ready to go now, and you’ll return to it when you set up your training.",re,vs,ie,ps,me,os,ce,rs,he,ks,fe,Gs,Ve="Great, now that you’ve fine-tuned a model, you can use it for inference!",ue,Ws,Ye="Load an image you’d like to run inference on:",de,Xs,ye,is,Fe='<img src="https://huggingface.co/datasets/huggingface/documentation-images/resolve/main/beignets-task-guide.png" alt="image of beignets"/>',ge,Vs,Re='The simplest way to try out your finetuned model for inference is to use it in a <a href="/docs/transformers/main/en/main_classes/pipelines#transformers.pipeline">pipeline()</a>. Instantiate a <code>pipeline</code> for image classification with your model, and pass your image to it:',Me,Ys,be,Fs,xe="You can also manually replicate the results of the <code>pipeline</code> if you’d like:",je,ms,we,cs,Je,Es,Te;return w=new xs({props:{title:"Image classification",local:"image-classification",headingTag:"h1"}}),Y=new la({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/image_classification.ipynb"},{label:"PyTorch",value:"https://colab.research.google.com/github/huggingface/notebooks/blob/main/transformers_doc/en/pytorch/image_classification.ipynb"},{label:"TensorFlow",value:"https://colab.research.google.com/github/huggingface/notebooks/blob/main/transformers_doc/en/tensorflow/image_classification.ipynb"},{label:"Mixed",value:"https://studiolab.sagemaker.aws/import/github/huggingface/notebooks/blob/main/transformers_doc/en/image_classification.ipynb"},{label:"PyTorch",value:"https://studiolab.sagemaker.aws/import/github/huggingface/notebooks/blob/main/transformers_doc/en/pytorch/image_classification.ipynb"},{label:"TensorFlow",value:"https://studiolab.sagemaker.aws/import/github/huggingface/notebooks/blob/main/transformers_doc/en/tensorflow/image_classification.ipynb"}]}}),Z=new ta({props:{id:"tjAIM7BOYhw"}}),N=new $e({props:{$$slots:{default:[na]},$$scope:{ctx:X}}}),B=new W({props:{code:"cGlwJTIwaW5zdGFsbCUyMHRyYW5zZm9ybWVycyUyMGRhdGFzZXRzJTIwZXZhbHVhdGU=",highlighted:"pip install transformers datasets evaluate",wrap:!1}}),D=new W({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}}),Q=new xs({props:{title:"Load Food-101 dataset",local:"load-food-101-dataset",headingTag:"h2"}}),A=new W({props:{code:"ZnJvbSUyMGRhdGFzZXRzJTIwaW1wb3J0JTIwbG9hZF9kYXRhc2V0JTBBJTBBZm9vZCUyMCUzRCUyMGxvYWRfZGF0YXNldCglMjJmb29kMTAxJTIyJTJDJTIwc3BsaXQlM0QlMjJ0cmFpbiU1QiUzQTUwMDAlNUQlMjIp",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>food = load_dataset(<span class="hljs-string">&quot;food101&quot;</span>, split=<span class="hljs-string">&quot;train[:5000]&quot;</span>)`,wrap:!1}}),r=new W({props:{code:"Zm9vZCUyMCUzRCUyMGZvb2QudHJhaW5fdGVzdF9zcGxpdCh0ZXN0X3NpemUlM0QwLjIp",highlighted:'<span class="hljs-meta">&gt;&gt;&gt; </span>food = food.train_test_split(test_size=<span class="hljs-number">0.2</span>)',wrap:!1}}),us=new W({props:{code:"Zm9vZCU1QiUyMnRyYWluJTIyJTVEJTVCMCU1RA==",highlighted:`<span class="hljs-meta">&gt;&gt;&gt; </span>food[<span class="hljs-string">&quot;train&quot;</span>][<span class="hljs-number">0</span>]
{<span class="hljs-string">&#x27;image&#x27;</span>: &lt;PIL.JpegImagePlugin.JpegImageFile image mode=RGB size=512x512 at <span class="hljs-number">0x7F52AFC8AC50</span>&gt;,
 <span class="hljs-string">&#x27;label&#x27;</span>: <span class="hljs-number">79</span>}`,wrap:!1}}),Ms=new W({props:{code:"bGFiZWxzJTIwJTNEJTIwZm9vZCU1QiUyMnRyYWluJTIyJTVELmZlYXR1cmVzJTVCJTIybGFiZWwlMjIlNUQubmFtZXMlMEFsYWJlbDJpZCUyQyUyMGlkMmxhYmVsJTIwJTNEJTIwZGljdCgpJTJDJTIwZGljdCgpJTBBZm9yJTIwaSUyQyUyMGxhYmVsJTIwaW4lMjBlbnVtZXJhdGUobGFiZWxzKSUzQSUwQSUyMCUyMCUyMCUyMGxhYmVsMmlkJTVCbGFiZWwlNUQlMjAlM0QlMjBzdHIoaSklMEElMjAlMjAlMjAlMjBpZDJsYWJlbCU1QnN0cihpKSU1RCUyMCUzRCUyMGxhYmVs",highlighted:`<span class="hljs-meta">&gt;&gt;&gt; </span>labels = food[<span class="hljs-string">&quot;train&quot;</span>].features[<span class="hljs-string">&quot;label&quot;</span>].names
<span class="hljs-meta">&gt;&gt;&gt; </span>label2id, id2label = <span class="hljs-built_in">dict</span>(), <span class="hljs-built_in">dict</span>()
<span class="hljs-meta">&gt;&gt;&gt; </span><span class="hljs-keyword">for</span> i, label <span class="hljs-keyword">in</span> <span class="hljs-built_in">enumerate</span>(labels):
<span class="hljs-meta">... </span>    label2id[label] = <span class="hljs-built_in">str</span>(i)
<span class="hljs-meta">... </span>    id2label[<span class="hljs-built_in">str</span>(i)] = label`,wrap:!1}}),js=new W({props:{code:"aWQybGFiZWwlNUJzdHIoNzkpJTVE",highlighted:`<span class="hljs-meta">&gt;&gt;&gt; </span>id2label[<span class="hljs-built_in">str</span>(<span class="hljs-number">79</span>)]
<span class="hljs-string">&#x27;prime_rib&#x27;</span>`,wrap:!1}}),ws=new xs({props:{title:"Preprocess",local:"preprocess",headingTag:"h2"}}),Ts=new W({props:{code:"ZnJvbSUyMHRyYW5zZm9ybWVycyUyMGltcG9ydCUyMEF1dG9JbWFnZVByb2Nlc3NvciUwQSUwQWNoZWNrcG9pbnQlMjAlM0QlMjAlMjJnb29nbGUlMkZ2aXQtYmFzZS1wYXRjaDE2LTIyNC1pbjIxayUyMiUwQWltYWdlX3Byb2Nlc3NvciUyMCUzRCUyMEF1dG9JbWFnZVByb2Nlc3Nvci5mcm9tX3ByZXRyYWluZWQoY2hlY2twb2ludCk=",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;google/vit-base-patch16-224-in21k&quot;</span>
<span class="hljs-meta">&gt;&gt;&gt; </span>image_processor = AutoImageProcessor.from_pretrained(checkpoint)`,wrap:!1}}),ls=new Rs({props:{pytorch:!0,tensorflow:!1,jax:!1,$$slots:{pytorch:[oa]},$$scope:{ctx:X}}}),ns=new Rs({props:{pytorch:!1,tensorflow:!0,jax:!1,$$slots:{tensorflow:[ia]},$$scope:{ctx:X}}}),$s=new xs({props:{title:"Evaluate",local:"evaluate",headingTag:"h2"}}),_s=new W({props:{code:"aW1wb3J0JTIwZXZhbHVhdGUlMEElMEFhY2N1cmFjeSUyMCUzRCUyMGV2YWx1YXRlLmxvYWQoJTIyYWNjdXJhY3klMjIp",highlighted:`<span class="hljs-meta">&gt;&gt;&gt; </span><span class="hljs-keyword">import</span> evaluate

<span class="hljs-meta">&gt;&gt;&gt; </span>accuracy = evaluate.load(<span class="hljs-string">&quot;accuracy&quot;</span>)`,wrap:!1}}),Cs=new W({props:{code:"aW1wb3J0JTIwbnVtcHklMjBhcyUyMG5wJTBBJTBBJTBBZGVmJTIwY29tcHV0ZV9tZXRyaWNzKGV2YWxfcHJlZCklM0ElMEElMjAlMjAlMjAlMjBwcmVkaWN0aW9ucyUyQyUyMGxhYmVscyUyMCUzRCUyMGV2YWxfcHJlZCUwQSUyMCUyMCUyMCUyMHByZWRpY3Rpb25zJTIwJTNEJTIwbnAuYXJnbWF4KHByZWRpY3Rpb25zJTJDJTIwYXhpcyUzRDEpJTBBJTIwJTIwJTIwJTIwcmV0dXJuJTIwYWNjdXJhY3kuY29tcHV0ZShwcmVkaWN0aW9ucyUzRHByZWRpY3Rpb25zJTJDJTIwcmVmZXJlbmNlcyUzRGxhYmVscyk=",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">def</span> <span class="hljs-title function_">compute_metrics</span>(<span class="hljs-params">eval_pred</span>):
<span class="hljs-meta">... </span>    predictions, labels = eval_pred
<span class="hljs-meta">... </span>    predictions = np.argmax(predictions, axis=<span class="hljs-number">1</span>)
<span class="hljs-meta">... </span>    <span class="hljs-keyword">return</span> accuracy.compute(predictions=predictions, references=labels)`,wrap:!1}}),vs=new xs({props:{title:"Train",local:"train",headingTag:"h2"}}),ps=new Rs({props:{pytorch:!0,tensorflow:!1,jax:!1,$$slots:{pytorch:[ha]},$$scope:{ctx:X}}}),os=new Rs({props:{pytorch:!1,tensorflow:!0,jax:!1,$$slots:{tensorflow:[da]},$$scope:{ctx:X}}}),rs=new $e({props:{$$slots:{default:[ya]},$$scope:{ctx:X}}}),ks=new xs({props:{title:"Inference",local:"inference",headingTag:"h2"}}),Xs=new W({props:{code:"ZHMlMjAlM0QlMjBsb2FkX2RhdGFzZXQoJTIyZm9vZDEwMSUyMiUyQyUyMHNwbGl0JTNEJTIydmFsaWRhdGlvbiU1QiUzQTEwJTVEJTIyKSUwQWltYWdlJTIwJTNEJTIwZHMlNUIlMjJpbWFnZSUyMiU1RCU1QjAlNUQ=",highlighted:`<span class="hljs-meta">&gt;&gt;&gt; </span>ds = load_dataset(<span class="hljs-string">&quot;food101&quot;</span>, split=<span class="hljs-string">&quot;validation[:10]&quot;</span>)
<span class="hljs-meta">&gt;&gt;&gt; </span>image = ds[<span class="hljs-string">&quot;image&quot;</span>][<span class="hljs-number">0</span>]`,wrap:!1}}),Ys=new W({props:{code:"ZnJvbSUyMHRyYW5zZm9ybWVycyUyMGltcG9ydCUyMHBpcGVsaW5lJTBBJTBBY2xhc3NpZmllciUyMCUzRCUyMHBpcGVsaW5lKCUyMmltYWdlLWNsYXNzaWZpY2F0aW9uJTIyJTJDJTIwbW9kZWwlM0QlMjJteV9hd2Vzb21lX2Zvb2RfbW9kZWwlMjIpJTBBY2xhc3NpZmllcihpbWFnZSk=",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>classifier = pipeline(<span class="hljs-string">&quot;image-classification&quot;</span>, model=<span class="hljs-string">&quot;my_awesome_food_model&quot;</span>)
<span class="hljs-meta">&gt;&gt;&gt; </span>classifier(image)
[{<span class="hljs-string">&#x27;score&#x27;</span>: <span class="hljs-number">0.31856709718704224</span>, <span class="hljs-string">&#x27;label&#x27;</span>: <span class="hljs-string">&#x27;beignets&#x27;</span>},
 {<span class="hljs-string">&#x27;score&#x27;</span>: <span class="hljs-number">0.015232225880026817</span>, <span class="hljs-string">&#x27;label&#x27;</span>: <span class="hljs-string">&#x27;bruschetta&#x27;</span>},
 {<span class="hljs-string">&#x27;score&#x27;</span>: <span class="hljs-number">0.01519392803311348</span>, <span class="hljs-string">&#x27;label&#x27;</span>: <span class="hljs-string">&#x27;chicken_wings&#x27;</span>},
 {<span class="hljs-string">&#x27;score&#x27;</span>: <span class="hljs-number">0.013022331520915031</span>, <span class="hljs-string">&#x27;label&#x27;</span>: <span class="hljs-string">&#x27;pork_chop&#x27;</span>},
 {<span class="hljs-string">&#x27;score&#x27;</span>: <span class="hljs-number">0.012728818692266941</span>, <span class="hljs-string">&#x27;label&#x27;</span>: <span class="hljs-string">&#x27;prime_rib&#x27;</span>}]`,wrap:!1}}),ms=new Rs({props:{pytorch:!0,tensorflow:!1,jax:!1,$$slots:{pytorch:[Ma]},$$scope:{ctx:X}}}),cs=new Rs({props:{pytorch:!1,tensorflow:!0,jax:!1,$$slots:{tensorflow:[ja]},$$scope:{ctx:X}}}),{c(){t=J("meta"),h=i(),l=J("p"),c=i(),u(w.$$.fragment),C=i(),u(Y.$$.fragment),k=i(),u(Z.$$.fragment),F=i(),I=J("p"),I.textContent=R,V=i(),$=J("p"),$.textContent=x,o=i(),U=J("ol"),U.innerHTML=z,G=i(),u(N.$$.fragment),p=i(),j=J("p"),j.textContent=E,f=i(),u(B.$$.fragment),K=i(),H=J("p"),H.textContent=fs,L=i(),u(D.$$.fragment),O=i(),u(Q.$$.fragment),ss=i(),S=J("p"),S.textContent=Ns,es=i(),u(A.$$.fragment),as=i(),q=J("p"),q.innerHTML=zs,ts=i(),u(r.$$.fragment),v=i(),P=J("p"),P.textContent=_e,Hs=i(),u(us.$$.fragment),Qs=i(),ds=J("p"),ds.textContent=Ze,Ss=i(),ys=J("ul"),ys.innerHTML=Ce,As=i(),gs=J("p"),gs.textContent=Ie,qs=i(),u(Ms.$$.fragment),Ls=i(),bs=J("p"),bs.textContent=ve,Ds=i(),u(js.$$.fragment),Ps=i(),u(ws.$$.fragment),Ks=i(),Js=J("p"),Js.textContent=ke,Os=i(),u(Ts.$$.fragment),se=i(),u(ls.$$.fragment),ee=i(),u(ns.$$.fragment),ae=i(),u($s.$$.fragment),te=i(),Us=J("p"),Us.innerHTML=Ge,le=i(),u(_s.$$.fragment),ne=i(),Zs=J("p"),Zs.innerHTML=We,pe=i(),u(Cs.$$.fragment),oe=i(),Is=J("p"),Is.innerHTML=Xe,re=i(),u(vs.$$.fragment),ie=i(),u(ps.$$.fragment),me=i(),u(os.$$.fragment),ce=i(),u(rs.$$.fragment),he=i(),u(ks.$$.fragment),fe=i(),Gs=J("p"),Gs.textContent=Ve,ue=i(),Ws=J("p"),Ws.textContent=Ye,de=i(),u(Xs.$$.fragment),ye=i(),is=J("div"),is.innerHTML=Fe,ge=i(),Vs=J("p"),Vs.innerHTML=Re,Me=i(),u(Ys.$$.fragment),be=i(),Fs=J("p"),Fs.innerHTML=xe,je=i(),u(ms.$$.fragment),we=i(),u(cs.$$.fragment),Je=i(),Es=J("p"),this.h()},l(s){const n=Oe("svelte-u9bgzb",document.head);t=T(n,"META",{name:!0,content:!0}),n.forEach(e),h=m(s),l=T(s,"P",{}),qe(l).forEach(e),c=m(s),d(w.$$.fragment,s),C=m(s),d(Y.$$.fragment,s),k=m(s),d(Z.$$.fragment,s),F=m(s),I=T(s,"P",{"data-svelte-h":!0}),_(I)!=="svelte-dpadt7"&&(I.textContent=R),V=m(s),$=T(s,"P",{"data-svelte-h":!0}),_($)!=="svelte-ku8orh"&&($.textContent=x),o=m(s),U=T(s,"OL",{"data-svelte-h":!0}),_(U)!=="svelte-1j1nbn7"&&(U.innerHTML=z),G=m(s),d(N.$$.fragment,s),p=m(s),j=T(s,"P",{"data-svelte-h":!0}),_(j)!=="svelte-1c9nexd"&&(j.textContent=E),f=m(s),d(B.$$.fragment,s),K=m(s),H=T(s,"P",{"data-svelte-h":!0}),_(H)!=="svelte-yib87s"&&(H.textContent=fs),L=m(s),d(D.$$.fragment,s),O=m(s),d(Q.$$.fragment,s),ss=m(s),S=T(s,"P",{"data-svelte-h":!0}),_(S)!=="svelte-1cr1dw1"&&(S.textContent=Ns),es=m(s),d(A.$$.fragment,s),as=m(s),q=T(s,"P",{"data-svelte-h":!0}),_(q)!=="svelte-rugbz4"&&(q.innerHTML=zs),ts=m(s),d(r.$$.fragment,s),v=m(s),P=T(s,"P",{"data-svelte-h":!0}),_(P)!=="svelte-1m91ua0"&&(P.textContent=_e),Hs=m(s),d(us.$$.fragment,s),Qs=m(s),ds=T(s,"P",{"data-svelte-h":!0}),_(ds)!=="svelte-w87shu"&&(ds.textContent=Ze),Ss=m(s),ys=T(s,"UL",{"data-svelte-h":!0}),_(ys)!=="svelte-133so41"&&(ys.innerHTML=Ce),As=m(s),gs=T(s,"P",{"data-svelte-h":!0}),_(gs)!=="svelte-1j34ajz"&&(gs.textContent=Ie),qs=m(s),d(Ms.$$.fragment,s),Ls=m(s),bs=T(s,"P",{"data-svelte-h":!0}),_(bs)!=="svelte-1e9n4a3"&&(bs.textContent=ve),Ds=m(s),d(js.$$.fragment,s),Ps=m(s),d(ws.$$.fragment,s),Ks=m(s),Js=T(s,"P",{"data-svelte-h":!0}),_(Js)!=="svelte-25xdfm"&&(Js.textContent=ke),Os=m(s),d(Ts.$$.fragment,s),se=m(s),d(ls.$$.fragment,s),ee=m(s),d(ns.$$.fragment,s),ae=m(s),d($s.$$.fragment,s),te=m(s),Us=T(s,"P",{"data-svelte-h":!0}),_(Us)!=="svelte-1qqtfp"&&(Us.innerHTML=Ge),le=m(s),d(_s.$$.fragment,s),ne=m(s),Zs=T(s,"P",{"data-svelte-h":!0}),_(Zs)!=="svelte-14irt3v"&&(Zs.innerHTML=We),pe=m(s),d(Cs.$$.fragment,s),oe=m(s),Is=T(s,"P",{"data-svelte-h":!0}),_(Is)!=="svelte-44vib3"&&(Is.innerHTML=Xe),re=m(s),d(vs.$$.fragment,s),ie=m(s),d(ps.$$.fragment,s),me=m(s),d(os.$$.fragment,s),ce=m(s),d(rs.$$.fragment,s),he=m(s),d(ks.$$.fragment,s),fe=m(s),Gs=T(s,"P",{"data-svelte-h":!0}),_(Gs)!=="svelte-l3g61e"&&(Gs.textContent=Ve),ue=m(s),Ws=T(s,"P",{"data-svelte-h":!0}),_(Ws)!=="svelte-1jlr7r7"&&(Ws.textContent=Ye),de=m(s),d(Xs.$$.fragment,s),ye=m(s),is=T(s,"DIV",{class:!0,"data-svelte-h":!0}),_(is)!=="svelte-pnh0xy"&&(is.innerHTML=Fe),ge=m(s),Vs=T(s,"P",{"data-svelte-h":!0}),_(Vs)!=="svelte-c2yfcj"&&(Vs.innerHTML=Re),Me=m(s),d(Ys.$$.fragment,s),be=m(s),Fs=T(s,"P",{"data-svelte-h":!0}),_(Fs)!=="svelte-1njl8vm"&&(Fs.innerHTML=xe),je=m(s),d(ms.$$.fragment,s),we=m(s),d(cs.$$.fragment,s),Je=m(s),Es=T(s,"P",{}),qe(Es).forEach(e),this.h()},h(){Ue(t,"name","hf:doc:metadata"),Ue(t,"content",Ja),Ue(is,"class","flex justify-center")},m(s,n){sa(document.head,t),a(s,h,n),a(s,l,n),a(s,c,n),y(w,s,n),a(s,C,n),y(Y,s,n),a(s,k,n),y(Z,s,n),a(s,F,n),a(s,I,n),a(s,V,n),a(s,$,n),a(s,o,n),a(s,U,n),a(s,G,n),y(N,s,n),a(s,p,n),a(s,j,n),a(s,f,n),y(B,s,n),a(s,K,n),a(s,H,n),a(s,L,n),y(D,s,n),a(s,O,n),y(Q,s,n),a(s,ss,n),a(s,S,n),a(s,es,n),y(A,s,n),a(s,as,n),a(s,q,n),a(s,ts,n),y(r,s,n),a(s,v,n),a(s,P,n),a(s,Hs,n),y(us,s,n),a(s,Qs,n),a(s,ds,n),a(s,Ss,n),a(s,ys,n),a(s,As,n),a(s,gs,n),a(s,qs,n),y(Ms,s,n),a(s,Ls,n),a(s,bs,n),a(s,Ds,n),y(js,s,n),a(s,Ps,n),y(ws,s,n),a(s,Ks,n),a(s,Js,n),a(s,Os,n),y(Ts,s,n),a(s,se,n),y(ls,s,n),a(s,ee,n),y(ns,s,n),a(s,ae,n),y($s,s,n),a(s,te,n),a(s,Us,n),a(s,le,n),y(_s,s,n),a(s,ne,n),a(s,Zs,n),a(s,pe,n),y(Cs,s,n),a(s,oe,n),a(s,Is,n),a(s,re,n),y(vs,s,n),a(s,ie,n),y(ps,s,n),a(s,me,n),y(os,s,n),a(s,ce,n),y(rs,s,n),a(s,he,n),y(ks,s,n),a(s,fe,n),a(s,Gs,n),a(s,ue,n),a(s,Ws,n),a(s,de,n),y(Xs,s,n),a(s,ye,n),a(s,is,n),a(s,ge,n),a(s,Vs,n),a(s,Me,n),y(Ys,s,n),a(s,be,n),a(s,Fs,n),a(s,je,n),y(ms,s,n),a(s,we,n),y(cs,s,n),a(s,Je,n),a(s,Es,n),Te=!0},p(s,[n]){const Be={};n&2&&(Be.$$scope={dirty:n,ctx:s}),N.$set(Be);const Ne={};n&2&&(Ne.$$scope={dirty:n,ctx:s}),ls.$set(Ne);const ze={};n&2&&(ze.$$scope={dirty:n,ctx:s}),ns.$set(ze);const Ee={};n&2&&(Ee.$$scope={dirty:n,ctx:s}),ps.$set(Ee);const He={};n&2&&(He.$$scope={dirty:n,ctx:s}),os.$set(He);const Qe={};n&2&&(Qe.$$scope={dirty:n,ctx:s}),rs.$set(Qe);const Se={};n&2&&(Se.$$scope={dirty:n,ctx:s}),ms.$set(Se);const Ae={};n&2&&(Ae.$$scope={dirty:n,ctx:s}),cs.$set(Ae)},i(s){Te||(g(w.$$.fragment,s),g(Y.$$.fragment,s),g(Z.$$.fragment,s),g(N.$$.fragment,s),g(B.$$.fragment,s),g(D.$$.fragment,s),g(Q.$$.fragment,s),g(A.$$.fragment,s),g(r.$$.fragment,s),g(us.$$.fragment,s),g(Ms.$$.fragment,s),g(js.$$.fragment,s),g(ws.$$.fragment,s),g(Ts.$$.fragment,s),g(ls.$$.fragment,s),g(ns.$$.fragment,s),g($s.$$.fragment,s),g(_s.$$.fragment,s),g(Cs.$$.fragment,s),g(vs.$$.fragment,s),g(ps.$$.fragment,s),g(os.$$.fragment,s),g(rs.$$.fragment,s),g(ks.$$.fragment,s),g(Xs.$$.fragment,s),g(Ys.$$.fragment,s),g(ms.$$.fragment,s),g(cs.$$.fragment,s),Te=!0)},o(s){M(w.$$.fragment,s),M(Y.$$.fragment,s),M(Z.$$.fragment,s),M(N.$$.fragment,s),M(B.$$.fragment,s),M(D.$$.fragment,s),M(Q.$$.fragment,s),M(A.$$.fragment,s),M(r.$$.fragment,s),M(us.$$.fragment,s),M(Ms.$$.fragment,s),M(js.$$.fragment,s),M(ws.$$.fragment,s),M(Ts.$$.fragment,s),M(ls.$$.fragment,s),M(ns.$$.fragment,s),M($s.$$.fragment,s),M(_s.$$.fragment,s),M(Cs.$$.fragment,s),M(vs.$$.fragment,s),M(ps.$$.fragment,s),M(os.$$.fragment,s),M(rs.$$.fragment,s),M(ks.$$.fragment,s),M(Xs.$$.fragment,s),M(Ys.$$.fragment,s),M(ms.$$.fragment,s),M(cs.$$.fragment,s),Te=!1},d(s){s&&(e(h),e(l),e(c),e(C),e(k),e(F),e(I),e(V),e($),e(o),e(U),e(G),e(p),e(j),e(f),e(K),e(H),e(L),e(O),e(ss),e(S),e(es),e(as),e(q),e(ts),e(v),e(P),e(Hs),e(Qs),e(ds),e(Ss),e(ys),e(As),e(gs),e(qs),e(Ls),e(bs),e(Ds),e(Ps),e(Ks),e(Js),e(Os),e(se),e(ee),e(ae),e(te),e(Us),e(le),e(ne),e(Zs),e(pe),e(oe),e(Is),e(re),e(ie),e(me),e(ce),e(he),e(fe),e(Gs),e(ue),e(Ws),e(de),e(ye),e(is),e(ge),e(Vs),e(Me),e(be),e(Fs),e(je),e(we),e(Je),e(Es)),e(t),b(w,s),b(Y,s),b(Z,s),b(N,s),b(B,s),b(D,s),b(Q,s),b(A,s),b(r,s),b(us,s),b(Ms,s),b(js,s),b(ws,s),b(Ts,s),b(ls,s),b(ns,s),b($s,s),b(_s,s),b(Cs,s),b(vs,s),b(ps,s),b(os,s),b(rs,s),b(ks,s),b(Xs,s),b(Ys,s),b(ms,s),b(cs,s)}}}const Ja='{"title":"Image classification","local":"image-classification","sections":[{"title":"Load Food-101 dataset","local":"load-food-101-dataset","sections":[],"depth":2},{"title":"Preprocess","local":"preprocess","sections":[],"depth":2},{"title":"Evaluate","local":"evaluate","sections":[],"depth":2},{"title":"Train","local":"train","sections":[],"depth":2},{"title":"Inference","local":"inference","sections":[],"depth":2}],"depth":1}';function Ta(X){return De(()=>{new URLSearchParams(window.location.search).get("fw")}),[]}class Ga extends Pe{constructor(t){super(),Ke(this,t,Ta,wa,Le,{})}}export{Ga as component};
