import{s as Pa,o as Ka,n as hs}from"../chunks/scheduler.25b97de1.js";import{S as Oa,i as se,g as w,s as o,r as u,A as ae,h as J,f as a,c as i,j as Da,u as y,x as _,k as Za,y as ee,a as e,v as g,d as M,t as d,w as b}from"../chunks/index.d9030fc9.js";import{T as _a}from"../chunks/Tip.baa67368.js";import{Y as te}from"../chunks/Youtube.eaf1a617.js";import{C as W}from"../chunks/CodeBlock.e6cd0d95.js";import{D as le}from"../chunks/DocNotebookDropdown.5ea6cb78.js";import{F as xs,M as zs}from"../chunks/Markdown.7217f838.js";import{H as Bs,E as ne}from"../chunks/EditOnGithub.91d95064.js";function pe(X){let t,h='To see all architectures and checkpoints compatible with this task, we recommend checking the <a href="https://huggingface.co/tasks/image-classification" rel="nofollow">task-page</a>';return{c(){t=w("p"),t.innerHTML=h},l(l){t=J(l,"P",{"data-svelte-h":!0}),_(t)!=="svelte-89t2wa"&&(t.innerHTML=h)},m(l,c){e(l,t,c)},p:hs,d(l){l&&a(t)}}}function re(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,$="Crop a random part of the image, resize it, and normalize it with the image mean and standard deviation:",C,R,v,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,V,Y,T,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:',r,U,N,G,z='Now create a batch of examples using <a href="/docs/transformers/pr_29969/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 R=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}}),V=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=w("p"),t.innerHTML=h,l=o(),c=w("p"),c.textContent=$,C=o(),u(R.$$.fragment),v=o(),Z=w("p"),Z.innerHTML=F,I=o(),u(V.$$.fragment),Y=o(),T=w("p"),T.innerHTML=x,r=o(),u(U.$$.fragment),N=o(),G=w("p"),G.innerHTML=z,p=o(),u(j.$$.fragment)},l(f){t=J(f,"P",{"data-svelte-h":!0}),_(t)!=="svelte-1h04qv0"&&(t.innerHTML=h),l=i(f),c=J(f,"P",{"data-svelte-h":!0}),_(c)!=="svelte-1ocztfo"&&(c.textContent=$),C=i(f),y(R.$$.fragment,f),v=i(f),Z=J(f,"P",{"data-svelte-h":!0}),_(Z)!=="svelte-q25jfj"&&(Z.innerHTML=F),I=i(f),y(V.$$.fragment,f),Y=i(f),T=J(f,"P",{"data-svelte-h":!0}),_(T)!=="svelte-7ormju"&&(T.innerHTML=x),r=i(f),y(U.$$.fragment,f),N=i(f),G=J(f,"P",{"data-svelte-h":!0}),_(G)!=="svelte-u3zxx5"&&(G.innerHTML=z),p=i(f),y(j.$$.fragment,f)},m(f,B){e(f,t,B),e(f,l,B),e(f,c,B),e(f,C,B),g(R,f,B),e(f,v,B),e(f,Z,B),e(f,I,B),g(V,f,B),e(f,Y,B),e(f,T,B),e(f,r,B),g(U,f,B),e(f,N,B),e(f,G,B),e(f,p,B),g(j,f,B),E=!0},p:hs,i(f){E||(M(R.$$.fragment,f),M(V.$$.fragment,f),M(U.$$.fragment,f),M(j.$$.fragment,f),E=!0)},o(f){d(R.$$.fragment,f),d(V.$$.fragment,f),d(U.$$.fragment,f),d(j.$$.fragment,f),E=!1},d(f){f&&(a(t),a(l),a(c),a(C),a(v),a(Z),a(I),a(Y),a(T),a(r),a(N),a(G),a(p)),b(R,f),b(V,f),b(U,f),b(j,f)}}}function oe(X){let t,h;return t=new zs({props:{$$slots:{default:[re]},$$scope:{ctx:X}}}),{c(){u(t.$$.fragment)},l(l){y(t.$$.fragment,l)},m(l,c){g(t,l,c),h=!0},p(l,c){const $={};c&2&&($.$$scope={dirty:c,ctx:l}),t.$set($)},i(l){h||(M(t.$$.fragment,l),h=!0)},o(l){d(t.$$.fragment,l),h=!1},d(l){b(t,l)}}}function ie(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,$,C,R="Next, create functions to apply appropriate transformations to a batch of images, instead of one image at a time.",v,Z,F,I,V='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:',Y,T,x,r,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.`,N,G,z;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}}),T=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=w("p"),t.innerHTML=h,l=o(),u(c.$$.fragment),$=o(),C=w("p"),C.textContent=R,v=o(),u(Z.$$.fragment),F=o(),I=w("p"),I.innerHTML=V,Y=o(),u(T.$$.fragment),x=o(),r=w("p"),r.innerHTML=U,N=o(),u(G.$$.fragment)},l(p){t=J(p,"P",{"data-svelte-h":!0}),_(t)!=="svelte-134vg0e"&&(t.innerHTML=h),l=i(p),y(c.$$.fragment,p),$=i(p),C=J(p,"P",{"data-svelte-h":!0}),_(C)!=="svelte-kdpfis"&&(C.textContent=R),v=i(p),y(Z.$$.fragment,p),F=i(p),I=J(p,"P",{"data-svelte-h":!0}),_(I)!=="svelte-1v4gef0"&&(I.innerHTML=V),Y=i(p),y(T.$$.fragment,p),x=i(p),r=J(p,"P",{"data-svelte-h":!0}),_(r)!=="svelte-j9ih75"&&(r.innerHTML=U),N=i(p),y(G.$$.fragment,p)},m(p,j){e(p,t,j),e(p,l,j),g(c,p,j),e(p,$,j),e(p,C,j),e(p,v,j),g(Z,p,j),e(p,F,j),e(p,I,j),e(p,Y,j),g(T,p,j),e(p,x,j),e(p,r,j),e(p,N,j),g(G,p,j),z=!0},p:hs,i(p){z||(M(c.$$.fragment,p),M(Z.$$.fragment,p),M(T.$$.fragment,p),M(G.$$.fragment,p),z=!0)},o(p){d(c.$$.fragment,p),d(Z.$$.fragment,p),d(T.$$.fragment,p),d(G.$$.fragment,p),z=!1},d(p){p&&(a(t),a(l),a($),a(C),a(v),a(F),a(I),a(Y),a(x),a(r),a(N)),b(c,p),b(Z,p),b(T,p),b(G,p)}}}function me(X){let t,h;return t=new zs({props:{$$slots:{default:[ie]},$$scope:{ctx:X}}}),{c(){u(t.$$.fragment)},l(l){y(t.$$.fragment,l)},m(l,c){g(t,l,c),h=!0},p(l,c){const $={};c&2&&($.$$scope={dirty:c,ctx:l}),t.$set($)},i(l){h||(M(t.$$.fragment,l),h=!0)},o(l){d(t.$$.fragment,l),h=!1},d(l){b(t,l)}}}function ce(X){let t,h='If you aren’t familiar with finetuning a model with the <a href="/docs/transformers/pr_29969/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=w("p"),t.innerHTML=h},l(l){t=J(l,"P",{"data-svelte-h":!0}),_(t)!=="svelte-9sclpj"&&(t.innerHTML=h)},m(l,c){e(l,t,c)},p:hs,d(l){l&&a(t)}}}function he(X){let t,h,l,c='You’re ready to start training your model now! Load ViT with <a href="/docs/transformers/pr_29969/en/model_doc/auto#transformers.AutoModelForImageClassification">AutoModelForImageClassification</a>. Specify the number of labels along with the number of expected labels, and the label mappings:',$,C,R,v,Z="At this point, only three steps remain:",F,I,V='<li>Define your training hyperparameters in <a href="/docs/transformers/pr_29969/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/pr_29969/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/pr_29969/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/pr_29969/en/main_classes/trainer#transformers.Trainer.train">train()</a> to finetune your model.</li>',Y,T,x,r,U='Once training is completed, share your model to the Hub with the <a href="/docs/transformers/pr_29969/en/main_classes/trainer#transformers.Trainer.push_to_hub">push_to_hub()</a> method so everyone can use your model:',N,G,z;return t=new _a({props:{$$slots:{default:[ce]},$$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}}),T=new W({props:{code:"dHJhaW5pbmdfYXJncyUyMCUzRCUyMFRyYWluaW5nQXJndW1lbnRzKCUwQSUyMCUyMCUyMCUyMG91dHB1dF9kaXIlM0QlMjJteV9hd2Vzb21lX2Zvb2RfbW9kZWwlMjIlMkMlMEElMjAlMjAlMjAlMjByZW1vdmVfdW51c2VkX2NvbHVtbnMlM0RGYWxzZSUyQyUwQSUyMCUyMCUyMCUyMGV2YWxfc3RyYXRlZ3klM0QlMjJlcG9jaCUyMiUyQyUwQSUyMCUyMCUyMCUyMHNhdmVfc3RyYXRlZ3klM0QlMjJlcG9jaCUyMiUyQyUwQSUyMCUyMCUyMCUyMGxlYXJuaW5nX3JhdGUlM0Q1ZS01JTJDJTBBJTIwJTIwJTIwJTIwcGVyX2RldmljZV90cmFpbl9iYXRjaF9zaXplJTNEMTYlMkMlMEElMjAlMjAlMjAlMjBncmFkaWVudF9hY2N1bXVsYXRpb25fc3RlcHMlM0Q0JTJDJTBBJTIwJTIwJTIwJTIwcGVyX2RldmljZV9ldmFsX2JhdGNoX3NpemUlM0QxNiUyQyUwQSUyMCUyMCUyMCUyMG51bV90cmFpbl9lcG9jaHMlM0QzJTJDJTBBJTIwJTIwJTIwJTIwd2FybXVwX3JhdGlvJTNEMC4xJTJDJTBBJTIwJTIwJTIwJTIwbG9nZ2luZ19zdGVwcyUzRDEwJTJDJTBBJTIwJTIwJTIwJTIwbG9hZF9iZXN0X21vZGVsX2F0X2VuZCUzRFRydWUlMkMlMEElMjAlMjAlMjAlMjBtZXRyaWNfZm9yX2Jlc3RfbW9kZWwlM0QlMjJhY2N1cmFjeSUyMiUyQyUwQSUyMCUyMCUyMCUyMHB1c2hfdG9faHViJTNEVHJ1ZSUyQyUwQSklMEElMEF0cmFpbmVyJTIwJTNEJTIwVHJhaW5lciglMEElMjAlMjAlMjAlMjBtb2RlbCUzRG1vZGVsJTJDJTBBJTIwJTIwJTIwJTIwYXJncyUzRHRyYWluaW5nX2FyZ3MlMkMlMEElMjAlMjAlMjAlMjBkYXRhX2NvbGxhdG9yJTNEZGF0YV9jb2xsYXRvciUyQyUwQSUyMCUyMCUyMCUyMHRyYWluX2RhdGFzZXQlM0Rmb29kJTVCJTIydHJhaW4lMjIlNUQlMkMlMEElMjAlMjAlMjAlMjBldmFsX2RhdGFzZXQlM0Rmb29kJTVCJTIydGVzdCUyMiU1RCUyQyUwQSUyMCUyMCUyMCUyMHByb2Nlc3NpbmdfY2xhc3MlM0RpbWFnZV9wcm9jZXNzb3IlMkMlMEElMjAlMjAlMjAlMjBjb21wdXRlX21ldHJpY3MlM0Rjb21wdXRlX21ldHJpY3MlMkMlMEEpJTBBJTBBdHJhaW5lci50cmFpbigp",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>    eval_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>    processing_class=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=o(),l=w("p"),l.innerHTML=c,$=o(),u(C.$$.fragment),R=o(),v=w("p"),v.textContent=Z,F=o(),I=w("ol"),I.innerHTML=V,Y=o(),u(T.$$.fragment),x=o(),r=w("p"),r.innerHTML=U,N=o(),u(G.$$.fragment)},l(p){y(t.$$.fragment,p),h=i(p),l=J(p,"P",{"data-svelte-h":!0}),_(l)!=="svelte-121etw5"&&(l.innerHTML=c),$=i(p),y(C.$$.fragment,p),R=i(p),v=J(p,"P",{"data-svelte-h":!0}),_(v)!=="svelte-l42k0i"&&(v.textContent=Z),F=i(p),I=J(p,"OL",{"data-svelte-h":!0}),_(I)!=="svelte-1k11b8l"&&(I.innerHTML=V),Y=i(p),y(T.$$.fragment,p),x=i(p),r=J(p,"P",{"data-svelte-h":!0}),_(r)!=="svelte-jpge3p"&&(r.innerHTML=U),N=i(p),y(G.$$.fragment,p)},m(p,j){g(t,p,j),e(p,h,j),e(p,l,j),e(p,$,j),g(C,p,j),e(p,R,j),e(p,v,j),e(p,F,j),e(p,I,j),e(p,Y,j),g(T,p,j),e(p,x,j),e(p,r,j),e(p,N,j),g(G,p,j),z=!0},p(p,j){const E={};j&2&&(E.$$scope={dirty:j,ctx:p}),t.$set(E)},i(p){z||(M(t.$$.fragment,p),M(C.$$.fragment,p),M(T.$$.fragment,p),M(G.$$.fragment,p),z=!0)},o(p){d(t.$$.fragment,p),d(C.$$.fragment,p),d(T.$$.fragment,p),d(G.$$.fragment,p),z=!1},d(p){p&&(a(h),a(l),a($),a(R),a(v),a(F),a(I),a(Y),a(x),a(r),a(N)),b(t,p),b(C,p),b(T,p),b(G,p)}}}function fe(X){let t,h;return t=new zs({props:{$$slots:{default:[he]},$$scope:{ctx:X}}}),{c(){u(t.$$.fragment)},l(l){y(t.$$.fragment,l)},m(l,c){g(t,l,c),h=!0},p(l,c){const $={};c&2&&($.$$scope={dirty:c,ctx:l}),t.$set($)},i(l){h||(M(t.$$.fragment,l),h=!0)},o(l){d(t.$$.fragment,l),h=!1},d(l){b(t,l)}}}function ue(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=w("p"),t.innerHTML=h},l(l){t=J(l,"P",{"data-svelte-h":!0}),_(t)!=="svelte-1egt5s9"&&(t.innerHTML=h)},m(l,c){e(l,t,c)},p:hs,d(l){l&&a(t)}}}function ye(X){let t,h,l,c="To fine-tune a model in TensorFlow, follow these steps:",$,C,R="<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>",v,Z,F="Start by defining the hyperparameters, optimizer and learning rate schedule:",I,V,Y,T,x='Then, load ViT with <a href="/docs/transformers/pr_29969/en/model_doc/auto#transformers.TFAutoModelForImageClassification">TFAutoModelForImageClassification</a> along with the label mappings:',r,U,N,G,z='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:`,as,A,es,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 _a({props:{$$slots:{default:[ue]},$$scope:{ctx:X}}}),V=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=o(),l=w("p"),l.textContent=c,$=o(),C=w("ol"),C.innerHTML=R,v=o(),Z=w("p"),Z.textContent=F,I=o(),u(V.$$.fragment),Y=o(),T=w("p"),T.innerHTML=x,r=o(),u(U.$$.fragment),N=o(),G=w("p"),G.innerHTML=z,p=o(),u(j.$$.fragment),E=o(),f=w("p"),f.innerHTML=B,K=o(),u(H.$$.fragment),fs=o(),L=w("p"),L.innerHTML=D,O=o(),u(Q.$$.fragment),ss=o(),S=w("p"),S.innerHTML=Ns,as=o(),u(A.$$.fragment),es=o(),q=w("p"),q.textContent=Es},l(m){y(t.$$.fragment,m),h=i(m),l=J(m,"P",{"data-svelte-h":!0}),_(l)!=="svelte-s07fxj"&&(l.textContent=c),$=i(m),C=J(m,"OL",{"data-svelte-h":!0}),_(C)!=="svelte-1psiqa4"&&(C.innerHTML=R),v=i(m),Z=J(m,"P",{"data-svelte-h":!0}),_(Z)!=="svelte-ccl3wn"&&(Z.textContent=F),I=i(m),y(V.$$.fragment,m),Y=i(m),T=J(m,"P",{"data-svelte-h":!0}),_(T)!=="svelte-xiozo6"&&(T.innerHTML=x),r=i(m),y(U.$$.fragment,m),N=i(m),G=J(m,"P",{"data-svelte-h":!0}),_(G)!=="svelte-ca31ls"&&(G.innerHTML=z),p=i(m),y(j.$$.fragment,m),E=i(m),f=J(m,"P",{"data-svelte-h":!0}),_(f)!=="svelte-fhefbq"&&(f.innerHTML=B),K=i(m),y(H.$$.fragment,m),fs=i(m),L=J(m,"P",{"data-svelte-h":!0}),_(L)!=="svelte-887qtl"&&(L.innerHTML=D),O=i(m),y(Q.$$.fragment,m),ss=i(m),S=J(m,"P",{"data-svelte-h":!0}),_(S)!=="svelte-1occr1z"&&(S.innerHTML=Ns),as=i(m),y(A.$$.fragment,m),es=i(m),q=J(m,"P",{"data-svelte-h":!0}),_(q)!=="svelte-1r99pbn"&&(q.textContent=Es)},m(m,k){g(t,m,k),e(m,h,k),e(m,l,k),e(m,$,k),e(m,C,k),e(m,v,k),e(m,Z,k),e(m,I,k),g(V,m,k),e(m,Y,k),e(m,T,k),e(m,r,k),g(U,m,k),e(m,N,k),e(m,G,k),e(m,p,k),g(j,m,k),e(m,E,k),e(m,f,k),e(m,K,k),g(H,m,k),e(m,fs,k),e(m,L,k),e(m,O,k),g(Q,m,k),e(m,ss,k),e(m,S,k),e(m,as,k),g(A,m,k),e(m,es,k),e(m,q,k),ts=!0},p(m,k){const P={};k&2&&(P.$$scope={dirty:k,ctx:m}),t.$set(P)},i(m){ts||(M(t.$$.fragment,m),M(V.$$.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){d(t.$$.fragment,m),d(V.$$.fragment,m),d(U.$$.fragment,m),d(j.$$.fragment,m),d(H.$$.fragment,m),d(Q.$$.fragment,m),d(A.$$.fragment,m),ts=!1},d(m){m&&(a(h),a(l),a($),a(C),a(v),a(Z),a(I),a(Y),a(T),a(r),a(N),a(G),a(p),a(E),a(f),a(K),a(fs),a(L),a(O),a(ss),a(S),a(as),a(es),a(q)),b(t,m),b(V,m),b(U,m),b(j,m),b(H,m),b(Q,m),b(A,m)}}}function ge(X){let t,h;return t=new zs({props:{$$slots:{default:[ye]},$$scope:{ctx:X}}}),{c(){u(t.$$.fragment)},l(l){y(t.$$.fragment,l)},m(l,c){g(t,l,c),h=!0},p(l,c){const $={};c&2&&($.$$scope={dirty:c,ctx:l}),t.$set($)},i(l){h||(M(t.$$.fragment,l),h=!0)},o(l){d(t.$$.fragment,l),h=!1},d(l){b(t,l)}}}function Me(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=w("p"),t.innerHTML=h},l(l){t=J(l,"P",{"data-svelte-h":!0}),_(t)!=="svelte-1gyicmz"&&(t.innerHTML=h)},m(l,c){e(l,t,c)},p:hs,d(l){l&&a(t)}}}function de(X){let t,h="Load an image processor to preprocess the image and return the <code>input</code> as PyTorch tensors:",l,c,$,C,R="Pass your inputs to the model and return the logits:",v,Z,F,I,V="Get the predicted label with the highest probability, and use the model’s <code>id2label</code> mapping to convert it to a label:",Y,T,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}}),T=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=w("p"),t.innerHTML=h,l=o(),u(c.$$.fragment),$=o(),C=w("p"),C.textContent=R,v=o(),u(Z.$$.fragment),F=o(),I=w("p"),I.innerHTML=V,Y=o(),u(T.$$.fragment)},l(r){t=J(r,"P",{"data-svelte-h":!0}),_(t)!=="svelte-65kh0h"&&(t.innerHTML=h),l=i(r),y(c.$$.fragment,r),$=i(r),C=J(r,"P",{"data-svelte-h":!0}),_(C)!=="svelte-1at92g"&&(C.textContent=R),v=i(r),y(Z.$$.fragment,r),F=i(r),I=J(r,"P",{"data-svelte-h":!0}),_(I)!=="svelte-uvq5m0"&&(I.innerHTML=V),Y=i(r),y(T.$$.fragment,r)},m(r,U){e(r,t,U),e(r,l,U),g(c,r,U),e(r,$,U),e(r,C,U),e(r,v,U),g(Z,r,U),e(r,F,U),e(r,I,U),e(r,Y,U),g(T,r,U),x=!0},p:hs,i(r){x||(M(c.$$.fragment,r),M(Z.$$.fragment,r),M(T.$$.fragment,r),x=!0)},o(r){d(c.$$.fragment,r),d(Z.$$.fragment,r),d(T.$$.fragment,r),x=!1},d(r){r&&(a(t),a(l),a($),a(C),a(v),a(F),a(I),a(Y)),b(c,r),b(Z,r),b(T,r)}}}function be(X){let t,h;return t=new zs({props:{$$slots:{default:[de]},$$scope:{ctx:X}}}),{c(){u(t.$$.fragment)},l(l){y(t.$$.fragment,l)},m(l,c){g(t,l,c),h=!0},p(l,c){const $={};c&2&&($.$$scope={dirty:c,ctx:l}),t.$set($)},i(l){h||(M(t.$$.fragment,l),h=!0)},o(l){d(t.$$.fragment,l),h=!1},d(l){b(t,l)}}}function je(X){let t,h="Load an image processor to preprocess the image and return the <code>input</code> as TensorFlow tensors:",l,c,$,C,R="Pass your inputs to the model and return the logits:",v,Z,F,I,V="Get the predicted label with the highest probability, and use the model’s <code>id2label</code> mapping to convert it to a label:",Y,T,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}}),T=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=w("p"),t.innerHTML=h,l=o(),u(c.$$.fragment),$=o(),C=w("p"),C.textContent=R,v=o(),u(Z.$$.fragment),F=o(),I=w("p"),I.innerHTML=V,Y=o(),u(T.$$.fragment)},l(r){t=J(r,"P",{"data-svelte-h":!0}),_(t)!=="svelte-1l61n0d"&&(t.innerHTML=h),l=i(r),y(c.$$.fragment,r),$=i(r),C=J(r,"P",{"data-svelte-h":!0}),_(C)!=="svelte-1at92g"&&(C.textContent=R),v=i(r),y(Z.$$.fragment,r),F=i(r),I=J(r,"P",{"data-svelte-h":!0}),_(I)!=="svelte-uvq5m0"&&(I.innerHTML=V),Y=i(r),y(T.$$.fragment,r)},m(r,U){e(r,t,U),e(r,l,U),g(c,r,U),e(r,$,U),e(r,C,U),e(r,v,U),g(Z,r,U),e(r,F,U),e(r,I,U),e(r,Y,U),g(T,r,U),x=!0},p:hs,i(r){x||(M(c.$$.fragment,r),M(Z.$$.fragment,r),M(T.$$.fragment,r),x=!0)},o(r){d(c.$$.fragment,r),d(Z.$$.fragment,r),d(T.$$.fragment,r),x=!1},d(r){r&&(a(t),a(l),a($),a(C),a(v),a(F),a(I),a(Y)),b(c,r),b(Z,r),b(T,r)}}}function we(X){let t,h;return t=new zs({props:{$$slots:{default:[je]},$$scope:{ctx:X}}}),{c(){u(t.$$.fragment)},l(l){y(t.$$.fragment,l)},m(l,c){g(t,l,c),h=!0},p(l,c){const $={};c&2&&($.$$scope={dirty:c,ctx:l}),t.$set($)},i(l){h||(M(t.$$.fragment,l),h=!0)},o(l){d(t.$$.fragment,l),h=!1},d(l){b(t,l)}}}function Je(X){let t,h,l,c,$,C,R,v,Z,F,I,V=`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.`,Y,T,x="This guide illustrates how to:",r,U,N='<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,z,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.`,as,A,es,q,Es='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,m,k,P,Ca="Then take a look at an example:",Qs,us,Ss,ys,Ia="Each example in the dataset has two fields:",As,gs,ka="<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,va=`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,ds,Ds,bs,Ga="Now you can convert the label id to a label name:",Ps,js,Ks,ws,Os,Js,Wa="The next step is to load a ViT image processor to process the image into a tensor:",sa,Ts,aa,ls,ea,ns,ta,$s,la,Us,Xa=`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):`,na,_s,pa,Zs,Ya='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:',ra,Cs,oa,Is,Ra="Your <code>compute_metrics</code> function is ready to go now, and you’ll return to it when you set up your training.",ia,ks,ma,ps,ca,rs,ha,os,fa,vs,ua,Gs,Fa="Great, now that you’ve fine-tuned a model, you can use it for inference!",ya,Ws,Va="Load an image you’d like to run inference on:",ga,Xs,Ma,is,xa='<img src="https://huggingface.co/datasets/huggingface/documentation-images/resolve/main/beignets-task-guide.png" alt="image of beignets"/>',da,Ys,Ba='The simplest way to try out your finetuned model for inference is to use it in a <a href="/docs/transformers/pr_29969/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:',ba,Rs,ja,Fs,za="You can also manually replicate the results of the <code>pipeline</code> if you’d like:",wa,ms,Ja,cs,Ta,Vs,$a,Hs,Ua;return $=new Bs({props:{title:"Image classification",local:"image-classification",headingTag:"h1"}}),R=new le({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 te({props:{id:"tjAIM7BOYhw"}}),z=new _a({props:{$$slots:{default:[pe]},$$scope:{ctx:X}}}),B=new W({props:{code:"cGlwJTIwaW5zdGFsbCUyMHRyYW5zZm9ybWVycyUyMGRhdGFzZXRzJTIwZXZhbHVhdGUlMjBhY2NlbGVyYXRlJTIwcGlsbG93JTIwdG9yY2h2aXNpb24lMjBzY2lraXQtbGVhcm4=",highlighted:"pip install transformers datasets evaluate accelerate pillow torchvision scikit-learn",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}}),ds=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:[oe]},$$scope:{ctx:X}}}),ns=new xs({props:{pytorch:!1,tensorflow:!0,jax:!1,$$slots:{tensorflow:[me]},$$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}}),ks=new Bs({props:{title:"Train",local:"train",headingTag:"h2"}}),ps=new xs({props:{pytorch:!0,tensorflow:!1,jax:!1,$$slots:{pytorch:[fe]},$$scope:{ctx:X}}}),rs=new xs({props:{pytorch:!1,tensorflow:!0,jax:!1,$$slots:{tensorflow:[ge]},$$scope:{ctx:X}}}),os=new _a({props:{$$slots:{default:[Me]},$$scope:{ctx:X}}}),vs=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}}),Rs=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:[be]},$$scope:{ctx:X}}}),cs=new xs({props:{pytorch:!1,tensorflow:!0,jax:!1,$$slots:{tensorflow:[we]},$$scope:{ctx:X}}}),Vs=new ne({props:{source:"https://github.com/huggingface/transformers/blob/main/docs/source/en/tasks/image_classification.md"}}),{c(){t=w("meta"),h=o(),l=w("p"),c=o(),u($.$$.fragment),C=o(),u(R.$$.fragment),v=o(),u(Z.$$.fragment),F=o(),I=w("p"),I.textContent=V,Y=o(),T=w("p"),T.textContent=x,r=o(),U=w("ol"),U.innerHTML=N,G=o(),u(z.$$.fragment),p=o(),j=w("p"),j.textContent=E,f=o(),u(B.$$.fragment),K=o(),H=w("p"),H.textContent=fs,L=o(),u(D.$$.fragment),O=o(),u(Q.$$.fragment),ss=o(),S=w("p"),S.textContent=Ns,as=o(),u(A.$$.fragment),es=o(),q=w("p"),q.innerHTML=Es,ts=o(),u(m.$$.fragment),k=o(),P=w("p"),P.textContent=Ca,Qs=o(),u(us.$$.fragment),Ss=o(),ys=w("p"),ys.textContent=Ia,As=o(),gs=w("ul"),gs.innerHTML=ka,qs=o(),Ms=w("p"),Ms.textContent=va,Ls=o(),u(ds.$$.fragment),Ds=o(),bs=w("p"),bs.textContent=Ga,Ps=o(),u(js.$$.fragment),Ks=o(),u(ws.$$.fragment),Os=o(),Js=w("p"),Js.textContent=Wa,sa=o(),u(Ts.$$.fragment),aa=o(),u(ls.$$.fragment),ea=o(),u(ns.$$.fragment),ta=o(),u($s.$$.fragment),la=o(),Us=w("p"),Us.innerHTML=Xa,na=o(),u(_s.$$.fragment),pa=o(),Zs=w("p"),Zs.innerHTML=Ya,ra=o(),u(Cs.$$.fragment),oa=o(),Is=w("p"),Is.innerHTML=Ra,ia=o(),u(ks.$$.fragment),ma=o(),u(ps.$$.fragment),ca=o(),u(rs.$$.fragment),ha=o(),u(os.$$.fragment),fa=o(),u(vs.$$.fragment),ua=o(),Gs=w("p"),Gs.textContent=Fa,ya=o(),Ws=w("p"),Ws.textContent=Va,ga=o(),u(Xs.$$.fragment),Ma=o(),is=w("div"),is.innerHTML=xa,da=o(),Ys=w("p"),Ys.innerHTML=Ba,ba=o(),u(Rs.$$.fragment),ja=o(),Fs=w("p"),Fs.innerHTML=za,wa=o(),u(ms.$$.fragment),Ja=o(),u(cs.$$.fragment),Ta=o(),u(Vs.$$.fragment),$a=o(),Hs=w("p"),this.h()},l(s){const n=ae("svelte-u9bgzb",document.head);t=J(n,"META",{name:!0,content:!0}),n.forEach(a),h=i(s),l=J(s,"P",{}),Da(l).forEach(a),c=i(s),y($.$$.fragment,s),C=i(s),y(R.$$.fragment,s),v=i(s),y(Z.$$.fragment,s),F=i(s),I=J(s,"P",{"data-svelte-h":!0}),_(I)!=="svelte-dpadt7"&&(I.textContent=V),Y=i(s),T=J(s,"P",{"data-svelte-h":!0}),_(T)!=="svelte-ku8orh"&&(T.textContent=x),r=i(s),U=J(s,"OL",{"data-svelte-h":!0}),_(U)!=="svelte-1j1nbn7"&&(U.innerHTML=N),G=i(s),y(z.$$.fragment,s),p=i(s),j=J(s,"P",{"data-svelte-h":!0}),_(j)!=="svelte-1c9nexd"&&(j.textContent=E),f=i(s),y(B.$$.fragment,s),K=i(s),H=J(s,"P",{"data-svelte-h":!0}),_(H)!=="svelte-yib87s"&&(H.textContent=fs),L=i(s),y(D.$$.fragment,s),O=i(s),y(Q.$$.fragment,s),ss=i(s),S=J(s,"P",{"data-svelte-h":!0}),_(S)!=="svelte-1cr1dw1"&&(S.textContent=Ns),as=i(s),y(A.$$.fragment,s),es=i(s),q=J(s,"P",{"data-svelte-h":!0}),_(q)!=="svelte-rugbz4"&&(q.innerHTML=Es),ts=i(s),y(m.$$.fragment,s),k=i(s),P=J(s,"P",{"data-svelte-h":!0}),_(P)!=="svelte-1m91ua0"&&(P.textContent=Ca),Qs=i(s),y(us.$$.fragment,s),Ss=i(s),ys=J(s,"P",{"data-svelte-h":!0}),_(ys)!=="svelte-w87shu"&&(ys.textContent=Ia),As=i(s),gs=J(s,"UL",{"data-svelte-h":!0}),_(gs)!=="svelte-133so41"&&(gs.innerHTML=ka),qs=i(s),Ms=J(s,"P",{"data-svelte-h":!0}),_(Ms)!=="svelte-1j34ajz"&&(Ms.textContent=va),Ls=i(s),y(ds.$$.fragment,s),Ds=i(s),bs=J(s,"P",{"data-svelte-h":!0}),_(bs)!=="svelte-1e9n4a3"&&(bs.textContent=Ga),Ps=i(s),y(js.$$.fragment,s),Ks=i(s),y(ws.$$.fragment,s),Os=i(s),Js=J(s,"P",{"data-svelte-h":!0}),_(Js)!=="svelte-25xdfm"&&(Js.textContent=Wa),sa=i(s),y(Ts.$$.fragment,s),aa=i(s),y(ls.$$.fragment,s),ea=i(s),y(ns.$$.fragment,s),ta=i(s),y($s.$$.fragment,s),la=i(s),Us=J(s,"P",{"data-svelte-h":!0}),_(Us)!=="svelte-1qqtfp"&&(Us.innerHTML=Xa),na=i(s),y(_s.$$.fragment,s),pa=i(s),Zs=J(s,"P",{"data-svelte-h":!0}),_(Zs)!=="svelte-14irt3v"&&(Zs.innerHTML=Ya),ra=i(s),y(Cs.$$.fragment,s),oa=i(s),Is=J(s,"P",{"data-svelte-h":!0}),_(Is)!=="svelte-44vib3"&&(Is.innerHTML=Ra),ia=i(s),y(ks.$$.fragment,s),ma=i(s),y(ps.$$.fragment,s),ca=i(s),y(rs.$$.fragment,s),ha=i(s),y(os.$$.fragment,s),fa=i(s),y(vs.$$.fragment,s),ua=i(s),Gs=J(s,"P",{"data-svelte-h":!0}),_(Gs)!=="svelte-l3g61e"&&(Gs.textContent=Fa),ya=i(s),Ws=J(s,"P",{"data-svelte-h":!0}),_(Ws)!=="svelte-1jlr7r7"&&(Ws.textContent=Va),ga=i(s),y(Xs.$$.fragment,s),Ma=i(s),is=J(s,"DIV",{class:!0,"data-svelte-h":!0}),_(is)!=="svelte-pnh0xy"&&(is.innerHTML=xa),da=i(s),Ys=J(s,"P",{"data-svelte-h":!0}),_(Ys)!=="svelte-gjc32"&&(Ys.innerHTML=Ba),ba=i(s),y(Rs.$$.fragment,s),ja=i(s),Fs=J(s,"P",{"data-svelte-h":!0}),_(Fs)!=="svelte-1njl8vm"&&(Fs.innerHTML=za),wa=i(s),y(ms.$$.fragment,s),Ja=i(s),y(cs.$$.fragment,s),Ta=i(s),y(Vs.$$.fragment,s),$a=i(s),Hs=J(s,"P",{}),Da(Hs).forEach(a),this.h()},h(){Za(t,"name","hf:doc:metadata"),Za(t,"content",Te),Za(is,"class","flex justify-center")},m(s,n){ee(document.head,t),e(s,h,n),e(s,l,n),e(s,c,n),g($,s,n),e(s,C,n),g(R,s,n),e(s,v,n),g(Z,s,n),e(s,F,n),e(s,I,n),e(s,Y,n),e(s,T,n),e(s,r,n),e(s,U,n),e(s,G,n),g(z,s,n),e(s,p,n),e(s,j,n),e(s,f,n),g(B,s,n),e(s,K,n),e(s,H,n),e(s,L,n),g(D,s,n),e(s,O,n),g(Q,s,n),e(s,ss,n),e(s,S,n),e(s,as,n),g(A,s,n),e(s,es,n),e(s,q,n),e(s,ts,n),g(m,s,n),e(s,k,n),e(s,P,n),e(s,Qs,n),g(us,s,n),e(s,Ss,n),e(s,ys,n),e(s,As,n),e(s,gs,n),e(s,qs,n),e(s,Ms,n),e(s,Ls,n),g(ds,s,n),e(s,Ds,n),e(s,bs,n),e(s,Ps,n),g(js,s,n),e(s,Ks,n),g(ws,s,n),e(s,Os,n),e(s,Js,n),e(s,sa,n),g(Ts,s,n),e(s,aa,n),g(ls,s,n),e(s,ea,n),g(ns,s,n),e(s,ta,n),g($s,s,n),e(s,la,n),e(s,Us,n),e(s,na,n),g(_s,s,n),e(s,pa,n),e(s,Zs,n),e(s,ra,n),g(Cs,s,n),e(s,oa,n),e(s,Is,n),e(s,ia,n),g(ks,s,n),e(s,ma,n),g(ps,s,n),e(s,ca,n),g(rs,s,n),e(s,ha,n),g(os,s,n),e(s,fa,n),g(vs,s,n),e(s,ua,n),e(s,Gs,n),e(s,ya,n),e(s,Ws,n),e(s,ga,n),g(Xs,s,n),e(s,Ma,n),e(s,is,n),e(s,da,n),e(s,Ys,n),e(s,ba,n),g(Rs,s,n),e(s,ja,n),e(s,Fs,n),e(s,wa,n),g(ms,s,n),e(s,Ja,n),g(cs,s,n),e(s,Ta,n),g(Vs,s,n),e(s,$a,n),e(s,Hs,n),Ua=!0},p(s,[n]){const Na={};n&2&&(Na.$$scope={dirty:n,ctx:s}),z.$set(Na);const Ea={};n&2&&(Ea.$$scope={dirty:n,ctx:s}),ls.$set(Ea);const Ha={};n&2&&(Ha.$$scope={dirty:n,ctx:s}),ns.$set(Ha);const Qa={};n&2&&(Qa.$$scope={dirty:n,ctx:s}),ps.$set(Qa);const Sa={};n&2&&(Sa.$$scope={dirty:n,ctx:s}),rs.$set(Sa);const Aa={};n&2&&(Aa.$$scope={dirty:n,ctx:s}),os.$set(Aa);const qa={};n&2&&(qa.$$scope={dirty:n,ctx:s}),ms.$set(qa);const La={};n&2&&(La.$$scope={dirty:n,ctx:s}),cs.$set(La)},i(s){Ua||(M($.$$.fragment,s),M(R.$$.fragment,s),M(Z.$$.fragment,s),M(z.$$.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(ds.$$.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(ks.$$.fragment,s),M(ps.$$.fragment,s),M(rs.$$.fragment,s),M(os.$$.fragment,s),M(vs.$$.fragment,s),M(Xs.$$.fragment,s),M(Rs.$$.fragment,s),M(ms.$$.fragment,s),M(cs.$$.fragment,s),M(Vs.$$.fragment,s),Ua=!0)},o(s){d($.$$.fragment,s),d(R.$$.fragment,s),d(Z.$$.fragment,s),d(z.$$.fragment,s),d(B.$$.fragment,s),d(D.$$.fragment,s),d(Q.$$.fragment,s),d(A.$$.fragment,s),d(m.$$.fragment,s),d(us.$$.fragment,s),d(ds.$$.fragment,s),d(js.$$.fragment,s),d(ws.$$.fragment,s),d(Ts.$$.fragment,s),d(ls.$$.fragment,s),d(ns.$$.fragment,s),d($s.$$.fragment,s),d(_s.$$.fragment,s),d(Cs.$$.fragment,s),d(ks.$$.fragment,s),d(ps.$$.fragment,s),d(rs.$$.fragment,s),d(os.$$.fragment,s),d(vs.$$.fragment,s),d(Xs.$$.fragment,s),d(Rs.$$.fragment,s),d(ms.$$.fragment,s),d(cs.$$.fragment,s),d(Vs.$$.fragment,s),Ua=!1},d(s){s&&(a(h),a(l),a(c),a(C),a(v),a(F),a(I),a(Y),a(T),a(r),a(U),a(G),a(p),a(j),a(f),a(K),a(H),a(L),a(O),a(ss),a(S),a(as),a(es),a(q),a(ts),a(k),a(P),a(Qs),a(Ss),a(ys),a(As),a(gs),a(qs),a(Ms),a(Ls),a(Ds),a(bs),a(Ps),a(Ks),a(Os),a(Js),a(sa),a(aa),a(ea),a(ta),a(la),a(Us),a(na),a(pa),a(Zs),a(ra),a(oa),a(Is),a(ia),a(ma),a(ca),a(ha),a(fa),a(ua),a(Gs),a(ya),a(Ws),a(ga),a(Ma),a(is),a(da),a(Ys),a(ba),a(ja),a(Fs),a(wa),a(Ja),a(Ta),a($a),a(Hs)),a(t),b($,s),b(R,s),b(Z,s),b(z,s),b(B,s),b(D,s),b(Q,s),b(A,s),b(m,s),b(us,s),b(ds,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(ks,s),b(ps,s),b(rs,s),b(os,s),b(vs,s),b(Xs,s),b(Rs,s),b(ms,s),b(cs,s),b(Vs,s)}}}const Te='{"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 $e(X){return Ka(()=>{new URLSearchParams(window.location.search).get("fw")}),[]}class We extends Oa{constructor(t){super(),se(this,t,$e,Je,Pa,{})}}export{We as component};
