import{s as Pe,o as Ke,n as hs}from"../chunks/scheduler.9bc65507.js";import{S as Oe,i as sa,g as J,s as r,r as u,A as ea,h as T,f as e,c as i,j as De,u as d,x as _,k as Ze,y as aa,a,v as y,d as M,t as g,w as b,m as ta,n as la}from"../chunks/index.707bf1b6.js";import{T as _e}from"../chunks/Tip.c2ecdbf4.js";import{Y as na}from"../chunks/Youtube.e1129c6f.js";import{C as W}from"../chunks/CodeBlock.54a9f38d.js";import{D as pa}from"../chunks/DocNotebookDropdown.41f65cb5.js";import{F as xs,M as Ns}from"../chunks/Markdown.fef84341.js";import{H as Bs,E as oa}from"../chunks/EditOnGithub.922df6ba.js";function ra(X){let t,h,l='<a href="../model_doc/beit">BEiT</a>, <a href="../model_doc/bit">BiT</a>, <a href="../model_doc/clip">CLIP</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/pvt_v2">PVTv2</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/siglip">SigLIP</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=ta(`The task illustrated in this tutorial is supported by the following model architectures:

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

`),h=T(c,"P",{"data-svelte-h":!0}),_(h)!=="svelte-6o21ol"&&(h.innerHTML=l)},m(c,w){a(c,t,w),a(c,h,w)},p:hs,d(c){c&&(e(t),e(h))}}}function ia(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,R="Then create a preprocessing function to apply the transforms and return the <code>pixel_values</code> - the inputs to the model - of the image:",v,F,V,$,x="To apply the preprocessing function over the entire dataset, use 🤗 Datasets <code>with_transform</code> 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/v4.40.2/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}}),F=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=r(),c=J("p"),c.textContent=w,C=r(),u(Y.$$.fragment),k=r(),Z=J("p"),Z.innerHTML=R,v=r(),u(F.$$.fragment),V=r(),$=J("p"),$.innerHTML=x,o=r(),u(U.$$.fragment),z=r(),G=J("p"),G.innerHTML=N,p=r(),u(j.$$.fragment)},l(f){t=T(f,"P",{"data-svelte-h":!0}),_(t)!=="svelte-1h04qv0"&&(t.innerHTML=h),l=i(f),c=T(f,"P",{"data-svelte-h":!0}),_(c)!=="svelte-1ocztfo"&&(c.textContent=w),C=i(f),d(Y.$$.fragment,f),k=i(f),Z=T(f,"P",{"data-svelte-h":!0}),_(Z)!=="svelte-q25jfj"&&(Z.innerHTML=R),v=i(f),d(F.$$.fragment,f),V=i(f),$=T(f,"P",{"data-svelte-h":!0}),_($)!=="svelte-z8dnte"&&($.innerHTML=x),o=i(f),d(U.$$.fragment,f),z=i(f),G=T(f,"P",{"data-svelte-h":!0}),_(G)!=="svelte-8gag3"&&(G.innerHTML=N),p=i(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,v,B),y(F,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||(M(Y.$$.fragment,f),M(F.$$.fragment,f),M(U.$$.fragment,f),M(j.$$.fragment,f),E=!0)},o(f){g(Y.$$.fragment,f),g(F.$$.fragment,f),g(U.$$.fragment,f),g(j.$$.fragment,f),E=!1},d(f){f&&(e(t),e(l),e(c),e(C),e(k),e(Z),e(v),e(V),e($),e(o),e(z),e(G),e(p)),b(Y,f),b(F,f),b(U,f),b(j,f)}}}function ma(X){let t,h;return t=new Ns({props:{$$slots:{default:[ia]},$$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||(M(t.$$.fragment,l),h=!0)},o(l){g(t.$$.fragment,l),h=!1},d(l){b(t,l)}}}function ca(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,R,v,F="Use 🤗 Datasets <code>set_transform</code> 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=r(),u(c.$$.fragment),w=r(),C=J("p"),C.textContent=Y,k=r(),u(Z.$$.fragment),R=r(),v=J("p"),v.innerHTML=F,V=r(),u($.$$.fragment),x=r(),o=J("p"),o.innerHTML=U,z=r(),u(G.$$.fragment)},l(p){t=T(p,"P",{"data-svelte-h":!0}),_(t)!=="svelte-134vg0e"&&(t.innerHTML=h),l=i(p),d(c.$$.fragment,p),w=i(p),C=T(p,"P",{"data-svelte-h":!0}),_(C)!=="svelte-kdpfis"&&(C.textContent=Y),k=i(p),d(Z.$$.fragment,p),R=i(p),v=T(p,"P",{"data-svelte-h":!0}),_(v)!=="svelte-16cmuvi"&&(v.innerHTML=F),V=i(p),d($.$$.fragment,p),x=i(p),o=T(p,"P",{"data-svelte-h":!0}),_(o)!=="svelte-j9ih75"&&(o.innerHTML=U),z=i(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,R,j),a(p,v,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||(M(c.$$.fragment,p),M(Z.$$.fragment,p),M($.$$.fragment,p),M(G.$$.fragment,p),N=!0)},o(p){g(c.$$.fragment,p),g(Z.$$.fragment,p),g($.$$.fragment,p),g(G.$$.fragment,p),N=!1},d(p){p&&(e(t),e(l),e(w),e(C),e(k),e(R),e(v),e(V),e(x),e(o),e(z)),b(c,p),b(Z,p),b($,p),b(G,p)}}}function ha(X){let t,h;return t=new Ns({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||(M(t.$$.fragment,l),h=!0)},o(l){g(t.$$.fragment,l),h=!1},d(l){b(t,l)}}}function fa(X){let t,h='If you aren’t familiar with finetuning a model with the <a href="/docs/transformers/v4.40.2/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-k4rvf7"&&(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='You’re ready to start training your model now! Load ViT with <a href="/docs/transformers/v4.40.2/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:",R,v,F='<li>Define your training hyperparameters in <a href="/docs/transformers/v4.40.2/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/v4.40.2/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/v4.40.2/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.40.2/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/v4.40.2/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:[fa]},$$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=r(),l=J("p"),l.innerHTML=c,w=r(),u(C.$$.fragment),Y=r(),k=J("p"),k.textContent=Z,R=r(),v=J("ol"),v.innerHTML=F,V=r(),u($.$$.fragment),x=r(),o=J("p"),o.innerHTML=U,z=r(),u(G.$$.fragment)},l(p){d(t.$$.fragment,p),h=i(p),l=T(p,"P",{"data-svelte-h":!0}),_(l)!=="svelte-152gf8j"&&(l.innerHTML=c),w=i(p),d(C.$$.fragment,p),Y=i(p),k=T(p,"P",{"data-svelte-h":!0}),_(k)!=="svelte-l42k0i"&&(k.textContent=Z),R=i(p),v=T(p,"OL",{"data-svelte-h":!0}),_(v)!=="svelte-1kpdobl"&&(v.innerHTML=F),V=i(p),d($.$$.fragment,p),x=i(p),o=T(p,"P",{"data-svelte-h":!0}),_(o)!=="svelte-4h48xz"&&(o.innerHTML=U),z=i(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,R,j),a(p,v,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||(M(t.$$.fragment,p),M(C.$$.fragment,p),M($.$$.fragment,p),M(G.$$.fragment,p),N=!0)},o(p){g(t.$$.fragment,p),g(C.$$.fragment,p),g($.$$.fragment,p),g(G.$$.fragment,p),N=!1},d(p){p&&(e(h),e(l),e(w),e(Y),e(k),e(R),e(v),e(V),e(x),e(o),e(z)),b(t,p),b(C,p),b($,p),b(G,p)}}}function da(X){let t,h;return t=new Ns({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||(M(t.$$.fragment,l),h=!0)},o(l){g(t.$$.fragment,l),h=!1},d(l){b(t,l)}}}function ya(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 Ma(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,R="Start by defining the hyperparameters, optimizer and learning rate schedule:",v,F,V,$,x='Then, load ViT with <a href="/docs/transformers/v4.40.2/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 <code>to_tf_dataset</code> 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,zs=`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,Es="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:[ya]},$$scope:{ctx:X}}}),F=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=r(),l=J("p"),l.textContent=c,w=r(),C=J("ol"),C.innerHTML=Y,k=r(),Z=J("p"),Z.textContent=R,v=r(),u(F.$$.fragment),V=r(),$=J("p"),$.innerHTML=x,o=r(),u(U.$$.fragment),z=r(),G=J("p"),G.innerHTML=N,p=r(),u(j.$$.fragment),E=r(),f=J("p"),f.innerHTML=B,K=r(),u(H.$$.fragment),fs=r(),L=J("p"),L.innerHTML=D,O=r(),u(Q.$$.fragment),ss=r(),S=J("p"),S.innerHTML=zs,es=r(),u(A.$$.fragment),as=r(),q=J("p"),q.textContent=Es},l(m){d(t.$$.fragment,m),h=i(m),l=T(m,"P",{"data-svelte-h":!0}),_(l)!=="svelte-s07fxj"&&(l.textContent=c),w=i(m),C=T(m,"OL",{"data-svelte-h":!0}),_(C)!=="svelte-1psiqa4"&&(C.innerHTML=Y),k=i(m),Z=T(m,"P",{"data-svelte-h":!0}),_(Z)!=="svelte-ccl3wn"&&(Z.textContent=R),v=i(m),d(F.$$.fragment,m),V=i(m),$=T(m,"P",{"data-svelte-h":!0}),_($)!=="svelte-6uoat0"&&($.innerHTML=x),o=i(m),d(U.$$.fragment,m),z=i(m),G=T(m,"P",{"data-svelte-h":!0}),_(G)!=="svelte-myl0l6"&&(G.innerHTML=N),p=i(m),d(j.$$.fragment,m),E=i(m),f=T(m,"P",{"data-svelte-h":!0}),_(f)!=="svelte-fhefbq"&&(f.innerHTML=B),K=i(m),d(H.$$.fragment,m),fs=i(m),L=T(m,"P",{"data-svelte-h":!0}),_(L)!=="svelte-887qtl"&&(L.innerHTML=D),O=i(m),d(Q.$$.fragment,m),ss=i(m),S=T(m,"P",{"data-svelte-h":!0}),_(S)!=="svelte-1occr1z"&&(S.innerHTML=zs),es=i(m),d(A.$$.fragment,m),as=i(m),q=T(m,"P",{"data-svelte-h":!0}),_(q)!=="svelte-1r99pbn"&&(q.textContent=Es)},m(m,I){y(t,m,I),a(m,h,I),a(m,l,I),a(m,w,I),a(m,C,I),a(m,k,I),a(m,Z,I),a(m,v,I),y(F,m,I),a(m,V,I),a(m,$,I),a(m,o,I),y(U,m,I),a(m,z,I),a(m,G,I),a(m,p,I),y(j,m,I),a(m,E,I),a(m,f,I),a(m,K,I),y(H,m,I),a(m,fs,I),a(m,L,I),a(m,O,I),y(Q,m,I),a(m,ss,I),a(m,S,I),a(m,es,I),y(A,m,I),a(m,as,I),a(m,q,I),ts=!0},p(m,I){const P={};I&2&&(P.$$scope={dirty:I,ctx:m}),t.$set(P)},i(m){ts||(M(t.$$.fragment,m),M(F.$$.fragment,m),M(U.$$.fragment,m),M(j.$$.fragment,m),M(H.$$.fragment,m),M(Q.$$.fragment,m),M(A.$$.fragment,m),ts=!0)},o(m){g(t.$$.fragment,m),g(F.$$.fragment,m),g(U.$$.fragment,m),g(j.$$.fragment,m),g(H.$$.fragment,m),g(Q.$$.fragment,m),g(A.$$.fragment,m),ts=!1},d(m){m&&(e(h),e(l),e(w),e(C),e(k),e(Z),e(v),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,m),b(F,m),b(U,m),b(j,m),b(H,m),b(Q,m),b(A,m)}}}function ga(X){let t,h;return t=new Ns({props:{$$slots:{default:[Ma]},$$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||(M(t.$$.fragment,l),h=!0)},o(l){g(t.$$.fragment,l),h=!1},d(l){b(t,l)}}}function ba(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 ja(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,R,v,F="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=r(),u(c.$$.fragment),w=r(),C=J("p"),C.textContent=Y,k=r(),u(Z.$$.fragment),R=r(),v=J("p"),v.innerHTML=F,V=r(),u($.$$.fragment)},l(o){t=T(o,"P",{"data-svelte-h":!0}),_(t)!=="svelte-65kh0h"&&(t.innerHTML=h),l=i(o),d(c.$$.fragment,o),w=i(o),C=T(o,"P",{"data-svelte-h":!0}),_(C)!=="svelte-1at92g"&&(C.textContent=Y),k=i(o),d(Z.$$.fragment,o),R=i(o),v=T(o,"P",{"data-svelte-h":!0}),_(v)!=="svelte-uvq5m0"&&(v.innerHTML=F),V=i(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,R,U),a(o,v,U),a(o,V,U),y($,o,U),x=!0},p:hs,i(o){x||(M(c.$$.fragment,o),M(Z.$$.fragment,o),M($.$$.fragment,o),x=!0)},o(o){g(c.$$.fragment,o),g(Z.$$.fragment,o),g($.$$.fragment,o),x=!1},d(o){o&&(e(t),e(l),e(w),e(C),e(k),e(R),e(v),e(V)),b(c,o),b(Z,o),b($,o)}}}function wa(X){let t,h;return t=new Ns({props:{$$slots:{default:[ja]},$$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||(M(t.$$.fragment,l),h=!0)},o(l){g(t.$$.fragment,l),h=!1},d(l){b(t,l)}}}function Ja(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,R,v,F="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=r(),u(c.$$.fragment),w=r(),C=J("p"),C.textContent=Y,k=r(),u(Z.$$.fragment),R=r(),v=J("p"),v.innerHTML=F,V=r(),u($.$$.fragment)},l(o){t=T(o,"P",{"data-svelte-h":!0}),_(t)!=="svelte-1l61n0d"&&(t.innerHTML=h),l=i(o),d(c.$$.fragment,o),w=i(o),C=T(o,"P",{"data-svelte-h":!0}),_(C)!=="svelte-1at92g"&&(C.textContent=Y),k=i(o),d(Z.$$.fragment,o),R=i(o),v=T(o,"P",{"data-svelte-h":!0}),_(v)!=="svelte-uvq5m0"&&(v.innerHTML=F),V=i(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,R,U),a(o,v,U),a(o,V,U),y($,o,U),x=!0},p:hs,i(o){x||(M(c.$$.fragment,o),M(Z.$$.fragment,o),M($.$$.fragment,o),x=!0)},o(o){g(c.$$.fragment,o),g(Z.$$.fragment,o),g($.$$.fragment,o),x=!1},d(o){o&&(e(t),e(l),e(w),e(C),e(k),e(R),e(v),e(V)),b(c,o),b(Z,o),b($,o)}}}function Ta(X){let t,h;return t=new Ns({props:{$$slots:{default:[Ja]},$$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||(M(t.$$.fragment,l),h=!0)},o(l){g(t.$$.fragment,l),h=!1},d(l){b(t,l)}}}function $a(X){let t,h,l,c,w,C,Y,k,Z,R,v,F=`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,zs=`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,Es="Split the dataset’s <code>train</code> split into a train and test set with the <code>train_test_split</code> method:",ts,m,I,P,Ce="Then take a look at an example:",Qs,us,Ss,ds,ve="Each example in the dataset has two fields:",As,ys,Ie="<li><code>image</code>: a PIL image of the food item</li> <li><code>label</code>: the label class of the food item</li>",qs,Ms,ke=`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:`,Ls,gs,Ds,bs,Ge="Now you can convert the label id to a label name:",Ps,js,Ks,ws,Os,Js,We="The next step is to load a ViT image processor to process the image into a tensor:",se,Ts,ee,ls,ae,ns,te,$s,le,Us,Xe=`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):`,ne,_s,pe,Zs,Ve="Then create a function that passes your predictions and labels to <code>compute</code> to calculate the accuracy:",oe,Cs,re,vs,Ye="Your <code>compute_metrics</code> function is ready to go now, and you’ll return to it when you set up your training.",ie,Is,me,ps,ce,os,he,rs,fe,ks,ue,Gs,Re="Great, now that you’ve fine-tuned a model, you can use it for inference!",de,Ws,Fe="Load an image you’d like to run inference on:",ye,Xs,Me,is,xe='<img src="https://huggingface.co/datasets/huggingface/documentation-images/resolve/main/beignets-task-guide.png" alt="image of beignets"/>',ge,Vs,Be='The simplest way to try out your finetuned model for inference is to use it in a <a href="/docs/transformers/v4.40.2/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:',be,Ys,je,Rs,Ne="You can also manually replicate the results of the <code>pipeline</code> if you’d like:",we,ms,Je,cs,Te,Fs,$e,Hs,Ue;return w=new Bs({props:{title:"Image classification",local:"image-classification",headingTag:"h1"}}),Y=new pa({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 na({props:{id:"tjAIM7BOYhw"}}),N=new _e({props:{$$slots:{default:[ra]},$$scope:{ctx:X}}}),B=new W({props:{code:"cGlwJTIwaW5zdGFsbCUyMHRyYW5zZm9ybWVycyUyMGRhdGFzZXRzJTIwZXZhbHVhdGUlMjBhY2NlbGVyYXRl",highlighted:"pip install transformers datasets evaluate accelerate",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 Bs({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}}),m=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}}),gs=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 Bs({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 xs({props:{pytorch:!0,tensorflow:!1,jax:!1,$$slots:{pytorch:[ma]},$$scope:{ctx:X}}}),ns=new xs({props:{pytorch:!1,tensorflow:!0,jax:!1,$$slots:{tensorflow:[ha]},$$scope:{ctx:X}}}),$s=new Bs({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}}),Is=new Bs({props:{title:"Train",local:"train",headingTag:"h2"}}),ps=new xs({props:{pytorch:!0,tensorflow:!1,jax:!1,$$slots:{pytorch:[da]},$$scope:{ctx:X}}}),os=new xs({props:{pytorch:!1,tensorflow:!0,jax:!1,$$slots:{tensorflow:[ga]},$$scope:{ctx:X}}}),rs=new _e({props:{$$slots:{default:[ba]},$$scope:{ctx:X}}}),ks=new Bs({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 xs({props:{pytorch:!0,tensorflow:!1,jax:!1,$$slots:{pytorch:[wa]},$$scope:{ctx:X}}}),cs=new xs({props:{pytorch:!1,tensorflow:!0,jax:!1,$$slots:{tensorflow:[Ta]},$$scope:{ctx:X}}}),Fs=new oa({props:{source:"https://github.com/huggingface/transformers/blob/main/docs/source/en/tasks/image_classification.md"}}),{c(){t=J("meta"),h=r(),l=J("p"),c=r(),u(w.$$.fragment),C=r(),u(Y.$$.fragment),k=r(),u(Z.$$.fragment),R=r(),v=J("p"),v.textContent=F,V=r(),$=J("p"),$.textContent=x,o=r(),U=J("ol"),U.innerHTML=z,G=r(),u(N.$$.fragment),p=r(),j=J("p"),j.textContent=E,f=r(),u(B.$$.fragment),K=r(),H=J("p"),H.textContent=fs,L=r(),u(D.$$.fragment),O=r(),u(Q.$$.fragment),ss=r(),S=J("p"),S.textContent=zs,es=r(),u(A.$$.fragment),as=r(),q=J("p"),q.innerHTML=Es,ts=r(),u(m.$$.fragment),I=r(),P=J("p"),P.textContent=Ce,Qs=r(),u(us.$$.fragment),Ss=r(),ds=J("p"),ds.textContent=ve,As=r(),ys=J("ul"),ys.innerHTML=Ie,qs=r(),Ms=J("p"),Ms.textContent=ke,Ls=r(),u(gs.$$.fragment),Ds=r(),bs=J("p"),bs.textContent=Ge,Ps=r(),u(js.$$.fragment),Ks=r(),u(ws.$$.fragment),Os=r(),Js=J("p"),Js.textContent=We,se=r(),u(Ts.$$.fragment),ee=r(),u(ls.$$.fragment),ae=r(),u(ns.$$.fragment),te=r(),u($s.$$.fragment),le=r(),Us=J("p"),Us.innerHTML=Xe,ne=r(),u(_s.$$.fragment),pe=r(),Zs=J("p"),Zs.innerHTML=Ve,oe=r(),u(Cs.$$.fragment),re=r(),vs=J("p"),vs.innerHTML=Ye,ie=r(),u(Is.$$.fragment),me=r(),u(ps.$$.fragment),ce=r(),u(os.$$.fragment),he=r(),u(rs.$$.fragment),fe=r(),u(ks.$$.fragment),ue=r(),Gs=J("p"),Gs.textContent=Re,de=r(),Ws=J("p"),Ws.textContent=Fe,ye=r(),u(Xs.$$.fragment),Me=r(),is=J("div"),is.innerHTML=xe,ge=r(),Vs=J("p"),Vs.innerHTML=Be,be=r(),u(Ys.$$.fragment),je=r(),Rs=J("p"),Rs.innerHTML=Ne,we=r(),u(ms.$$.fragment),Je=r(),u(cs.$$.fragment),Te=r(),u(Fs.$$.fragment),$e=r(),Hs=J("p"),this.h()},l(s){const n=ea("svelte-u9bgzb",document.head);t=T(n,"META",{name:!0,content:!0}),n.forEach(e),h=i(s),l=T(s,"P",{}),De(l).forEach(e),c=i(s),d(w.$$.fragment,s),C=i(s),d(Y.$$.fragment,s),k=i(s),d(Z.$$.fragment,s),R=i(s),v=T(s,"P",{"data-svelte-h":!0}),_(v)!=="svelte-dpadt7"&&(v.textContent=F),V=i(s),$=T(s,"P",{"data-svelte-h":!0}),_($)!=="svelte-ku8orh"&&($.textContent=x),o=i(s),U=T(s,"OL",{"data-svelte-h":!0}),_(U)!=="svelte-1j1nbn7"&&(U.innerHTML=z),G=i(s),d(N.$$.fragment,s),p=i(s),j=T(s,"P",{"data-svelte-h":!0}),_(j)!=="svelte-1c9nexd"&&(j.textContent=E),f=i(s),d(B.$$.fragment,s),K=i(s),H=T(s,"P",{"data-svelte-h":!0}),_(H)!=="svelte-yib87s"&&(H.textContent=fs),L=i(s),d(D.$$.fragment,s),O=i(s),d(Q.$$.fragment,s),ss=i(s),S=T(s,"P",{"data-svelte-h":!0}),_(S)!=="svelte-1cr1dw1"&&(S.textContent=zs),es=i(s),d(A.$$.fragment,s),as=i(s),q=T(s,"P",{"data-svelte-h":!0}),_(q)!=="svelte-5ihn7h"&&(q.innerHTML=Es),ts=i(s),d(m.$$.fragment,s),I=i(s),P=T(s,"P",{"data-svelte-h":!0}),_(P)!=="svelte-1m91ua0"&&(P.textContent=Ce),Qs=i(s),d(us.$$.fragment,s),Ss=i(s),ds=T(s,"P",{"data-svelte-h":!0}),_(ds)!=="svelte-w87shu"&&(ds.textContent=ve),As=i(s),ys=T(s,"UL",{"data-svelte-h":!0}),_(ys)!=="svelte-133so41"&&(ys.innerHTML=Ie),qs=i(s),Ms=T(s,"P",{"data-svelte-h":!0}),_(Ms)!=="svelte-1j34ajz"&&(Ms.textContent=ke),Ls=i(s),d(gs.$$.fragment,s),Ds=i(s),bs=T(s,"P",{"data-svelte-h":!0}),_(bs)!=="svelte-1e9n4a3"&&(bs.textContent=Ge),Ps=i(s),d(js.$$.fragment,s),Ks=i(s),d(ws.$$.fragment,s),Os=i(s),Js=T(s,"P",{"data-svelte-h":!0}),_(Js)!=="svelte-25xdfm"&&(Js.textContent=We),se=i(s),d(Ts.$$.fragment,s),ee=i(s),d(ls.$$.fragment,s),ae=i(s),d(ns.$$.fragment,s),te=i(s),d($s.$$.fragment,s),le=i(s),Us=T(s,"P",{"data-svelte-h":!0}),_(Us)!=="svelte-1qqtfp"&&(Us.innerHTML=Xe),ne=i(s),d(_s.$$.fragment,s),pe=i(s),Zs=T(s,"P",{"data-svelte-h":!0}),_(Zs)!=="svelte-o3o85z"&&(Zs.innerHTML=Ve),oe=i(s),d(Cs.$$.fragment,s),re=i(s),vs=T(s,"P",{"data-svelte-h":!0}),_(vs)!=="svelte-44vib3"&&(vs.innerHTML=Ye),ie=i(s),d(Is.$$.fragment,s),me=i(s),d(ps.$$.fragment,s),ce=i(s),d(os.$$.fragment,s),he=i(s),d(rs.$$.fragment,s),fe=i(s),d(ks.$$.fragment,s),ue=i(s),Gs=T(s,"P",{"data-svelte-h":!0}),_(Gs)!=="svelte-l3g61e"&&(Gs.textContent=Re),de=i(s),Ws=T(s,"P",{"data-svelte-h":!0}),_(Ws)!=="svelte-1jlr7r7"&&(Ws.textContent=Fe),ye=i(s),d(Xs.$$.fragment,s),Me=i(s),is=T(s,"DIV",{class:!0,"data-svelte-h":!0}),_(is)!=="svelte-pnh0xy"&&(is.innerHTML=xe),ge=i(s),Vs=T(s,"P",{"data-svelte-h":!0}),_(Vs)!=="svelte-12f5jf8"&&(Vs.innerHTML=Be),be=i(s),d(Ys.$$.fragment,s),je=i(s),Rs=T(s,"P",{"data-svelte-h":!0}),_(Rs)!=="svelte-1njl8vm"&&(Rs.innerHTML=Ne),we=i(s),d(ms.$$.fragment,s),Je=i(s),d(cs.$$.fragment,s),Te=i(s),d(Fs.$$.fragment,s),$e=i(s),Hs=T(s,"P",{}),De(Hs).forEach(e),this.h()},h(){Ze(t,"name","hf:doc:metadata"),Ze(t,"content",Ua),Ze(is,"class","flex justify-center")},m(s,n){aa(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,R,n),a(s,v,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(m,s,n),a(s,I,n),a(s,P,n),a(s,Qs,n),y(us,s,n),a(s,Ss,n),a(s,ds,n),a(s,As,n),a(s,ys,n),a(s,qs,n),a(s,Ms,n),a(s,Ls,n),y(gs,s,n),a(s,Ds,n),a(s,bs,n),a(s,Ps,n),y(js,s,n),a(s,Ks,n),y(ws,s,n),a(s,Os,n),a(s,Js,n),a(s,se,n),y(Ts,s,n),a(s,ee,n),y(ls,s,n),a(s,ae,n),y(ns,s,n),a(s,te,n),y($s,s,n),a(s,le,n),a(s,Us,n),a(s,ne,n),y(_s,s,n),a(s,pe,n),a(s,Zs,n),a(s,oe,n),y(Cs,s,n),a(s,re,n),a(s,vs,n),a(s,ie,n),y(Is,s,n),a(s,me,n),y(ps,s,n),a(s,ce,n),y(os,s,n),a(s,he,n),y(rs,s,n),a(s,fe,n),y(ks,s,n),a(s,ue,n),a(s,Gs,n),a(s,de,n),a(s,Ws,n),a(s,ye,n),y(Xs,s,n),a(s,Me,n),a(s,is,n),a(s,ge,n),a(s,Vs,n),a(s,be,n),y(Ys,s,n),a(s,je,n),a(s,Rs,n),a(s,we,n),y(ms,s,n),a(s,Je,n),y(cs,s,n),a(s,Te,n),y(Fs,s,n),a(s,$e,n),a(s,Hs,n),Ue=!0},p(s,[n]){const ze={};n&2&&(ze.$$scope={dirty:n,ctx:s}),N.$set(ze);const Ee={};n&2&&(Ee.$$scope={dirty:n,ctx:s}),ls.$set(Ee);const He={};n&2&&(He.$$scope={dirty:n,ctx:s}),ns.$set(He);const Qe={};n&2&&(Qe.$$scope={dirty:n,ctx:s}),ps.$set(Qe);const Se={};n&2&&(Se.$$scope={dirty:n,ctx:s}),os.$set(Se);const Ae={};n&2&&(Ae.$$scope={dirty:n,ctx:s}),rs.$set(Ae);const qe={};n&2&&(qe.$$scope={dirty:n,ctx:s}),ms.$set(qe);const Le={};n&2&&(Le.$$scope={dirty:n,ctx:s}),cs.$set(Le)},i(s){Ue||(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(m.$$.fragment,s),M(us.$$.fragment,s),M(gs.$$.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(Is.$$.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),M(Fs.$$.fragment,s),Ue=!0)},o(s){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(m.$$.fragment,s),g(us.$$.fragment,s),g(gs.$$.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(Is.$$.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),g(Fs.$$.fragment,s),Ue=!1},d(s){s&&(e(h),e(l),e(c),e(C),e(k),e(R),e(v),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(I),e(P),e(Qs),e(Ss),e(ds),e(As),e(ys),e(qs),e(Ms),e(Ls),e(Ds),e(bs),e(Ps),e(Ks),e(Os),e(Js),e(se),e(ee),e(ae),e(te),e(le),e(Us),e(ne),e(pe),e(Zs),e(oe),e(re),e(vs),e(ie),e(me),e(ce),e(he),e(fe),e(ue),e(Gs),e(de),e(Ws),e(ye),e(Me),e(is),e(ge),e(Vs),e(be),e(je),e(Rs),e(we),e(Je),e(Te),e($e),e(Hs)),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(m,s),b(us,s),b(gs,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(Is,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),b(Fs,s)}}}const Ua='{"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 _a(X){return Ke(()=>{new URLSearchParams(window.location.search).get("fw")}),[]}class Va extends Oe{constructor(t){super(),sa(this,t,_a,$a,Pe,{})}}export{Va as component};
