import{S as hd,i as md,s as ud,e as p,k as h,w as j,t as n,M as id,c as r,d as e,m,a as o,x as f,h as l,b as i,N as rd,G as a,g as c,y as b,q as g,o as y,B as w,v as dd,L as od}from"../chunks/vendor-hf-doc-builder.js";import{T as ke}from"../chunks/Tip-hf-doc-builder.js";import{Y as jd}from"../chunks/Youtube-hf-doc-builder.js";import{I as Is}from"../chunks/IconCopyLink-hf-doc-builder.js";import{C as E}from"../chunks/CodeBlock-hf-doc-builder.js";import{D as fd}from"../chunks/DocNotebookDropdown-hf-doc-builder.js";import{F as bd,M as cd}from"../chunks/Markdown-hf-doc-builder.js";function gd(I){let u,_,d,J,$,v,M;return{c(){u=p("p"),_=p("code"),d=n("AutoProcessor"),J=h(),$=p("strong"),v=n("always"),M=n(" works and automatically chooses the correct class for the model you\u2019re using, whether you\u2019re using a tokenizer, image processor, feature extractor or processor.")},l(k){u=r(k,"P",{});var x=o(u);_=r(x,"CODE",{});var Z=o(_);d=l(Z,"AutoProcessor"),Z.forEach(e),J=m(x),$=r(x,"STRONG",{});var U=o($);v=l(U,"always"),U.forEach(e),M=l(x," works and automatically chooses the correct class for the model you\u2019re using, whether you\u2019re using a tokenizer, image processor, feature extractor or processor."),x.forEach(e)},m(k,x){c(k,u,x),a(u,_),a(_,d),a(u,J),a(u,$),a($,v),a(u,M)},d(k){k&&e(u)}}}function yd(I){let u,_,d,J,$;return{c(){u=p("p"),_=n("If you plan on using a pretrained model, it\u2019s important to use the associated pretrained tokenizer. This ensures the text is split the same way as the pretraining corpus, and uses the same corresponding tokens-to-index (usually referred to as the "),d=p("em"),J=n("vocab"),$=n(") during pretraining.")},l(v){u=r(v,"P",{});var M=o(u);_=l(M,"If you plan on using a pretrained model, it\u2019s important to use the associated pretrained tokenizer. This ensures the text is split the same way as the pretraining corpus, and uses the same corresponding tokens-to-index (usually referred to as the "),d=r(M,"EM",{});var k=o(d);J=l(k,"vocab"),k.forEach(e),$=l(M,") during pretraining."),M.forEach(e)},m(v,M){c(v,u,M),a(u,_),a(u,d),a(d,J),a(u,$)},d(v){v&&e(u)}}}function wd(I){let u,_,d,J,$;return{c(){u=p("p"),_=n("Check out the "),d=p("a"),J=n("Padding and truncation"),$=n(" concept guide to learn more different padding and truncation arguments."),this.h()},l(v){u=r(v,"P",{});var M=o(u);_=l(M,"Check out the "),d=r(M,"A",{href:!0});var k=o(d);J=l(k,"Padding and truncation"),k.forEach(e),$=l(M," concept guide to learn more different padding and truncation arguments."),M.forEach(e),this.h()},h(){i(d,"href","./pad_truncation")},m(v,M){c(v,u,M),a(u,_),a(u,d),a(d,J),a(u,$)},d(v){v&&e(u)}}}function Jd(I){let u,_;return u=new E({props:{code:"YmF0Y2hfc2VudGVuY2VzJTIwJTNEJTIwJTVCJTBBJTIwJTIwJTIwJTIwJTIyQnV0JTIwd2hhdCUyMGFib3V0JTIwc2Vjb25kJTIwYnJlYWtmYXN0JTNGJTIyJTJDJTBBJTIwJTIwJTIwJTIwJTIyRG9uJ3QlMjB0aGluayUyMGhlJTIwa25vd3MlMjBhYm91dCUyMHNlY29uZCUyMGJyZWFrZmFzdCUyQyUyMFBpcC4lMjIlMkMlMEElMjAlMjAlMjAlMjAlMjJXaGF0JTIwYWJvdXQlMjBlbGV2ZW5zaWVzJTNGJTIyJTJDJTBBJTVEJTBBZW5jb2RlZF9pbnB1dCUyMCUzRCUyMHRva2VuaXplcihiYXRjaF9zZW50ZW5jZXMlMkMlMjBwYWRkaW5nJTNEVHJ1ZSUyQyUyMHRydW5jYXRpb24lM0RUcnVlJTJDJTIwcmV0dXJuX3RlbnNvcnMlM0QlMjJwdCUyMiklMEFwcmludChlbmNvZGVkX2lucHV0KQ==",highlighted:`<span class="hljs-meta">&gt;&gt;&gt; </span>batch_sentences = [
<span class="hljs-meta">... </span>    <span class="hljs-string">&quot;But what about second breakfast?&quot;</span>,
<span class="hljs-meta">... </span>    <span class="hljs-string">&quot;Don&#x27;t think he knows about second breakfast, Pip.&quot;</span>,
<span class="hljs-meta">... </span>    <span class="hljs-string">&quot;What about elevensies?&quot;</span>,
<span class="hljs-meta">... </span>]
<span class="hljs-meta">&gt;&gt;&gt; </span>encoded_input = tokenizer(batch_sentences, padding=<span class="hljs-literal">True</span>, truncation=<span class="hljs-literal">True</span>, return_tensors=<span class="hljs-string">&quot;pt&quot;</span>)
<span class="hljs-meta">&gt;&gt;&gt; </span><span class="hljs-built_in">print</span>(encoded_input)
{<span class="hljs-string">&#x27;input_ids&#x27;</span>: tensor([[<span class="hljs-number">101</span>, <span class="hljs-number">1252</span>, <span class="hljs-number">1184</span>, <span class="hljs-number">1164</span>, <span class="hljs-number">1248</span>, <span class="hljs-number">6462</span>, <span class="hljs-number">136</span>, <span class="hljs-number">102</span>, <span class="hljs-number">0</span>, <span class="hljs-number">0</span>, <span class="hljs-number">0</span>, <span class="hljs-number">0</span>, <span class="hljs-number">0</span>, <span class="hljs-number">0</span>, <span class="hljs-number">0</span>],
                      [<span class="hljs-number">101</span>, <span class="hljs-number">1790</span>, <span class="hljs-number">112</span>, <span class="hljs-number">189</span>, <span class="hljs-number">1341</span>, <span class="hljs-number">1119</span>, <span class="hljs-number">3520</span>, <span class="hljs-number">1164</span>, <span class="hljs-number">1248</span>, <span class="hljs-number">6462</span>, <span class="hljs-number">117</span>, <span class="hljs-number">21902</span>, <span class="hljs-number">1643</span>, <span class="hljs-number">119</span>, <span class="hljs-number">102</span>],
                      [<span class="hljs-number">101</span>, <span class="hljs-number">1327</span>, <span class="hljs-number">1164</span>, <span class="hljs-number">5450</span>, <span class="hljs-number">23434</span>, <span class="hljs-number">136</span>, <span class="hljs-number">102</span>, <span class="hljs-number">0</span>, <span class="hljs-number">0</span>, <span class="hljs-number">0</span>, <span class="hljs-number">0</span>, <span class="hljs-number">0</span>, <span class="hljs-number">0</span>, <span class="hljs-number">0</span>, <span class="hljs-number">0</span>]]),
 <span class="hljs-string">&#x27;token_type_ids&#x27;</span>: tensor([[<span class="hljs-number">0</span>, <span class="hljs-number">0</span>, <span class="hljs-number">0</span>, <span class="hljs-number">0</span>, <span class="hljs-number">0</span>, <span class="hljs-number">0</span>, <span class="hljs-number">0</span>, <span class="hljs-number">0</span>, <span class="hljs-number">0</span>, <span class="hljs-number">0</span>, <span class="hljs-number">0</span>, <span class="hljs-number">0</span>, <span class="hljs-number">0</span>, <span class="hljs-number">0</span>, <span class="hljs-number">0</span>],
                           [<span class="hljs-number">0</span>, <span class="hljs-number">0</span>, <span class="hljs-number">0</span>, <span class="hljs-number">0</span>, <span class="hljs-number">0</span>, <span class="hljs-number">0</span>, <span class="hljs-number">0</span>, <span class="hljs-number">0</span>, <span class="hljs-number">0</span>, <span class="hljs-number">0</span>, <span class="hljs-number">0</span>, <span class="hljs-number">0</span>, <span class="hljs-number">0</span>, <span class="hljs-number">0</span>, <span class="hljs-number">0</span>],
                           [<span class="hljs-number">0</span>, <span class="hljs-number">0</span>, <span class="hljs-number">0</span>, <span class="hljs-number">0</span>, <span class="hljs-number">0</span>, <span class="hljs-number">0</span>, <span class="hljs-number">0</span>, <span class="hljs-number">0</span>, <span class="hljs-number">0</span>, <span class="hljs-number">0</span>, <span class="hljs-number">0</span>, <span class="hljs-number">0</span>, <span class="hljs-number">0</span>, <span class="hljs-number">0</span>, <span class="hljs-number">0</span>]]),
 <span class="hljs-string">&#x27;attention_mask&#x27;</span>: tensor([[<span class="hljs-number">1</span>, <span class="hljs-number">1</span>, <span class="hljs-number">1</span>, <span class="hljs-number">1</span>, <span class="hljs-number">1</span>, <span class="hljs-number">1</span>, <span class="hljs-number">1</span>, <span class="hljs-number">1</span>, <span class="hljs-number">0</span>, <span class="hljs-number">0</span>, <span class="hljs-number">0</span>, <span class="hljs-number">0</span>, <span class="hljs-number">0</span>, <span class="hljs-number">0</span>, <span class="hljs-number">0</span>],
                           [<span class="hljs-number">1</span>, <span class="hljs-number">1</span>, <span class="hljs-number">1</span>, <span class="hljs-number">1</span>, <span class="hljs-number">1</span>, <span class="hljs-number">1</span>, <span class="hljs-number">1</span>, <span class="hljs-number">1</span>, <span class="hljs-number">1</span>, <span class="hljs-number">1</span>, <span class="hljs-number">1</span>, <span class="hljs-number">1</span>, <span class="hljs-number">1</span>, <span class="hljs-number">1</span>, <span class="hljs-number">1</span>],
                           [<span class="hljs-number">1</span>, <span class="hljs-number">1</span>, <span class="hljs-number">1</span>, <span class="hljs-number">1</span>, <span class="hljs-number">1</span>, <span class="hljs-number">1</span>, <span class="hljs-number">1</span>, <span class="hljs-number">0</span>, <span class="hljs-number">0</span>, <span class="hljs-number">0</span>, <span class="hljs-number">0</span>, <span class="hljs-number">0</span>, <span class="hljs-number">0</span>, <span class="hljs-number">0</span>, <span class="hljs-number">0</span>]])}`}}),{c(){j(u.$$.fragment)},l(d){f(u.$$.fragment,d)},m(d,J){b(u,d,J),_=!0},p:od,i(d){_||(g(u.$$.fragment,d),_=!0)},o(d){y(u.$$.fragment,d),_=!1},d(d){w(u,d)}}}function _d(I){let u,_;return u=new cd({props:{$$slots:{default:[Jd]},$$scope:{ctx:I}}}),{c(){j(u.$$.fragment)},l(d){f(u.$$.fragment,d)},m(d,J){b(u,d,J),_=!0},p(d,J){const $={};J&2&&($.$$scope={dirty:J,ctx:d}),u.$set($)},i(d){_||(g(u.$$.fragment,d),_=!0)},o(d){y(u.$$.fragment,d),_=!1},d(d){w(u,d)}}}function vd(I){let u,_;return u=new E({props:{code:"YmF0Y2hfc2VudGVuY2VzJTIwJTNEJTIwJTVCJTBBJTIwJTIwJTIwJTIwJTIyQnV0JTIwd2hhdCUyMGFib3V0JTIwc2Vjb25kJTIwYnJlYWtmYXN0JTNGJTIyJTJDJTBBJTIwJTIwJTIwJTIwJTIyRG9uJ3QlMjB0aGluayUyMGhlJTIwa25vd3MlMjBhYm91dCUyMHNlY29uZCUyMGJyZWFrZmFzdCUyQyUyMFBpcC4lMjIlMkMlMEElMjAlMjAlMjAlMjAlMjJXaGF0JTIwYWJvdXQlMjBlbGV2ZW5zaWVzJTNGJTIyJTJDJTBBJTVEJTBBZW5jb2RlZF9pbnB1dCUyMCUzRCUyMHRva2VuaXplcihiYXRjaF9zZW50ZW5jZXMlMkMlMjBwYWRkaW5nJTNEVHJ1ZSUyQyUyMHRydW5jYXRpb24lM0RUcnVlJTJDJTIwcmV0dXJuX3RlbnNvcnMlM0QlMjJ0ZiUyMiklMEFwcmludChlbmNvZGVkX2lucHV0KQ==",highlighted:`<span class="hljs-meta">&gt;&gt;&gt; </span>batch_sentences = [
<span class="hljs-meta">... </span>    <span class="hljs-string">&quot;But what about second breakfast?&quot;</span>,
<span class="hljs-meta">... </span>    <span class="hljs-string">&quot;Don&#x27;t think he knows about second breakfast, Pip.&quot;</span>,
<span class="hljs-meta">... </span>    <span class="hljs-string">&quot;What about elevensies?&quot;</span>,
<span class="hljs-meta">... </span>]
<span class="hljs-meta">&gt;&gt;&gt; </span>encoded_input = tokenizer(batch_sentences, padding=<span class="hljs-literal">True</span>, truncation=<span class="hljs-literal">True</span>, return_tensors=<span class="hljs-string">&quot;tf&quot;</span>)
<span class="hljs-meta">&gt;&gt;&gt; </span><span class="hljs-built_in">print</span>(encoded_input)
{<span class="hljs-string">&#x27;input_ids&#x27;</span>: &lt;tf.Tensor: shape=(<span class="hljs-number">2</span>, <span class="hljs-number">9</span>), dtype=int32, numpy=
array([[<span class="hljs-number">101</span>, <span class="hljs-number">1252</span>, <span class="hljs-number">1184</span>, <span class="hljs-number">1164</span>, <span class="hljs-number">1248</span>, <span class="hljs-number">6462</span>, <span class="hljs-number">136</span>, <span class="hljs-number">102</span>, <span class="hljs-number">0</span>, <span class="hljs-number">0</span>, <span class="hljs-number">0</span>, <span class="hljs-number">0</span>, <span class="hljs-number">0</span>, <span class="hljs-number">0</span>, <span class="hljs-number">0</span>],
       [<span class="hljs-number">101</span>, <span class="hljs-number">1790</span>, <span class="hljs-number">112</span>, <span class="hljs-number">189</span>, <span class="hljs-number">1341</span>, <span class="hljs-number">1119</span>, <span class="hljs-number">3520</span>, <span class="hljs-number">1164</span>, <span class="hljs-number">1248</span>, <span class="hljs-number">6462</span>, <span class="hljs-number">117</span>, <span class="hljs-number">21902</span>, <span class="hljs-number">1643</span>, <span class="hljs-number">119</span>, <span class="hljs-number">102</span>],
       [<span class="hljs-number">101</span>, <span class="hljs-number">1327</span>, <span class="hljs-number">1164</span>, <span class="hljs-number">5450</span>, <span class="hljs-number">23434</span>, <span class="hljs-number">136</span>, <span class="hljs-number">102</span>, <span class="hljs-number">0</span>, <span class="hljs-number">0</span>, <span class="hljs-number">0</span>, <span class="hljs-number">0</span>, <span class="hljs-number">0</span>, <span class="hljs-number">0</span>, <span class="hljs-number">0</span>, <span class="hljs-number">0</span>]],
      dtype=int32)&gt;,
 <span class="hljs-string">&#x27;token_type_ids&#x27;</span>: &lt;tf.Tensor: shape=(<span class="hljs-number">2</span>, <span class="hljs-number">9</span>), dtype=int32, numpy=
array([[<span class="hljs-number">0</span>, <span class="hljs-number">0</span>, <span class="hljs-number">0</span>, <span class="hljs-number">0</span>, <span class="hljs-number">0</span>, <span class="hljs-number">0</span>, <span class="hljs-number">0</span>, <span class="hljs-number">0</span>, <span class="hljs-number">0</span>, <span class="hljs-number">0</span>, <span class="hljs-number">0</span>, <span class="hljs-number">0</span>, <span class="hljs-number">0</span>, <span class="hljs-number">0</span>, <span class="hljs-number">0</span>],
       [<span class="hljs-number">0</span>, <span class="hljs-number">0</span>, <span class="hljs-number">0</span>, <span class="hljs-number">0</span>, <span class="hljs-number">0</span>, <span class="hljs-number">0</span>, <span class="hljs-number">0</span>, <span class="hljs-number">0</span>, <span class="hljs-number">0</span>, <span class="hljs-number">0</span>, <span class="hljs-number">0</span>, <span class="hljs-number">0</span>, <span class="hljs-number">0</span>, <span class="hljs-number">0</span>, <span class="hljs-number">0</span>],
       [<span class="hljs-number">0</span>, <span class="hljs-number">0</span>, <span class="hljs-number">0</span>, <span class="hljs-number">0</span>, <span class="hljs-number">0</span>, <span class="hljs-number">0</span>, <span class="hljs-number">0</span>, <span class="hljs-number">0</span>, <span class="hljs-number">0</span>, <span class="hljs-number">0</span>, <span class="hljs-number">0</span>, <span class="hljs-number">0</span>, <span class="hljs-number">0</span>, <span class="hljs-number">0</span>, <span class="hljs-number">0</span>]], dtype=int32)&gt;,
 <span class="hljs-string">&#x27;attention_mask&#x27;</span>: &lt;tf.Tensor: shape=(<span class="hljs-number">2</span>, <span class="hljs-number">9</span>), dtype=int32, numpy=
array([[<span class="hljs-number">1</span>, <span class="hljs-number">1</span>, <span class="hljs-number">1</span>, <span class="hljs-number">1</span>, <span class="hljs-number">1</span>, <span class="hljs-number">1</span>, <span class="hljs-number">1</span>, <span class="hljs-number">1</span>, <span class="hljs-number">0</span>, <span class="hljs-number">0</span>, <span class="hljs-number">0</span>, <span class="hljs-number">0</span>, <span class="hljs-number">0</span>, <span class="hljs-number">0</span>, <span class="hljs-number">0</span>],
       [<span class="hljs-number">1</span>, <span class="hljs-number">1</span>, <span class="hljs-number">1</span>, <span class="hljs-number">1</span>, <span class="hljs-number">1</span>, <span class="hljs-number">1</span>, <span class="hljs-number">1</span>, <span class="hljs-number">1</span>, <span class="hljs-number">1</span>, <span class="hljs-number">1</span>, <span class="hljs-number">1</span>, <span class="hljs-number">1</span>, <span class="hljs-number">1</span>, <span class="hljs-number">1</span>, <span class="hljs-number">1</span>],
       [<span class="hljs-number">1</span>, <span class="hljs-number">1</span>, <span class="hljs-number">1</span>, <span class="hljs-number">1</span>, <span class="hljs-number">1</span>, <span class="hljs-number">1</span>, <span class="hljs-number">1</span>, <span class="hljs-number">0</span>, <span class="hljs-number">0</span>, <span class="hljs-number">0</span>, <span class="hljs-number">0</span>, <span class="hljs-number">0</span>, <span class="hljs-number">0</span>, <span class="hljs-number">0</span>, <span class="hljs-number">0</span>]], dtype=int32)&gt;}`}}),{c(){j(u.$$.fragment)},l(d){f(u.$$.fragment,d)},m(d,J){b(u,d,J),_=!0},p:od,i(d){_||(g(u.$$.fragment,d),_=!0)},o(d){y(u.$$.fragment,d),_=!1},d(d){w(u,d)}}}function $d(I){let u,_;return u=new cd({props:{$$slots:{default:[vd]},$$scope:{ctx:I}}}),{c(){j(u.$$.fragment)},l(d){f(u.$$.fragment,d)},m(d,J){b(u,d,J),_=!0},p(d,J){const $={};J&2&&($.$$scope={dirty:J,ctx:d}),u.$set($)},i(d){_||(g(u.$$.fragment,d),_=!0)},o(d){y(u.$$.fragment,d),_=!1},d(d){w(u,d)}}}function Md(I){let u,_,d,J,$,v,M,k,x,Z,U,B,A,S,Y;return{c(){u=p("p"),_=n(`Image preprocessing often follows some form of image augmentation. Both image preprocessing and image augmentation
transform image data, but they serve different purposes:`),d=h(),J=p("ul"),$=p("li"),v=n("Image augmentation alters images in a way that can help prevent overfitting and increase the robustness of the model. You can get creative in how you augment your data - adjust brightness and colors, crop, rotate, resize, zoom, etc. However, be mindful not to change the meaning of the images with your augmentations."),M=h(),k=p("li"),x=n("Image preprocessing guarantees that the images match the model\u2019s expected input format. When fine-tuning a computer vision model, images must be preprocessed exactly as when the model was initially trained."),Z=h(),U=p("p"),B=n("You can use any library you like for image augmentation. For image preprocessing, use the "),A=p("code"),S=n("ImageProcessor"),Y=n(" associated with the model.")},l(T){u=r(T,"P",{});var G=o(u);_=l(G,`Image preprocessing often follows some form of image augmentation. Both image preprocessing and image augmentation
transform image data, but they serve different purposes:`),G.forEach(e),d=m(T),J=r(T,"UL",{});var W=o(J);$=r(W,"LI",{});var q=o($);v=l(q,"Image augmentation alters images in a way that can help prevent overfitting and increase the robustness of the model. You can get creative in how you augment your data - adjust brightness and colors, crop, rotate, resize, zoom, etc. However, be mindful not to change the meaning of the images with your augmentations."),q.forEach(e),M=m(W),k=r(W,"LI",{});var K=o(k);x=l(K,"Image preprocessing guarantees that the images match the model\u2019s expected input format. When fine-tuning a computer vision model, images must be preprocessed exactly as when the model was initially trained."),K.forEach(e),W.forEach(e),Z=m(T),U=r(T,"P",{});var N=o(U);B=l(N,"You can use any library you like for image augmentation. For image preprocessing, use the "),A=r(N,"CODE",{});var ss=o(A);S=l(ss,"ImageProcessor"),ss.forEach(e),Y=l(N," associated with the model."),N.forEach(e)},m(T,G){c(T,u,G),a(u,_),c(T,d,G),c(T,J,G),a(J,$),a($,v),a(J,M),a(J,k),a(k,x),c(T,Z,G),c(T,U,G),a(U,B),a(U,A),a(A,S),a(U,Y)},d(T){T&&e(u),T&&e(d),T&&e(J),T&&e(Z),T&&e(U)}}}function Td(I){let u,_,d,J,$;return{c(){u=p("p"),_=n("Use \u{1F917} Datasets "),d=p("code"),J=n("split"),$=n(" parameter to only load a small sample from the training split since the dataset is quite large!")},l(v){u=r(v,"P",{});var M=o(u);_=l(M,"Use \u{1F917} Datasets "),d=r(M,"CODE",{});var k=o(d);J=l(k,"split"),k.forEach(e),$=l(M," parameter to only load a small sample from the training split since the dataset is quite large!"),M.forEach(e)},m(v,M){c(v,u,M),a(u,_),a(u,d),a(d,J),a(u,$)},d(v){v&&e(u)}}}function Ed(I){let u,_,d,J,$,v,M,k,x,Z,U,B,A,S,Y,T,G,W,q,K,N,ss,H;return{c(){u=p("p"),_=n("In the example above we set "),d=p("code"),J=n("do_resize=False"),$=n(` because we have already resized the images in the image augmentation transformation,
and leveraged the `),v=p("code"),M=n("size"),k=n(" attribute from the appropriate "),x=p("code"),Z=n("image_processor"),U=n(`. If you do not resize images during image augmentation,
leave this parameter out. By default, `),B=p("code"),A=n("ImageProcessor"),S=n(" will handle the resizing."),Y=h(),T=p("p"),G=n("If you wish to normalize images as a part of the augmentation transformation, use the "),W=p("code"),q=n("image_processor.image_mean"),K=n(`,
and `),N=p("code"),ss=n("image_processor.image_std"),H=n(" values.")},l(V){u=r(V,"P",{});var C=o(u);_=l(C,"In the example above we set "),d=r(C,"CODE",{});var Ie=o(d);J=l(Ie,"do_resize=False"),Ie.forEach(e),$=l(C,` because we have already resized the images in the image augmentation transformation,
and leveraged the `),v=r(C,"CODE",{});var Ue=o(v);M=l(Ue,"size"),Ue.forEach(e),k=l(C," attribute from the appropriate "),x=r(C,"CODE",{});var xe=o(x);Z=l(xe,"image_processor"),xe.forEach(e),U=l(C,`. If you do not resize images during image augmentation,
leave this parameter out. By default, `),B=r(C,"CODE",{});var as=o(B);A=l(as,"ImageProcessor"),as.forEach(e),S=l(C," will handle the resizing."),C.forEach(e),Y=m(V),T=r(V,"P",{});var es=o(T);G=l(es,"If you wish to normalize images as a part of the augmentation transformation, use the "),W=r(es,"CODE",{});var ws=o(W);q=l(ws,"image_processor.image_mean"),ws.forEach(e),K=l(es,`,
and `),N=r(es,"CODE",{});var Ce=o(N);ss=l(Ce,"image_processor.image_std"),Ce.forEach(e),H=l(es," values."),es.forEach(e)},m(V,C){c(V,u,C),a(u,_),a(u,d),a(d,J),a(u,$),a(u,v),a(v,M),a(u,k),a(u,x),a(x,Z),a(u,U),a(u,B),a(B,A),a(u,S),c(V,Y,C),c(V,T,C),a(T,G),a(T,W),a(W,q),a(T,K),a(T,N),a(N,ss),a(T,H)},d(V){V&&e(u),V&&e(Y),V&&e(T)}}}function kd(I){let u,_,d,J,$;return{c(){u=p("p"),_=n("For tasks like object detection, semantic segmentation, instance segmentation, and panoptic segmentation, "),d=p("code"),J=n("ImageProcessor"),$=n(`
offers post processing methods. These methods convert model\u2019s raw outputs into meaningful predictions such as bounding boxes,
or segmentation maps.`)},l(v){u=r(v,"P",{});var M=o(u);_=l(M,"For tasks like object detection, semantic segmentation, instance segmentation, and panoptic segmentation, "),d=r(M,"CODE",{});var k=o(d);J=l(k,"ImageProcessor"),k.forEach(e),$=l(M,`
offers post processing methods. These methods convert model\u2019s raw outputs into meaningful predictions such as bounding boxes,
or segmentation maps.`),M.forEach(e)},m(v,M){c(v,u,M),a(u,_),a(u,d),a(d,J),a(u,$)},d(v){v&&e(u)}}}function Id(I){let u,_,d,J,$,v,M,k,x,Z,U,B,A,S,Y,T,G,W,q,K,N,ss,H,V,C,Ie,Ue,xe,as,es,ws,Ce,_r,vr,ca,$r,Ge,Mr,Tr,Ll,Us,Ol,Ze,Er,Kl,ha,st,Js,xs,xn,ma,kr,Cn,Ir,at,ua,et,ns,Ur,Ae,xr,Cr,Gn,Gr,Zr,nt,Cs,lt,ls,Ar,Ve,Vr,zr,Zn,Br,Wr,tt,ia,pt,ze,Nr,rt,da,ot,Be,Rr,ct,ts,We,Ne,Yr,qr,Fr,Re,Ye,Xr,Qr,Pr,qe,Fe,Dr,Sr,ht,Gs,Hr,An,Lr,Or,mt,ja,ut,ps,Kr,Vn,so,ao,zn,eo,no,it,Xe,lo,dt,fa,jt,_s,Zs,Bn,ba,to,Wn,po,ft,As,ro,Nn,oo,co,bt,rs,ho,Rn,mo,uo,Yn,io,jo,gt,ga,yt,Vs,fo,qn,bo,go,wt,vs,zs,Fn,ya,yo,Xn,wo,Jt,Qe,Jo,_t,os,_o,Qn,vo,$o,Pn,Mo,To,vt,wa,$t,Bs,Mt,$s,Ws,Dn,Ja,Eo,Sn,ko,Tt,Pe,Io,Et,X,Uo,Hn,xo,Co,Ln,Go,Zo,On,Ao,Vo,kt,Ns,It,Ms,Rs,Kn,_a,zo,sl,Bo,Ut,Ys,Wo,De,No,Ro,xt,cs,Yo,va,qo,Fo,$a,Xo,Qo,Ct,Ma,Gt,hs,Po,al,Do,So,el,Ho,Lo,Zt,Ta,At,Se,Oo,Vt,ms,He,nl,Ko,sc,ac,Le,ll,ec,nc,lc,Oe,tl,tc,pc,zt,qs,rc,Ea,oc,cc,Bt,Ke,ka,hc,Ia,mc,uc,Wt,Ua,Nt,xa,Ca,ic,pl,dc,jc,Rt,Ga,Yt,Q,fc,rl,bc,gc,ol,yc,wc,cl,Jc,_c,qt,Fs,vc,sn,$c,Mc,Ft,Za,Xt,us,Tc,hl,Ec,kc,ml,Ic,Uc,Qt,Aa,Pt,an,xc,Dt,Va,St,en,Cc,Ht,za,Lt,Xs,Gc,ul,Zc,Ac,Ot,Ba,Kt,nn,Vc,sp,Wa,ap,Ts,Qs,il,Na,zc,dl,Bc,ep,Ps,Wc,ln,Nc,Rc,np,Ds,lp,is,Yc,Ra,qc,Fc,Ya,Xc,Qc,tp,Ss,pp,qa,rp,Hs,Pc,Fa,jl,Dc,Sc,op,Xa,cp,Qa,fl,zm,hp,Ls,Hc,tn,Lc,Oc,mp,Pa,up,P,Kc,Da,bl,sh,ah,Sa,eh,nh,Ha,lh,th,ip,pn,z,ph,La,gl,rh,oh,Oa,yl,ch,hh,Ka,wl,mh,uh,Jl,ih,dh,_l,jh,fh,dp,se,jp,ae,L,bh,rn,vl,gh,yh,$l,wh,Jh,Ml,_h,vh,fp,ee,bp,Os,gp,ne,le,$h,te,Tl,Mh,Th,yp,pe,wp,re,oe,Eh,El,kh,Ih,Jp,ce,_p,on,Uh,vp,he,$p,me,kl,Bm,Mp,Ks,Tp,Es,sa,Il,ue,xh,Ul,Ch,Ep,R,Gh,cn,Zh,Ah,xl,Vh,zh,hn,Bh,Wh,Cl,Nh,Rh,kp,ie,Ip,ks,aa,Gl,de,Yh,Zl,qh,Up,ea,Fh,mn,Xh,Qh,xp,ds,Ph,je,Dh,Sh,fe,Hh,Lh,Cp,be,Gp,js,Oh,Al,Kh,sm,Vl,am,em,Zp,ge,Ap,fs,nm,zl,lm,tm,Bl,pm,rm,Vp,ye,zp,na,om,un,cm,hm,Bp,we,Wp,la,mm,dn,um,im,Np,Je,Rp,jn,F,dm,Wl,jm,fm,Nl,bm,gm,Rl,ym,wm,Yl,Jm,_m,Yp,_e,qp,ve,$e,vm,ql,$m,Mm,Fp,Me,Xp,bs,Tm,Fl,Em,km,Xl,Im,Um,Qp;return v=new Is({}),U=new fd({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/preprocessing.ipynb"},{label:"PyTorch",value:"https://colab.research.google.com/github/huggingface/notebooks/blob/main/transformers_doc/en/pytorch/preprocessing.ipynb"},{label:"TensorFlow",value:"https://colab.research.google.com/github/huggingface/notebooks/blob/main/transformers_doc/en/tensorflow/preprocessing.ipynb"},{label:"Mixed",value:"https://studiolab.sagemaker.aws/import/github/huggingface/notebooks/blob/main/transformers_doc/en/preprocessing.ipynb"},{label:"PyTorch",value:"https://studiolab.sagemaker.aws/import/github/huggingface/notebooks/blob/main/transformers_doc/en/pytorch/preprocessing.ipynb"},{label:"TensorFlow",value:"https://studiolab.sagemaker.aws/import/github/huggingface/notebooks/blob/main/transformers_doc/en/tensorflow/preprocessing.ipynb"}]}}),Us=new ke({props:{$$slots:{default:[gd]},$$scope:{ctx:I}}}),ha=new E({props:{code:"cGlwJTIwaW5zdGFsbCUyMGRhdGFzZXRz",highlighted:"pip install datasets"}}),ma=new Is({}),ua=new jd({props:{id:"Yffk5aydLzg"}}),Cs=new ke({props:{$$slots:{default:[yd]},$$scope:{ctx:I}}}),ia=new E({props:{code:"ZnJvbSUyMHRyYW5zZm9ybWVycyUyMGltcG9ydCUyMEF1dG9Ub2tlbml6ZXIlMEElMEF0b2tlbml6ZXIlMjAlM0QlMjBBdXRvVG9rZW5pemVyLmZyb21fcHJldHJhaW5lZCglMjJiZXJ0LWJhc2UtY2FzZWQlMjIp",highlighted:`<span class="hljs-meta">&gt;&gt;&gt; </span><span class="hljs-keyword">from</span> transformers <span class="hljs-keyword">import</span> AutoTokenizer

<span class="hljs-meta">&gt;&gt;&gt; </span>tokenizer = AutoTokenizer.from_pretrained(<span class="hljs-string">&quot;bert-base-cased&quot;</span>)`}}),da=new E({props:{code:"ZW5jb2RlZF9pbnB1dCUyMCUzRCUyMHRva2VuaXplciglMjJEbyUyMG5vdCUyMG1lZGRsZSUyMGluJTIwdGhlJTIwYWZmYWlycyUyMG9mJTIwd2l6YXJkcyUyQyUyMGZvciUyMHRoZXklMjBhcmUlMjBzdWJ0bGUlMjBhbmQlMjBxdWljayUyMHRvJTIwYW5nZXIuJTIyKSUwQXByaW50KGVuY29kZWRfaW5wdXQp",highlighted:`<span class="hljs-meta">&gt;&gt;&gt; </span>encoded_input = tokenizer(<span class="hljs-string">&quot;Do not meddle in the affairs of wizards, for they are subtle and quick to anger.&quot;</span>)
<span class="hljs-meta">&gt;&gt;&gt; </span><span class="hljs-built_in">print</span>(encoded_input)
{<span class="hljs-string">&#x27;input_ids&#x27;</span>: [<span class="hljs-number">101</span>, <span class="hljs-number">2079</span>, <span class="hljs-number">2025</span>, <span class="hljs-number">19960</span>, <span class="hljs-number">10362</span>, <span class="hljs-number">1999</span>, <span class="hljs-number">1996</span>, <span class="hljs-number">3821</span>, <span class="hljs-number">1997</span>, <span class="hljs-number">16657</span>, <span class="hljs-number">1010</span>, <span class="hljs-number">2005</span>, <span class="hljs-number">2027</span>, <span class="hljs-number">2024</span>, <span class="hljs-number">11259</span>, <span class="hljs-number">1998</span>, <span class="hljs-number">4248</span>, <span class="hljs-number">2000</span>, <span class="hljs-number">4963</span>, <span class="hljs-number">1012</span>, <span class="hljs-number">102</span>],
 <span class="hljs-string">&#x27;token_type_ids&#x27;</span>: [<span class="hljs-number">0</span>, <span class="hljs-number">0</span>, <span class="hljs-number">0</span>, <span class="hljs-number">0</span>, <span class="hljs-number">0</span>, <span class="hljs-number">0</span>, <span class="hljs-number">0</span>, <span class="hljs-number">0</span>, <span class="hljs-number">0</span>, <span class="hljs-number">0</span>, <span class="hljs-number">0</span>, <span class="hljs-number">0</span>, <span class="hljs-number">0</span>, <span class="hljs-number">0</span>, <span class="hljs-number">0</span>, <span class="hljs-number">0</span>, <span class="hljs-number">0</span>, <span class="hljs-number">0</span>, <span class="hljs-number">0</span>, <span class="hljs-number">0</span>, <span class="hljs-number">0</span>],
 <span class="hljs-string">&#x27;attention_mask&#x27;</span>: [<span class="hljs-number">1</span>, <span class="hljs-number">1</span>, <span class="hljs-number">1</span>, <span class="hljs-number">1</span>, <span class="hljs-number">1</span>, <span class="hljs-number">1</span>, <span class="hljs-number">1</span>, <span class="hljs-number">1</span>, <span class="hljs-number">1</span>, <span class="hljs-number">1</span>, <span class="hljs-number">1</span>, <span class="hljs-number">1</span>, <span class="hljs-number">1</span>, <span class="hljs-number">1</span>, <span class="hljs-number">1</span>, <span class="hljs-number">1</span>, <span class="hljs-number">1</span>, <span class="hljs-number">1</span>, <span class="hljs-number">1</span>, <span class="hljs-number">1</span>, <span class="hljs-number">1</span>]}`}}),ja=new E({props:{code:"dG9rZW5pemVyLmRlY29kZShlbmNvZGVkX2lucHV0JTVCJTIyaW5wdXRfaWRzJTIyJTVEKQ==",highlighted:`<span class="hljs-meta">&gt;&gt;&gt; </span>tokenizer.decode(encoded_input[<span class="hljs-string">&quot;input_ids&quot;</span>])
<span class="hljs-string">&#x27;[CLS] Do not meddle in the affairs of wizards, for they are subtle and quick to anger. [SEP]&#x27;</span>`}}),fa=new E({props:{code:"YmF0Y2hfc2VudGVuY2VzJTIwJTNEJTIwJTVCJTBBJTIwJTIwJTIwJTIwJTIyQnV0JTIwd2hhdCUyMGFib3V0JTIwc2Vjb25kJTIwYnJlYWtmYXN0JTNGJTIyJTJDJTBBJTIwJTIwJTIwJTIwJTIyRG9uJ3QlMjB0aGluayUyMGhlJTIwa25vd3MlMjBhYm91dCUyMHNlY29uZCUyMGJyZWFrZmFzdCUyQyUyMFBpcC4lMjIlMkMlMEElMjAlMjAlMjAlMjAlMjJXaGF0JTIwYWJvdXQlMjBlbGV2ZW5zaWVzJTNGJTIyJTJDJTBBJTVEJTBBZW5jb2RlZF9pbnB1dHMlMjAlM0QlMjB0b2tlbml6ZXIoYmF0Y2hfc2VudGVuY2VzKSUwQXByaW50KGVuY29kZWRfaW5wdXRzKQ==",highlighted:`<span class="hljs-meta">&gt;&gt;&gt; </span>batch_sentences = [
<span class="hljs-meta">... </span>    <span class="hljs-string">&quot;But what about second breakfast?&quot;</span>,
<span class="hljs-meta">... </span>    <span class="hljs-string">&quot;Don&#x27;t think he knows about second breakfast, Pip.&quot;</span>,
<span class="hljs-meta">... </span>    <span class="hljs-string">&quot;What about elevensies?&quot;</span>,
<span class="hljs-meta">... </span>]
<span class="hljs-meta">&gt;&gt;&gt; </span>encoded_inputs = tokenizer(batch_sentences)
<span class="hljs-meta">&gt;&gt;&gt; </span><span class="hljs-built_in">print</span>(encoded_inputs)
{<span class="hljs-string">&#x27;input_ids&#x27;</span>: [[<span class="hljs-number">101</span>, <span class="hljs-number">1252</span>, <span class="hljs-number">1184</span>, <span class="hljs-number">1164</span>, <span class="hljs-number">1248</span>, <span class="hljs-number">6462</span>, <span class="hljs-number">136</span>, <span class="hljs-number">102</span>],
               [<span class="hljs-number">101</span>, <span class="hljs-number">1790</span>, <span class="hljs-number">112</span>, <span class="hljs-number">189</span>, <span class="hljs-number">1341</span>, <span class="hljs-number">1119</span>, <span class="hljs-number">3520</span>, <span class="hljs-number">1164</span>, <span class="hljs-number">1248</span>, <span class="hljs-number">6462</span>, <span class="hljs-number">117</span>, <span class="hljs-number">21902</span>, <span class="hljs-number">1643</span>, <span class="hljs-number">119</span>, <span class="hljs-number">102</span>],
               [<span class="hljs-number">101</span>, <span class="hljs-number">1327</span>, <span class="hljs-number">1164</span>, <span class="hljs-number">5450</span>, <span class="hljs-number">23434</span>, <span class="hljs-number">136</span>, <span class="hljs-number">102</span>]],
 <span class="hljs-string">&#x27;token_type_ids&#x27;</span>: [[<span class="hljs-number">0</span>, <span class="hljs-number">0</span>, <span class="hljs-number">0</span>, <span class="hljs-number">0</span>, <span class="hljs-number">0</span>, <span class="hljs-number">0</span>, <span class="hljs-number">0</span>, <span class="hljs-number">0</span>],
                    [<span class="hljs-number">0</span>, <span class="hljs-number">0</span>, <span class="hljs-number">0</span>, <span class="hljs-number">0</span>, <span class="hljs-number">0</span>, <span class="hljs-number">0</span>, <span class="hljs-number">0</span>, <span class="hljs-number">0</span>, <span class="hljs-number">0</span>, <span class="hljs-number">0</span>, <span class="hljs-number">0</span>, <span class="hljs-number">0</span>, <span class="hljs-number">0</span>, <span class="hljs-number">0</span>, <span class="hljs-number">0</span>],
                    [<span class="hljs-number">0</span>, <span class="hljs-number">0</span>, <span class="hljs-number">0</span>, <span class="hljs-number">0</span>, <span class="hljs-number">0</span>, <span class="hljs-number">0</span>, <span class="hljs-number">0</span>]],
 <span class="hljs-string">&#x27;attention_mask&#x27;</span>: [[<span class="hljs-number">1</span>, <span class="hljs-number">1</span>, <span class="hljs-number">1</span>, <span class="hljs-number">1</span>, <span class="hljs-number">1</span>, <span class="hljs-number">1</span>, <span class="hljs-number">1</span>, <span class="hljs-number">1</span>],
                    [<span class="hljs-number">1</span>, <span class="hljs-number">1</span>, <span class="hljs-number">1</span>, <span class="hljs-number">1</span>, <span class="hljs-number">1</span>, <span class="hljs-number">1</span>, <span class="hljs-number">1</span>, <span class="hljs-number">1</span>, <span class="hljs-number">1</span>, <span class="hljs-number">1</span>, <span class="hljs-number">1</span>, <span class="hljs-number">1</span>, <span class="hljs-number">1</span>, <span class="hljs-number">1</span>, <span class="hljs-number">1</span>],
                    [<span class="hljs-number">1</span>, <span class="hljs-number">1</span>, <span class="hljs-number">1</span>, <span class="hljs-number">1</span>, <span class="hljs-number">1</span>, <span class="hljs-number">1</span>, <span class="hljs-number">1</span>]]}`}}),ba=new Is({}),ga=new E({props:{code:"YmF0Y2hfc2VudGVuY2VzJTIwJTNEJTIwJTVCJTBBJTIwJTIwJTIwJTIwJTIyQnV0JTIwd2hhdCUyMGFib3V0JTIwc2Vjb25kJTIwYnJlYWtmYXN0JTNGJTIyJTJDJTBBJTIwJTIwJTIwJTIwJTIyRG9uJ3QlMjB0aGluayUyMGhlJTIwa25vd3MlMjBhYm91dCUyMHNlY29uZCUyMGJyZWFrZmFzdCUyQyUyMFBpcC4lMjIlMkMlMEElMjAlMjAlMjAlMjAlMjJXaGF0JTIwYWJvdXQlMjBlbGV2ZW5zaWVzJTNGJTIyJTJDJTBBJTVEJTBBZW5jb2RlZF9pbnB1dCUyMCUzRCUyMHRva2VuaXplcihiYXRjaF9zZW50ZW5jZXMlMkMlMjBwYWRkaW5nJTNEVHJ1ZSklMEFwcmludChlbmNvZGVkX2lucHV0KQ==",highlighted:`<span class="hljs-meta">&gt;&gt;&gt; </span>batch_sentences = [
<span class="hljs-meta">... </span>    <span class="hljs-string">&quot;But what about second breakfast?&quot;</span>,
<span class="hljs-meta">... </span>    <span class="hljs-string">&quot;Don&#x27;t think he knows about second breakfast, Pip.&quot;</span>,
<span class="hljs-meta">... </span>    <span class="hljs-string">&quot;What about elevensies?&quot;</span>,
<span class="hljs-meta">... </span>]
<span class="hljs-meta">&gt;&gt;&gt; </span>encoded_input = tokenizer(batch_sentences, padding=<span class="hljs-literal">True</span>)
<span class="hljs-meta">&gt;&gt;&gt; </span><span class="hljs-built_in">print</span>(encoded_input)
{<span class="hljs-string">&#x27;input_ids&#x27;</span>: [[<span class="hljs-number">101</span>, <span class="hljs-number">1252</span>, <span class="hljs-number">1184</span>, <span class="hljs-number">1164</span>, <span class="hljs-number">1248</span>, <span class="hljs-number">6462</span>, <span class="hljs-number">136</span>, <span class="hljs-number">102</span>, <span class="hljs-number">0</span>, <span class="hljs-number">0</span>, <span class="hljs-number">0</span>, <span class="hljs-number">0</span>, <span class="hljs-number">0</span>, <span class="hljs-number">0</span>, <span class="hljs-number">0</span>],
               [<span class="hljs-number">101</span>, <span class="hljs-number">1790</span>, <span class="hljs-number">112</span>, <span class="hljs-number">189</span>, <span class="hljs-number">1341</span>, <span class="hljs-number">1119</span>, <span class="hljs-number">3520</span>, <span class="hljs-number">1164</span>, <span class="hljs-number">1248</span>, <span class="hljs-number">6462</span>, <span class="hljs-number">117</span>, <span class="hljs-number">21902</span>, <span class="hljs-number">1643</span>, <span class="hljs-number">119</span>, <span class="hljs-number">102</span>],
               [<span class="hljs-number">101</span>, <span class="hljs-number">1327</span>, <span class="hljs-number">1164</span>, <span class="hljs-number">5450</span>, <span class="hljs-number">23434</span>, <span class="hljs-number">136</span>, <span class="hljs-number">102</span>, <span class="hljs-number">0</span>, <span class="hljs-number">0</span>, <span class="hljs-number">0</span>, <span class="hljs-number">0</span>, <span class="hljs-number">0</span>, <span class="hljs-number">0</span>, <span class="hljs-number">0</span>, <span class="hljs-number">0</span>]],
 <span class="hljs-string">&#x27;token_type_ids&#x27;</span>: [[<span class="hljs-number">0</span>, <span class="hljs-number">0</span>, <span class="hljs-number">0</span>, <span class="hljs-number">0</span>, <span class="hljs-number">0</span>, <span class="hljs-number">0</span>, <span class="hljs-number">0</span>, <span class="hljs-number">0</span>, <span class="hljs-number">0</span>, <span class="hljs-number">0</span>, <span class="hljs-number">0</span>, <span class="hljs-number">0</span>, <span class="hljs-number">0</span>, <span class="hljs-number">0</span>, <span class="hljs-number">0</span>],
                    [<span class="hljs-number">0</span>, <span class="hljs-number">0</span>, <span class="hljs-number">0</span>, <span class="hljs-number">0</span>, <span class="hljs-number">0</span>, <span class="hljs-number">0</span>, <span class="hljs-number">0</span>, <span class="hljs-number">0</span>, <span class="hljs-number">0</span>, <span class="hljs-number">0</span>, <span class="hljs-number">0</span>, <span class="hljs-number">0</span>, <span class="hljs-number">0</span>, <span class="hljs-number">0</span>, <span class="hljs-number">0</span>],
                    [<span class="hljs-number">0</span>, <span class="hljs-number">0</span>, <span class="hljs-number">0</span>, <span class="hljs-number">0</span>, <span class="hljs-number">0</span>, <span class="hljs-number">0</span>, <span class="hljs-number">0</span>, <span class="hljs-number">0</span>, <span class="hljs-number">0</span>, <span class="hljs-number">0</span>, <span class="hljs-number">0</span>, <span class="hljs-number">0</span>, <span class="hljs-number">0</span>, <span class="hljs-number">0</span>, <span class="hljs-number">0</span>]],
 <span class="hljs-string">&#x27;attention_mask&#x27;</span>: [[<span class="hljs-number">1</span>, <span class="hljs-number">1</span>, <span class="hljs-number">1</span>, <span class="hljs-number">1</span>, <span class="hljs-number">1</span>, <span class="hljs-number">1</span>, <span class="hljs-number">1</span>, <span class="hljs-number">1</span>, <span class="hljs-number">0</span>, <span class="hljs-number">0</span>, <span class="hljs-number">0</span>, <span class="hljs-number">0</span>, <span class="hljs-number">0</span>, <span class="hljs-number">0</span>, <span class="hljs-number">0</span>],
                    [<span class="hljs-number">1</span>, <span class="hljs-number">1</span>, <span class="hljs-number">1</span>, <span class="hljs-number">1</span>, <span class="hljs-number">1</span>, <span class="hljs-number">1</span>, <span class="hljs-number">1</span>, <span class="hljs-number">1</span>, <span class="hljs-number">1</span>, <span class="hljs-number">1</span>, <span class="hljs-number">1</span>, <span class="hljs-number">1</span>, <span class="hljs-number">1</span>, <span class="hljs-number">1</span>, <span class="hljs-number">1</span>],
                    [<span class="hljs-number">1</span>, <span class="hljs-number">1</span>, <span class="hljs-number">1</span>, <span class="hljs-number">1</span>, <span class="hljs-number">1</span>, <span class="hljs-number">1</span>, <span class="hljs-number">1</span>, <span class="hljs-number">0</span>, <span class="hljs-number">0</span>, <span class="hljs-number">0</span>, <span class="hljs-number">0</span>, <span class="hljs-number">0</span>, <span class="hljs-number">0</span>, <span class="hljs-number">0</span>, <span class="hljs-number">0</span>]]}`}}),ya=new Is({}),wa=new E({props:{code:"YmF0Y2hfc2VudGVuY2VzJTIwJTNEJTIwJTVCJTBBJTIwJTIwJTIwJTIwJTIyQnV0JTIwd2hhdCUyMGFib3V0JTIwc2Vjb25kJTIwYnJlYWtmYXN0JTNGJTIyJTJDJTBBJTIwJTIwJTIwJTIwJTIyRG9uJ3QlMjB0aGluayUyMGhlJTIwa25vd3MlMjBhYm91dCUyMHNlY29uZCUyMGJyZWFrZmFzdCUyQyUyMFBpcC4lMjIlMkMlMEElMjAlMjAlMjAlMjAlMjJXaGF0JTIwYWJvdXQlMjBlbGV2ZW5zaWVzJTNGJTIyJTJDJTBBJTVEJTBBZW5jb2RlZF9pbnB1dCUyMCUzRCUyMHRva2VuaXplcihiYXRjaF9zZW50ZW5jZXMlMkMlMjBwYWRkaW5nJTNEVHJ1ZSUyQyUyMHRydW5jYXRpb24lM0RUcnVlKSUwQXByaW50KGVuY29kZWRfaW5wdXQp",highlighted:`<span class="hljs-meta">&gt;&gt;&gt; </span>batch_sentences = [
<span class="hljs-meta">... </span>    <span class="hljs-string">&quot;But what about second breakfast?&quot;</span>,
<span class="hljs-meta">... </span>    <span class="hljs-string">&quot;Don&#x27;t think he knows about second breakfast, Pip.&quot;</span>,
<span class="hljs-meta">... </span>    <span class="hljs-string">&quot;What about elevensies?&quot;</span>,
<span class="hljs-meta">... </span>]
<span class="hljs-meta">&gt;&gt;&gt; </span>encoded_input = tokenizer(batch_sentences, padding=<span class="hljs-literal">True</span>, truncation=<span class="hljs-literal">True</span>)
<span class="hljs-meta">&gt;&gt;&gt; </span><span class="hljs-built_in">print</span>(encoded_input)
{<span class="hljs-string">&#x27;input_ids&#x27;</span>: [[<span class="hljs-number">101</span>, <span class="hljs-number">1252</span>, <span class="hljs-number">1184</span>, <span class="hljs-number">1164</span>, <span class="hljs-number">1248</span>, <span class="hljs-number">6462</span>, <span class="hljs-number">136</span>, <span class="hljs-number">102</span>, <span class="hljs-number">0</span>, <span class="hljs-number">0</span>, <span class="hljs-number">0</span>, <span class="hljs-number">0</span>, <span class="hljs-number">0</span>, <span class="hljs-number">0</span>, <span class="hljs-number">0</span>],
               [<span class="hljs-number">101</span>, <span class="hljs-number">1790</span>, <span class="hljs-number">112</span>, <span class="hljs-number">189</span>, <span class="hljs-number">1341</span>, <span class="hljs-number">1119</span>, <span class="hljs-number">3520</span>, <span class="hljs-number">1164</span>, <span class="hljs-number">1248</span>, <span class="hljs-number">6462</span>, <span class="hljs-number">117</span>, <span class="hljs-number">21902</span>, <span class="hljs-number">1643</span>, <span class="hljs-number">119</span>, <span class="hljs-number">102</span>],
               [<span class="hljs-number">101</span>, <span class="hljs-number">1327</span>, <span class="hljs-number">1164</span>, <span class="hljs-number">5450</span>, <span class="hljs-number">23434</span>, <span class="hljs-number">136</span>, <span class="hljs-number">102</span>, <span class="hljs-number">0</span>, <span class="hljs-number">0</span>, <span class="hljs-number">0</span>, <span class="hljs-number">0</span>, <span class="hljs-number">0</span>, <span class="hljs-number">0</span>, <span class="hljs-number">0</span>, <span class="hljs-number">0</span>]],
 <span class="hljs-string">&#x27;token_type_ids&#x27;</span>: [[<span class="hljs-number">0</span>, <span class="hljs-number">0</span>, <span class="hljs-number">0</span>, <span class="hljs-number">0</span>, <span class="hljs-number">0</span>, <span class="hljs-number">0</span>, <span class="hljs-number">0</span>, <span class="hljs-number">0</span>, <span class="hljs-number">0</span>, <span class="hljs-number">0</span>, <span class="hljs-number">0</span>, <span class="hljs-number">0</span>, <span class="hljs-number">0</span>, <span class="hljs-number">0</span>, <span class="hljs-number">0</span>],
                    [<span class="hljs-number">0</span>, <span class="hljs-number">0</span>, <span class="hljs-number">0</span>, <span class="hljs-number">0</span>, <span class="hljs-number">0</span>, <span class="hljs-number">0</span>, <span class="hljs-number">0</span>, <span class="hljs-number">0</span>, <span class="hljs-number">0</span>, <span class="hljs-number">0</span>, <span class="hljs-number">0</span>, <span class="hljs-number">0</span>, <span class="hljs-number">0</span>, <span class="hljs-number">0</span>, <span class="hljs-number">0</span>],
                    [<span class="hljs-number">0</span>, <span class="hljs-number">0</span>, <span class="hljs-number">0</span>, <span class="hljs-number">0</span>, <span class="hljs-number">0</span>, <span class="hljs-number">0</span>, <span class="hljs-number">0</span>, <span class="hljs-number">0</span>, <span class="hljs-number">0</span>, <span class="hljs-number">0</span>, <span class="hljs-number">0</span>, <span class="hljs-number">0</span>, <span class="hljs-number">0</span>, <span class="hljs-number">0</span>, <span class="hljs-number">0</span>]],
 <span class="hljs-string">&#x27;attention_mask&#x27;</span>: [[<span class="hljs-number">1</span>, <span class="hljs-number">1</span>, <span class="hljs-number">1</span>, <span class="hljs-number">1</span>, <span class="hljs-number">1</span>, <span class="hljs-number">1</span>, <span class="hljs-number">1</span>, <span class="hljs-number">1</span>, <span class="hljs-number">0</span>, <span class="hljs-number">0</span>, <span class="hljs-number">0</span>, <span class="hljs-number">0</span>, <span class="hljs-number">0</span>, <span class="hljs-number">0</span>, <span class="hljs-number">0</span>],
                    [<span class="hljs-number">1</span>, <span class="hljs-number">1</span>, <span class="hljs-number">1</span>, <span class="hljs-number">1</span>, <span class="hljs-number">1</span>, <span class="hljs-number">1</span>, <span class="hljs-number">1</span>, <span class="hljs-number">1</span>, <span class="hljs-number">1</span>, <span class="hljs-number">1</span>, <span class="hljs-number">1</span>, <span class="hljs-number">1</span>, <span class="hljs-number">1</span>, <span class="hljs-number">1</span>, <span class="hljs-number">1</span>],
                    [<span class="hljs-number">1</span>, <span class="hljs-number">1</span>, <span class="hljs-number">1</span>, <span class="hljs-number">1</span>, <span class="hljs-number">1</span>, <span class="hljs-number">1</span>, <span class="hljs-number">1</span>, <span class="hljs-number">0</span>, <span class="hljs-number">0</span>, <span class="hljs-number">0</span>, <span class="hljs-number">0</span>, <span class="hljs-number">0</span>, <span class="hljs-number">0</span>, <span class="hljs-number">0</span>, <span class="hljs-number">0</span>]]}`}}),Bs=new ke({props:{$$slots:{default:[wd]},$$scope:{ctx:I}}}),Ja=new Is({}),Ns=new bd({props:{pytorch:!0,tensorflow:!0,jax:!1,$$slots:{tensorflow:[$d],pytorch:[_d]},$$scope:{ctx:I}}}),_a=new Is({}),Ma=new E({props:{code:"ZnJvbSUyMGRhdGFzZXRzJTIwaW1wb3J0JTIwbG9hZF9kYXRhc2V0JTJDJTIwQXVkaW8lMEElMEFkYXRhc2V0JTIwJTNEJTIwbG9hZF9kYXRhc2V0KCUyMlBvbHlBSSUyRm1pbmRzMTQlMjIlMkMlMjBuYW1lJTNEJTIyZW4tVVMlMjIlMkMlMjBzcGxpdCUzRCUyMnRyYWluJTIyKQ==",highlighted:`<span class="hljs-meta">&gt;&gt;&gt; </span><span class="hljs-keyword">from</span> datasets <span class="hljs-keyword">import</span> load_dataset, Audio

<span class="hljs-meta">&gt;&gt;&gt; </span>dataset = load_dataset(<span class="hljs-string">&quot;PolyAI/minds14&quot;</span>, name=<span class="hljs-string">&quot;en-US&quot;</span>, split=<span class="hljs-string">&quot;train&quot;</span>)`}}),Ta=new E({props:{code:"ZGF0YXNldCU1QjAlNUQlNUIlMjJhdWRpbyUyMiU1RA==",highlighted:`<span class="hljs-meta">&gt;&gt;&gt; </span>dataset[<span class="hljs-number">0</span>][<span class="hljs-string">&quot;audio&quot;</span>]
{<span class="hljs-string">&#x27;array&#x27;</span>: array([ <span class="hljs-number">0.</span>        ,  <span class="hljs-number">0.00024414</span>, -<span class="hljs-number">0.00024414</span>, ..., -<span class="hljs-number">0.00024414</span>,
         <span class="hljs-number">0.</span>        ,  <span class="hljs-number">0.</span>        ], dtype=float32),
 <span class="hljs-string">&#x27;path&#x27;</span>: <span class="hljs-string">&#x27;/root/.cache/huggingface/datasets/downloads/extracted/f14948e0e84be638dd7943ac36518a4cf3324e8b7aa331c5ab11541518e9368c/en-US~JOINT_ACCOUNT/602ba55abb1e6d0fbce92065.wav&#x27;</span>,
 <span class="hljs-string">&#x27;sampling_rate&#x27;</span>: <span class="hljs-number">8000</span>}`}}),Ua=new E({props:{code:"ZGF0YXNldCUyMCUzRCUyMGRhdGFzZXQuY2FzdF9jb2x1bW4oJTIyYXVkaW8lMjIlMkMlMjBBdWRpbyhzYW1wbGluZ19yYXRlJTNEMTZfMDAwKSk=",highlighted:'<span class="hljs-meta">&gt;&gt;&gt; </span>dataset = dataset.cast_column(<span class="hljs-string">&quot;audio&quot;</span>, Audio(sampling_rate=<span class="hljs-number">16_000</span>))'}}),Ga=new E({props:{code:"ZGF0YXNldCU1QjAlNUQlNUIlMjJhdWRpbyUyMiU1RA==",highlighted:`<span class="hljs-meta">&gt;&gt;&gt; </span>dataset[<span class="hljs-number">0</span>][<span class="hljs-string">&quot;audio&quot;</span>]
{<span class="hljs-string">&#x27;array&#x27;</span>: array([ <span class="hljs-number">2.3443763e-05</span>,  <span class="hljs-number">2.1729663e-04</span>,  <span class="hljs-number">2.2145823e-04</span>, ...,
         <span class="hljs-number">3.8356509e-05</span>, -<span class="hljs-number">7.3497440e-06</span>, -<span class="hljs-number">2.1754686e-05</span>], dtype=float32),
 <span class="hljs-string">&#x27;path&#x27;</span>: <span class="hljs-string">&#x27;/root/.cache/huggingface/datasets/downloads/extracted/f14948e0e84be638dd7943ac36518a4cf3324e8b7aa331c5ab11541518e9368c/en-US~JOINT_ACCOUNT/602ba55abb1e6d0fbce92065.wav&#x27;</span>,
 <span class="hljs-string">&#x27;sampling_rate&#x27;</span>: <span class="hljs-number">16000</span>}`}}),Za=new E({props:{code:"ZnJvbSUyMHRyYW5zZm9ybWVycyUyMGltcG9ydCUyMEF1dG9GZWF0dXJlRXh0cmFjdG9yJTBBJTBBZmVhdHVyZV9leHRyYWN0b3IlMjAlM0QlMjBBdXRvRmVhdHVyZUV4dHJhY3Rvci5mcm9tX3ByZXRyYWluZWQoJTIyZmFjZWJvb2slMkZ3YXYydmVjMi1iYXNlJTIyKQ==",highlighted:`<span class="hljs-meta">&gt;&gt;&gt; </span><span class="hljs-keyword">from</span> transformers <span class="hljs-keyword">import</span> AutoFeatureExtractor

<span class="hljs-meta">&gt;&gt;&gt; </span>feature_extractor = AutoFeatureExtractor.from_pretrained(<span class="hljs-string">&quot;facebook/wav2vec2-base&quot;</span>)`}}),Aa=new E({props:{code:"YXVkaW9faW5wdXQlMjAlM0QlMjAlNUJkYXRhc2V0JTVCMCU1RCU1QiUyMmF1ZGlvJTIyJTVEJTVCJTIyYXJyYXklMjIlNUQlNUQlMEFmZWF0dXJlX2V4dHJhY3RvcihhdWRpb19pbnB1dCUyQyUyMHNhbXBsaW5nX3JhdGUlM0QxNjAwMCk=",highlighted:`<span class="hljs-meta">&gt;&gt;&gt; </span>audio_input = [dataset[<span class="hljs-number">0</span>][<span class="hljs-string">&quot;audio&quot;</span>][<span class="hljs-string">&quot;array&quot;</span>]]
<span class="hljs-meta">&gt;&gt;&gt; </span>feature_extractor(audio_input, sampling_rate=<span class="hljs-number">16000</span>)
{<span class="hljs-string">&#x27;input_values&#x27;</span>: [array([ <span class="hljs-number">3.8106556e-04</span>,  <span class="hljs-number">2.7506407e-03</span>,  <span class="hljs-number">2.8015103e-03</span>, ...,
        <span class="hljs-number">5.6335266e-04</span>,  <span class="hljs-number">4.6588284e-06</span>, -<span class="hljs-number">1.7142107e-04</span>], dtype=float32)]}`}}),Va=new E({props:{code:"ZGF0YXNldCU1QjAlNUQlNUIlMjJhdWRpbyUyMiU1RCU1QiUyMmFycmF5JTIyJTVELnNoYXBlJTBBJTBBZGF0YXNldCU1QjElNUQlNUIlMjJhdWRpbyUyMiU1RCU1QiUyMmFycmF5JTIyJTVELnNoYXBl",highlighted:`<span class="hljs-meta">&gt;&gt;&gt; </span>dataset[<span class="hljs-number">0</span>][<span class="hljs-string">&quot;audio&quot;</span>][<span class="hljs-string">&quot;array&quot;</span>].shape
(<span class="hljs-number">173398</span>,)

<span class="hljs-meta">&gt;&gt;&gt; </span>dataset[<span class="hljs-number">1</span>][<span class="hljs-string">&quot;audio&quot;</span>][<span class="hljs-string">&quot;array&quot;</span>].shape
(<span class="hljs-number">106496</span>,)`}}),za=new E({props:{code:"ZGVmJTIwcHJlcHJvY2Vzc19mdW5jdGlvbihleGFtcGxlcyklM0ElMEElMjAlMjAlMjAlMjBhdWRpb19hcnJheXMlMjAlM0QlMjAlNUJ4JTVCJTIyYXJyYXklMjIlNUQlMjBmb3IlMjB4JTIwaW4lMjBleGFtcGxlcyU1QiUyMmF1ZGlvJTIyJTVEJTVEJTBBJTIwJTIwJTIwJTIwaW5wdXRzJTIwJTNEJTIwZmVhdHVyZV9leHRyYWN0b3IoJTBBJTIwJTIwJTIwJTIwJTIwJTIwJTIwJTIwYXVkaW9fYXJyYXlzJTJDJTBBJTIwJTIwJTIwJTIwJTIwJTIwJTIwJTIwc2FtcGxpbmdfcmF0ZSUzRDE2MDAwJTJDJTBBJTIwJTIwJTIwJTIwJTIwJTIwJTIwJTIwcGFkZGluZyUzRFRydWUlMkMlMEElMjAlMjAlMjAlMjAlMjAlMjAlMjAlMjBtYXhfbGVuZ3RoJTNEMTAwMDAwJTJDJTBBJTIwJTIwJTIwJTIwJTIwJTIwJTIwJTIwdHJ1bmNhdGlvbiUzRFRydWUlMkMlMEElMjAlMjAlMjAlMjApJTBBJTIwJTIwJTIwJTIwcmV0dXJuJTIwaW5wdXRz",highlighted:`<span class="hljs-meta">&gt;&gt;&gt; </span><span class="hljs-keyword">def</span> <span class="hljs-title function_">preprocess_function</span>(<span class="hljs-params">examples</span>):
<span class="hljs-meta">... </span>    audio_arrays = [x[<span class="hljs-string">&quot;array&quot;</span>] <span class="hljs-keyword">for</span> x <span class="hljs-keyword">in</span> examples[<span class="hljs-string">&quot;audio&quot;</span>]]
<span class="hljs-meta">... </span>    inputs = feature_extractor(
<span class="hljs-meta">... </span>        audio_arrays,
<span class="hljs-meta">... </span>        sampling_rate=<span class="hljs-number">16000</span>,
<span class="hljs-meta">... </span>        padding=<span class="hljs-literal">True</span>,
<span class="hljs-meta">... </span>        max_length=<span class="hljs-number">100000</span>,
<span class="hljs-meta">... </span>        truncation=<span class="hljs-literal">True</span>,
<span class="hljs-meta">... </span>    )
<span class="hljs-meta">... </span>    <span class="hljs-keyword">return</span> inputs`}}),Ba=new E({props:{code:"cHJvY2Vzc2VkX2RhdGFzZXQlMjAlM0QlMjBwcmVwcm9jZXNzX2Z1bmN0aW9uKGRhdGFzZXQlNUIlM0E1JTVEKQ==",highlighted:'<span class="hljs-meta">&gt;&gt;&gt; </span>processed_dataset = preprocess_function(dataset[:<span class="hljs-number">5</span>])'}}),Wa=new E({props:{code:"cHJvY2Vzc2VkX2RhdGFzZXQlNUIlMjJpbnB1dF92YWx1ZXMlMjIlNUQlNUIwJTVELnNoYXBlJTBBJTBBcHJvY2Vzc2VkX2RhdGFzZXQlNUIlMjJpbnB1dF92YWx1ZXMlMjIlNUQlNUIxJTVELnNoYXBl",highlighted:`<span class="hljs-meta">&gt;&gt;&gt; </span>processed_dataset[<span class="hljs-string">&quot;input_values&quot;</span>][<span class="hljs-number">0</span>].shape
(<span class="hljs-number">100000</span>,)

<span class="hljs-meta">&gt;&gt;&gt; </span>processed_dataset[<span class="hljs-string">&quot;input_values&quot;</span>][<span class="hljs-number">1</span>].shape
(<span class="hljs-number">100000</span>,)`}}),Na=new Is({}),Ds=new ke({props:{$$slots:{default:[Md]},$$scope:{ctx:I}}}),Ss=new ke({props:{$$slots:{default:[Td]},$$scope:{ctx:I}}}),qa=new E({props:{code:"ZnJvbSUyMGRhdGFzZXRzJTIwaW1wb3J0JTIwbG9hZF9kYXRhc2V0JTBBJTBBZGF0YXNldCUyMCUzRCUyMGxvYWRfZGF0YXNldCglMjJmb29kMTAxJTIyJTJDJTIwc3BsaXQlM0QlMjJ0cmFpbiU1QiUzQTEwMCU1RCUyMik=",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>dataset = load_dataset(<span class="hljs-string">&quot;food101&quot;</span>, split=<span class="hljs-string">&quot;train[:100]&quot;</span>)`}}),Xa=new E({props:{code:"ZGF0YXNldCU1QjAlNUQlNUIlMjJpbWFnZSUyMiU1RA==",highlighted:'<span class="hljs-meta">&gt;&gt;&gt; </span>dataset[<span class="hljs-number">0</span>][<span class="hljs-string">&quot;image&quot;</span>]'}}),Pa=new E({props:{code:"ZnJvbSUyMHRyYW5zZm9ybWVycyUyMGltcG9ydCUyMEF1dG9JbWFnZVByb2Nlc3NvciUwQSUwQWltYWdlX3Byb2Nlc3NvciUyMCUzRCUyMEF1dG9JbWFnZVByb2Nlc3Nvci5mcm9tX3ByZXRyYWluZWQoJTIyZ29vZ2xlJTJGdml0LWJhc2UtcGF0Y2gxNi0yMjQlMjIp",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;google/vit-base-patch16-224&quot;</span>)`}}),se=new E({props:{code:"ZnJvbSUyMHRvcmNodmlzaW9uLnRyYW5zZm9ybXMlMjBpbXBvcnQlMjBSYW5kb21SZXNpemVkQ3JvcCUyQyUyMENvbG9ySml0dGVyJTJDJTIwQ29tcG9zZSUwQSUwQXNpemUlMjAlM0QlMjAoJTBBJTIwJTIwJTIwJTIwaW1hZ2VfcHJvY2Vzc29yLnNpemUlNUIlMjJzaG9ydGVzdF9lZGdlJTIyJTVEJTBBJTIwJTIwJTIwJTIwaWYlMjAlMjJzaG9ydGVzdF9lZGdlJTIyJTIwaW4lMjBpbWFnZV9wcm9jZXNzb3Iuc2l6ZSUwQSUyMCUyMCUyMCUyMGVsc2UlMjAoaW1hZ2VfcHJvY2Vzc29yLnNpemUlNUIlMjJoZWlnaHQlMjIlNUQlMkMlMjBpbWFnZV9wcm9jZXNzb3Iuc2l6ZSU1QiUyMndpZHRoJTIyJTVEKSUwQSklMEElMEFfdHJhbnNmb3JtcyUyMCUzRCUyMENvbXBvc2UoJTVCUmFuZG9tUmVzaXplZENyb3Aoc2l6ZSklMkMlMjBDb2xvckppdHRlcihicmlnaHRuZXNzJTNEMC41JTJDJTIwaHVlJTNEMC41KSU1RCk=",highlighted:`<span class="hljs-meta">&gt;&gt;&gt; </span><span class="hljs-keyword">from</span> torchvision.transforms <span class="hljs-keyword">import</span> RandomResizedCrop, ColorJitter, Compose

<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), ColorJitter(brightness=<span class="hljs-number">0.5</span>, hue=<span class="hljs-number">0.5</span>)])`}}),ee=new E({props:{code:"ZGVmJTIwdHJhbnNmb3JtcyhleGFtcGxlcyklM0ElMEElMjAlMjAlMjAlMjBpbWFnZXMlMjAlM0QlMjAlNUJfdHJhbnNmb3JtcyhpbWcuY29udmVydCglMjJSR0IlMjIpKSUyMGZvciUyMGltZyUyMGluJTIwZXhhbXBsZXMlNUIlMjJpbWFnZSUyMiU1RCU1RCUwQSUyMCUyMCUyMCUyMGV4YW1wbGVzJTVCJTIycGl4ZWxfdmFsdWVzJTIyJTVEJTIwJTNEJTIwaW1hZ2VfcHJvY2Vzc29yKGltYWdlcyUyQyUyMGRvX3Jlc2l6ZSUzREZhbHNlJTJDJTIwcmV0dXJuX3RlbnNvcnMlM0QlMjJwdCUyMiklNUIlMjJwaXhlbF92YWx1ZXMlMjIlNUQlMEElMjAlMjAlMjAlMjByZXR1cm4lMjBleGFtcGxlcw==",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>    images = [_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>    examples[<span class="hljs-string">&quot;pixel_values&quot;</span>] = image_processor(images, do_resize=<span class="hljs-literal">False</span>, return_tensors=<span class="hljs-string">&quot;pt&quot;</span>)[<span class="hljs-string">&quot;pixel_values&quot;</span>]
<span class="hljs-meta">... </span>    <span class="hljs-keyword">return</span> examples`}}),Os=new ke({props:{$$slots:{default:[Ed]},$$scope:{ctx:I}}}),pe=new E({props:{code:"ZGF0YXNldC5zZXRfdHJhbnNmb3JtKHRyYW5zZm9ybXMp",highlighted:'<span class="hljs-meta">&gt;&gt;&gt; </span>dataset.set_transform(transforms)'}}),ce=new E({props:{code:"ZGF0YXNldCU1QjAlNUQua2V5cygp",highlighted:'<span class="hljs-meta">&gt;&gt;&gt; </span>dataset[<span class="hljs-number">0</span>].keys()'}}),he=new E({props:{code:"aW1wb3J0JTIwbnVtcHklMjBhcyUyMG5wJTBBaW1wb3J0JTIwbWF0cGxvdGxpYi5weXBsb3QlMjBhcyUyMHBsdCUwQSUwQWltZyUyMCUzRCUyMGRhdGFzZXQlNUIwJTVEJTVCJTIycGl4ZWxfdmFsdWVzJTIyJTVEJTBBcGx0Lmltc2hvdyhpbWcucGVybXV0ZSgxJTJDJTIwMiUyQyUyMDApKQ==",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> matplotlib.pyplot <span class="hljs-keyword">as</span> plt

<span class="hljs-meta">&gt;&gt;&gt; </span>img = dataset[<span class="hljs-number">0</span>][<span class="hljs-string">&quot;pixel_values&quot;</span>]
<span class="hljs-meta">&gt;&gt;&gt; </span>plt.imshow(img.permute(<span class="hljs-number">1</span>, <span class="hljs-number">2</span>, <span class="hljs-number">0</span>))`}}),Ks=new ke({props:{$$slots:{default:[kd]},$$scope:{ctx:I}}}),ue=new Is({}),ie=new E({props:{code:"ZGVmJTIwY29sbGF0ZV9mbihiYXRjaCklM0ElMEElMjAlMjAlMjAlMjBwaXhlbF92YWx1ZXMlMjAlM0QlMjAlNUJpdGVtJTVCJTIycGl4ZWxfdmFsdWVzJTIyJTVEJTIwZm9yJTIwaXRlbSUyMGluJTIwYmF0Y2glNUQlMEElMjAlMjAlMjAlMjBlbmNvZGluZyUyMCUzRCUyMGltYWdlX3Byb2Nlc3Nvci5wYWQocGl4ZWxfdmFsdWVzJTJDJTIwcmV0dXJuX3RlbnNvcnMlM0QlMjJwdCUyMiklMEElMjAlMjAlMjAlMjBsYWJlbHMlMjAlM0QlMjAlNUJpdGVtJTVCJTIybGFiZWxzJTIyJTVEJTIwZm9yJTIwaXRlbSUyMGluJTIwYmF0Y2glNUQlMEElMjAlMjAlMjAlMjBiYXRjaCUyMCUzRCUyMCU3QiU3RCUwQSUyMCUyMCUyMCUyMGJhdGNoJTVCJTIycGl4ZWxfdmFsdWVzJTIyJTVEJTIwJTNEJTIwZW5jb2RpbmclNUIlMjJwaXhlbF92YWx1ZXMlMjIlNUQlMEElMjAlMjAlMjAlMjBiYXRjaCU1QiUyMnBpeGVsX21hc2slMjIlNUQlMjAlM0QlMjBlbmNvZGluZyU1QiUyMnBpeGVsX21hc2slMjIlNUQlMEElMjAlMjAlMjAlMjBiYXRjaCU1QiUyMmxhYmVscyUyMiU1RCUyMCUzRCUyMGxhYmVscyUwQSUyMCUyMCUyMCUyMHJldHVybiUyMGJhdGNo",highlighted:`<span class="hljs-meta">&gt;&gt;&gt; </span><span class="hljs-keyword">def</span> <span class="hljs-title function_">collate_fn</span>(<span class="hljs-params">batch</span>):
<span class="hljs-meta">... </span>    pixel_values = [item[<span class="hljs-string">&quot;pixel_values&quot;</span>] <span class="hljs-keyword">for</span> item <span class="hljs-keyword">in</span> batch]
<span class="hljs-meta">... </span>    encoding = image_processor.pad(pixel_values, return_tensors=<span class="hljs-string">&quot;pt&quot;</span>)
<span class="hljs-meta">... </span>    labels = [item[<span class="hljs-string">&quot;labels&quot;</span>] <span class="hljs-keyword">for</span> item <span class="hljs-keyword">in</span> batch]
<span class="hljs-meta">... </span>    batch = {}
<span class="hljs-meta">... </span>    batch[<span class="hljs-string">&quot;pixel_values&quot;</span>] = encoding[<span class="hljs-string">&quot;pixel_values&quot;</span>]
<span class="hljs-meta">... </span>    batch[<span class="hljs-string">&quot;pixel_mask&quot;</span>] = encoding[<span class="hljs-string">&quot;pixel_mask&quot;</span>]
<span class="hljs-meta">... </span>    batch[<span class="hljs-string">&quot;labels&quot;</span>] = labels
<span class="hljs-meta">... </span>    <span class="hljs-keyword">return</span> batch`}}),de=new Is({}),be=new E({props:{code:"ZnJvbSUyMGRhdGFzZXRzJTIwaW1wb3J0JTIwbG9hZF9kYXRhc2V0JTBBJTBBbGpfc3BlZWNoJTIwJTNEJTIwbG9hZF9kYXRhc2V0KCUyMmxqX3NwZWVjaCUyMiUyQyUyMHNwbGl0JTNEJTIydHJhaW4lMjIp",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>lj_speech = load_dataset(<span class="hljs-string">&quot;lj_speech&quot;</span>, split=<span class="hljs-string">&quot;train&quot;</span>)`}}),ge=new E({props:{code:"bGpfc3BlZWNoJTIwJTNEJTIwbGpfc3BlZWNoLm1hcChyZW1vdmVfY29sdW1ucyUzRCU1QiUyMmZpbGUlMjIlMkMlMjAlMjJpZCUyMiUyQyUyMCUyMm5vcm1hbGl6ZWRfdGV4dCUyMiU1RCk=",highlighted:'<span class="hljs-meta">&gt;&gt;&gt; </span>lj_speech = lj_speech.<span class="hljs-built_in">map</span>(remove_columns=[<span class="hljs-string">&quot;file&quot;</span>, <span class="hljs-string">&quot;id&quot;</span>, <span class="hljs-string">&quot;normalized_text&quot;</span>])'}}),ye=new E({props:{code:"bGpfc3BlZWNoJTVCMCU1RCU1QiUyMmF1ZGlvJTIyJTVEJTBBJTBBbGpfc3BlZWNoJTVCMCU1RCU1QiUyMnRleHQlMjIlNUQ=",highlighted:`<span class="hljs-meta">&gt;&gt;&gt; </span>lj_speech[<span class="hljs-number">0</span>][<span class="hljs-string">&quot;audio&quot;</span>]
{<span class="hljs-string">&#x27;array&#x27;</span>: array([-<span class="hljs-number">7.3242188e-04</span>, -<span class="hljs-number">7.6293945e-04</span>, -<span class="hljs-number">6.4086914e-04</span>, ...,
         <span class="hljs-number">7.3242188e-04</span>,  <span class="hljs-number">2.1362305e-04</span>,  <span class="hljs-number">6.1035156e-05</span>], dtype=float32),
 <span class="hljs-string">&#x27;path&#x27;</span>: <span class="hljs-string">&#x27;/root/.cache/huggingface/datasets/downloads/extracted/917ece08c95cf0c4115e45294e3cd0dee724a1165b7fc11798369308a465bd26/LJSpeech-1.1/wavs/LJ001-0001.wav&#x27;</span>,
 <span class="hljs-string">&#x27;sampling_rate&#x27;</span>: <span class="hljs-number">22050</span>}

<span class="hljs-meta">&gt;&gt;&gt; </span>lj_speech[<span class="hljs-number">0</span>][<span class="hljs-string">&quot;text&quot;</span>]
<span class="hljs-string">&#x27;Printing, in the only sense with which we are at present concerned, differs from most if not from all the arts and crafts represented in the Exhibition&#x27;</span>`}}),we=new E({props:{code:"bGpfc3BlZWNoJTIwJTNEJTIwbGpfc3BlZWNoLmNhc3RfY29sdW1uKCUyMmF1ZGlvJTIyJTJDJTIwQXVkaW8oc2FtcGxpbmdfcmF0ZSUzRDE2XzAwMCkp",highlighted:'<span class="hljs-meta">&gt;&gt;&gt; </span>lj_speech = lj_speech.cast_column(<span class="hljs-string">&quot;audio&quot;</span>, Audio(sampling_rate=<span class="hljs-number">16_000</span>))'}}),Je=new E({props:{code:"ZnJvbSUyMHRyYW5zZm9ybWVycyUyMGltcG9ydCUyMEF1dG9Qcm9jZXNzb3IlMEElMEFwcm9jZXNzb3IlMjAlM0QlMjBBdXRvUHJvY2Vzc29yLmZyb21fcHJldHJhaW5lZCglMjJmYWNlYm9vayUyRndhdjJ2ZWMyLWJhc2UtOTYwaCUyMik=",highlighted:`<span class="hljs-meta">&gt;&gt;&gt; </span><span class="hljs-keyword">from</span> transformers <span class="hljs-keyword">import</span> AutoProcessor

<span class="hljs-meta">&gt;&gt;&gt; </span>processor = AutoProcessor.from_pretrained(<span class="hljs-string">&quot;facebook/wav2vec2-base-960h&quot;</span>)`}}),_e=new E({props:{code:"ZGVmJTIwcHJlcGFyZV9kYXRhc2V0KGV4YW1wbGUpJTNBJTBBJTIwJTIwJTIwJTIwYXVkaW8lMjAlM0QlMjBleGFtcGxlJTVCJTIyYXVkaW8lMjIlNUQlMEElMEElMjAlMjAlMjAlMjBleGFtcGxlLnVwZGF0ZShwcm9jZXNzb3IoYXVkaW8lM0RhdWRpbyU1QiUyMmFycmF5JTIyJTVEJTJDJTIwdGV4dCUzRGV4YW1wbGUlNUIlMjJ0ZXh0JTIyJTVEJTJDJTIwc2FtcGxpbmdfcmF0ZSUzRDE2MDAwKSklMEElMEElMjAlMjAlMjAlMjByZXR1cm4lMjBleGFtcGxl",highlighted:`<span class="hljs-meta">&gt;&gt;&gt; </span><span class="hljs-keyword">def</span> <span class="hljs-title function_">prepare_dataset</span>(<span class="hljs-params">example</span>):
<span class="hljs-meta">... </span>    audio = example[<span class="hljs-string">&quot;audio&quot;</span>]

<span class="hljs-meta">... </span>    example.update(processor(audio=audio[<span class="hljs-string">&quot;array&quot;</span>], text=example[<span class="hljs-string">&quot;text&quot;</span>], sampling_rate=<span class="hljs-number">16000</span>))

<span class="hljs-meta">... </span>    <span class="hljs-keyword">return</span> example`}}),Me=new E({props:{code:"cHJlcGFyZV9kYXRhc2V0KGxqX3NwZWVjaCU1QjAlNUQp",highlighted:'<span class="hljs-meta">&gt;&gt;&gt; </span>prepare_dataset(lj_speech[<span class="hljs-number">0</span>])'}}),{c(){u=p("meta"),_=h(),d=p("h1"),J=p("a"),$=p("span"),j(v.$$.fragment),M=h(),k=p("span"),x=n("Preprocess"),Z=h(),j(U.$$.fragment),B=h(),A=p("p"),S=n("Before you can train a model on a dataset, it needs to be preprocessed into the expected model input format. Whether your data is text, images, or audio, they need to be converted and assembled into batches of tensors. \u{1F917} Transformers provides a set of preprocessing classes to help prepare your data for the model. In this tutorial, you\u2019ll learn that for:"),Y=h(),T=p("ul"),G=p("li"),W=n("Text, use a "),q=p("a"),K=n("Tokenizer"),N=n(" to convert text into a sequence of tokens, create a numerical representation of the tokens, and assemble them into tensors."),ss=h(),H=p("li"),V=n("Speech and audio, use a "),C=p("a"),Ie=n("Feature extractor"),Ue=n(" to extract sequential features from audio waveforms and convert them into tensors."),xe=h(),as=p("li"),es=n("Image inputs use a "),ws=p("a"),Ce=n("ImageProcessor"),_r=n(" to convert images into tensors."),vr=h(),ca=p("li"),$r=n("Multimodal inputs, use a "),Ge=p("a"),Mr=n("Processor"),Tr=n(" to combine a tokenizer and a feature extractor or image processor."),Ll=h(),j(Us.$$.fragment),Ol=h(),Ze=p("p"),Er=n("Before you begin, install \u{1F917} Datasets so you can load some datasets to experiment with:"),Kl=h(),j(ha.$$.fragment),st=h(),Js=p("h2"),xs=p("a"),xn=p("span"),j(ma.$$.fragment),kr=h(),Cn=p("span"),Ir=n("Natural Language Processing"),at=h(),j(ua.$$.fragment),et=h(),ns=p("p"),Ur=n("The main tool for preprocessing textual data is a "),Ae=p("a"),xr=n("tokenizer"),Cr=n(". A tokenizer splits text into "),Gn=p("em"),Gr=n("tokens"),Zr=n(" according to a set of rules. The tokens are converted into numbers and then tensors, which become the model inputs. Any additional inputs required by the model are added by the tokenizer."),nt=h(),j(Cs.$$.fragment),lt=h(),ls=p("p"),Ar=n("Get started by loading a pretrained tokenizer with the "),Ve=p("a"),Vr=n("AutoTokenizer.from_pretrained()"),zr=n(" method. This downloads the "),Zn=p("em"),Br=n("vocab"),Wr=n(" a model was pretrained with:"),tt=h(),j(ia.$$.fragment),pt=h(),ze=p("p"),Nr=n("Then pass your text to the tokenizer:"),rt=h(),j(da.$$.fragment),ot=h(),Be=p("p"),Rr=n("The tokenizer returns a dictionary with three important items:"),ct=h(),ts=p("ul"),We=p("li"),Ne=p("a"),Yr=n("input_ids"),qr=n(" are the indices corresponding to each token in the sentence."),Fr=h(),Re=p("li"),Ye=p("a"),Xr=n("attention_mask"),Qr=n(" indicates whether a token should be attended to or not."),Pr=h(),qe=p("li"),Fe=p("a"),Dr=n("token_type_ids"),Sr=n(" identifies which sequence a token belongs to when there is more than one sequence."),ht=h(),Gs=p("p"),Hr=n("Return your input by decoding the "),An=p("code"),Lr=n("input_ids"),Or=n(":"),mt=h(),j(ja.$$.fragment),ut=h(),ps=p("p"),Kr=n("As you can see, the tokenizer added two special tokens - "),Vn=p("code"),so=n("CLS"),ao=n(" and "),zn=p("code"),eo=n("SEP"),no=n(` (classifier and separator) - to the sentence. Not all models need
special tokens, but if they do, the tokenizer automatically adds them for you.`),it=h(),Xe=p("p"),lo=n("If there are several sentences you want to preprocess, pass them as a list to the tokenizer:"),dt=h(),j(fa.$$.fragment),jt=h(),_s=p("h3"),Zs=p("a"),Bn=p("span"),j(ba.$$.fragment),to=h(),Wn=p("span"),po=n("Pad"),ft=h(),As=p("p"),ro=n("Sentences aren\u2019t always the same length which can be an issue because tensors, the model inputs, need to have a uniform shape. Padding is a strategy for ensuring tensors are rectangular by adding a special "),Nn=p("em"),oo=n("padding token"),co=n(" to shorter sentences."),bt=h(),rs=p("p"),ho=n("Set the "),Rn=p("code"),mo=n("padding"),uo=n(" parameter to "),Yn=p("code"),io=n("True"),jo=n(" to pad the shorter sequences in the batch to match the longest sequence:"),gt=h(),j(ga.$$.fragment),yt=h(),Vs=p("p"),fo=n("The first and third sentences are now padded with "),qn=p("code"),bo=n("0"),go=n("\u2019s because they are shorter."),wt=h(),vs=p("h3"),zs=p("a"),Fn=p("span"),j(ya.$$.fragment),yo=h(),Xn=p("span"),wo=n("Truncation"),Jt=h(),Qe=p("p"),Jo=n("On the other end of the spectrum, sometimes a sequence may be too long for a model to handle. In this case, you\u2019ll need to truncate the sequence to a shorter length."),_t=h(),os=p("p"),_o=n("Set the "),Qn=p("code"),vo=n("truncation"),$o=n(" parameter to "),Pn=p("code"),Mo=n("True"),To=n(" to truncate a sequence to the maximum length accepted by the model:"),vt=h(),j(wa.$$.fragment),$t=h(),j(Bs.$$.fragment),Mt=h(),$s=p("h3"),Ws=p("a"),Dn=p("span"),j(Ja.$$.fragment),Eo=h(),Sn=p("span"),ko=n("Build tensors"),Tt=h(),Pe=p("p"),Io=n("Finally, you want the tokenizer to return the actual tensors that get fed to the model."),Et=h(),X=p("p"),Uo=n("Set the "),Hn=p("code"),xo=n("return_tensors"),Co=n(" parameter to either "),Ln=p("code"),Go=n("pt"),Zo=n(" for PyTorch, or "),On=p("code"),Ao=n("tf"),Vo=n(" for TensorFlow:"),kt=h(),j(Ns.$$.fragment),It=h(),Ms=p("h2"),Rs=p("a"),Kn=p("span"),j(_a.$$.fragment),zo=h(),sl=p("span"),Bo=n("Audio"),Ut=h(),Ys=p("p"),Wo=n("For audio tasks, you\u2019ll need a "),De=p("a"),No=n("feature extractor"),Ro=n(" to prepare your dataset for the model. The feature extractor is designed to extract features from raw audio data, and convert them into tensors."),xt=h(),cs=p("p"),Yo=n("Load the "),va=p("a"),qo=n("MInDS-14"),Fo=n(" dataset (see the \u{1F917} "),$a=p("a"),Xo=n("Datasets tutorial"),Qo=n(" for more details on how to load a dataset) to see how you can use a feature extractor with audio datasets:"),Ct=h(),j(Ma.$$.fragment),Gt=h(),hs=p("p"),Po=n("Access the first element of the "),al=p("code"),Do=n("audio"),So=n(" column to take a look at the input. Calling the "),el=p("code"),Ho=n("audio"),Lo=n(" column automatically loads and resamples the audio file:"),Zt=h(),j(Ta.$$.fragment),At=h(),Se=p("p"),Oo=n("This returns three items:"),Vt=h(),ms=p("ul"),He=p("li"),nl=p("code"),Ko=n("array"),sc=n(" is the speech signal loaded - and potentially resampled - as a 1D array."),ac=h(),Le=p("li"),ll=p("code"),ec=n("path"),nc=n(" points to the location of the audio file."),lc=h(),Oe=p("li"),tl=p("code"),tc=n("sampling_rate"),pc=n(" refers to how many data points in the speech signal are measured per second."),zt=h(),qs=p("p"),rc=n("For this tutorial, you\u2019ll use the "),Ea=p("a"),oc=n("Wav2Vec2"),cc=n(" model. Take a look at the model card, and you\u2019ll learn Wav2Vec2 is pretrained on 16kHz sampled speech audio. It is important your audio data\u2019s sampling rate matches the sampling rate of the dataset used to pretrain the model. If your data\u2019s sampling rate isn\u2019t the same, then you need to resample your data."),Bt=h(),Ke=p("ol"),ka=p("li"),hc=n("Use \u{1F917} Datasets\u2019 "),Ia=p("a"),mc=n("cast_column"),uc=n(" method to upsample the sampling rate to 16kHz:"),Wt=h(),j(Ua.$$.fragment),Nt=h(),xa=p("ol"),Ca=p("li"),ic=n("Call the "),pl=p("code"),dc=n("audio"),jc=n(" column again to resample the audio file:"),Rt=h(),j(Ga.$$.fragment),Yt=h(),Q=p("p"),fc=n("Next, load a feature extractor to normalize and pad the input. When padding textual data, a "),rl=p("code"),bc=n("0"),gc=n(" is added for shorter sequences. The same idea applies to audio data. The feature extractor adds a "),ol=p("code"),yc=n("0"),wc=n(" - interpreted as silence - to "),cl=p("code"),Jc=n("array"),_c=n("."),qt=h(),Fs=p("p"),vc=n("Load the feature extractor with "),sn=p("a"),$c=n("AutoFeatureExtractor.from_pretrained()"),Mc=n(":"),Ft=h(),j(Za.$$.fragment),Xt=h(),us=p("p"),Tc=n("Pass the audio "),hl=p("code"),Ec=n("array"),kc=n(" to the feature extractor. We also recommend adding the "),ml=p("code"),Ic=n("sampling_rate"),Uc=n(" argument in the feature extractor in order to better debug any silent errors that may occur."),Qt=h(),j(Aa.$$.fragment),Pt=h(),an=p("p"),xc=n("Just like the tokenizer, you can apply padding or truncation to handle variable sequences in a batch. Take a look at the sequence length of these two audio samples:"),Dt=h(),j(Va.$$.fragment),St=h(),en=p("p"),Cc=n("Create a function to preprocess the dataset so the audio samples are the same lengths. Specify a maximum sample length, and the feature extractor will either pad or truncate the sequences to match it:"),Ht=h(),j(za.$$.fragment),Lt=h(),Xs=p("p"),Gc=n("Apply the "),ul=p("code"),Zc=n("preprocess_function"),Ac=n(" to the the first few examples in the dataset:"),Ot=h(),j(Ba.$$.fragment),Kt=h(),nn=p("p"),Vc=n("The sample lengths are now the same and match the specified maximum length. You can pass your processed dataset to the model now!"),sp=h(),j(Wa.$$.fragment),ap=h(),Ts=p("h2"),Qs=p("a"),il=p("span"),j(Na.$$.fragment),zc=h(),dl=p("span"),Bc=n("Computer vision"),ep=h(),Ps=p("p"),Wc=n("For computer vision tasks, you\u2019ll need an "),ln=p("a"),Nc=n("image processor"),Rc=n(` to prepare your dataset for the model.
Image preprocessing consists of several steps that convert images into the input expected by the model. These steps
include but are not limited to resizing, normalizing, color channel correction, and converting images to tensors.`),np=h(),j(Ds.$$.fragment),lp=h(),is=p("p"),Yc=n("Load the "),Ra=p("a"),qc=n("food101"),Fc=n(" dataset (see the \u{1F917} "),Ya=p("a"),Xc=n("Datasets tutorial"),Qc=n(" for more details on how to load a dataset) to see how you can use an image processor with computer vision datasets:"),tp=h(),j(Ss.$$.fragment),pp=h(),j(qa.$$.fragment),rp=h(),Hs=p("p"),Pc=n("Next, take a look at the image with \u{1F917} Datasets "),Fa=p("a"),jl=p("code"),Dc=n("Image"),Sc=n(" feature:"),op=h(),j(Xa.$$.fragment),cp=h(),Qa=p("div"),fl=p("img"),hp=h(),Ls=p("p"),Hc=n("Load the image processor with "),tn=p("a"),Lc=n("AutoImageProcessor.from_pretrained()"),Oc=n(":"),mp=h(),j(Pa.$$.fragment),up=h(),P=p("p"),Kc=n("First, let\u2019s add some image augmentation. You can use any library you prefer, but in this tutorial, we\u2019ll use torchvision\u2019s "),Da=p("a"),bl=p("code"),sh=n("transforms"),ah=n(" module. If you\u2019re interested in using another data augmentation library, learn how in the "),Sa=p("a"),eh=n("Albumentations"),nh=n(" or "),Ha=p("a"),lh=n("Kornia notebooks"),th=n("."),ip=h(),pn=p("ol"),z=p("li"),ph=n("Here we use "),La=p("a"),gl=p("code"),rh=n("Compose"),oh=n(` to chain together a couple of
transforms - `),Oa=p("a"),yl=p("code"),ch=n("RandomResizedCrop"),hh=n(" and "),Ka=p("a"),wl=p("code"),mh=n("ColorJitter"),uh=n(`.
Note that for resizing, we can get the image size requirements from the `),Jl=p("code"),ih=n("image_processor"),dh=n(`. For some models, an exact height and
width are expected, for others only the `),_l=p("code"),jh=n("shortest_edge"),fh=n(" is defined."),dp=h(),j(se.$$.fragment),jp=h(),ae=p("ol"),L=p("li"),bh=n("The model accepts "),rn=p("a"),vl=p("code"),gh=n("pixel_values"),yh=n(`
as its input. `),$l=p("code"),wh=n("ImageProcessor"),Jh=n(` can take care of normalizing the images, and generating appropriate tensors.
Create a function that combines image augmentation and image preprocessing for a batch of images and generates `),Ml=p("code"),_h=n("pixel_values"),vh=n(":"),fp=h(),j(ee.$$.fragment),bp=h(),j(Os.$$.fragment),gp=h(),ne=p("ol"),le=p("li"),$h=n("Then use \u{1F917} Datasets "),te=p("a"),Tl=p("code"),Mh=n("set_transform"),Th=n(" to apply the transforms on the fly:"),yp=h(),j(pe.$$.fragment),wp=h(),re=p("ol"),oe=p("li"),Eh=n("Now when you access the image, you\u2019ll notice the image processor has added "),El=p("code"),kh=n("pixel_values"),Ih=n(". You can pass your processed dataset to the model now!"),Jp=h(),j(ce.$$.fragment),_p=h(),on=p("p"),Uh=n("Here is what the image looks like after the transforms are applied. The image has been randomly cropped and it\u2019s color properties are different."),vp=h(),j(he.$$.fragment),$p=h(),me=p("div"),kl=p("img"),Mp=h(),j(Ks.$$.fragment),Tp=h(),Es=p("h3"),sa=p("a"),Il=p("span"),j(ue.$$.fragment),xh=h(),Ul=p("span"),Ch=n("Pad"),Ep=h(),R=p("p"),Gh=n("In some cases, for instance, when fine-tuning "),cn=p("a"),Zh=n("DETR"),Ah=n(`, the model applies scale augmentation at training
time. This may cause images to be different sizes in a batch. You can use `),xl=p("code"),Vh=n("DetrImageProcessor.pad()"),zh=n(`
from `),hn=p("a"),Bh=n("DetrImageProcessor"),Wh=n(" and define a custom "),Cl=p("code"),Nh=n("collate_fn"),Rh=n(" to batch images together."),kp=h(),j(ie.$$.fragment),Ip=h(),ks=p("h2"),aa=p("a"),Gl=p("span"),j(de.$$.fragment),Yh=h(),Zl=p("span"),qh=n("Multimodal"),Up=h(),ea=p("p"),Fh=n("For tasks involving multimodal inputs, you\u2019ll need a "),mn=p("a"),Xh=n("processor"),Qh=n(" to prepare your dataset for the model. A processor couples together two processing objects such as as tokenizer and feature extractor."),xp=h(),ds=p("p"),Ph=n("Load the "),je=p("a"),Dh=n("LJ Speech"),Sh=n(" dataset (see the \u{1F917} "),fe=p("a"),Hh=n("Datasets tutorial"),Lh=n(" for more details on how to load a dataset) to see how you can use a processor for automatic speech recognition (ASR):"),Cp=h(),j(be.$$.fragment),Gp=h(),js=p("p"),Oh=n("For ASR, you\u2019re mainly focused on "),Al=p("code"),Kh=n("audio"),sm=n(" and "),Vl=p("code"),am=n("text"),em=n(" so you can remove the other columns:"),Zp=h(),j(ge.$$.fragment),Ap=h(),fs=p("p"),nm=n("Now take a look at the "),zl=p("code"),lm=n("audio"),tm=n(" and "),Bl=p("code"),pm=n("text"),rm=n(" columns:"),Vp=h(),j(ye.$$.fragment),zp=h(),na=p("p"),om=n("Remember you should always "),un=p("a"),cm=n("resample"),hm=n(" your audio dataset\u2019s sampling rate to match the sampling rate of the dataset used to pretrain a model!"),Bp=h(),j(we.$$.fragment),Wp=h(),la=p("p"),mm=n("Load a processor with "),dn=p("a"),um=n("AutoProcessor.from_pretrained()"),im=n(":"),Np=h(),j(Je.$$.fragment),Rp=h(),jn=p("ol"),F=p("li"),dm=n("Create a function to process the audio data contained in "),Wl=p("code"),jm=n("array"),fm=n(" to "),Nl=p("code"),bm=n("input_values"),gm=n(", and tokenize "),Rl=p("code"),ym=n("text"),wm=n(" to "),Yl=p("code"),Jm=n("labels"),_m=n(". These are the inputs to the model:"),Yp=h(),j(_e.$$.fragment),qp=h(),ve=p("ol"),$e=p("li"),vm=n("Apply the "),ql=p("code"),$m=n("prepare_dataset"),Mm=n(" function to a sample:"),Fp=h(),j(Me.$$.fragment),Xp=h(),bs=p("p"),Tm=n("The processor has now added "),Fl=p("code"),Em=n("input_values"),km=n(" and "),Xl=p("code"),Im=n("labels"),Um=n(", and the sampling rate has also been correctly downsampled to 16kHz. You can pass your processed dataset to the model now!"),this.h()},l(s){const t=id('[data-svelte="svelte-1phssyn"]',document.head);u=r(t,"META",{name:!0,content:!0}),t.forEach(e),_=m(s),d=r(s,"H1",{class:!0});var Te=o(d);J=r(Te,"A",{id:!0,class:!0,href:!0});var Ql=o(J);$=r(Ql,"SPAN",{});var Pl=o($);f(v.$$.fragment,Pl),Pl.forEach(e),Ql.forEach(e),M=m(Te),k=r(Te,"SPAN",{});var Dl=o(k);x=l(Dl,"Preprocess"),Dl.forEach(e),Te.forEach(e),Z=m(s),f(U.$$.fragment,s),B=m(s),A=r(s,"P",{});var Sl=o(A);S=l(Sl,"Before you can train a model on a dataset, it needs to be preprocessed into the expected model input format. Whether your data is text, images, or audio, they need to be converted and assembled into batches of tensors. \u{1F917} Transformers provides a set of preprocessing classes to help prepare your data for the model. In this tutorial, you\u2019ll learn that for:"),Sl.forEach(e),Y=m(s),T=r(s,"UL",{});var O=o(T);G=r(O,"LI",{});var Ee=o(G);W=l(Ee,"Text, use a "),q=r(Ee,"A",{href:!0});var Hl=o(q);K=l(Hl,"Tokenizer"),Hl.forEach(e),N=l(Ee," to convert text into a sequence of tokens, create a numerical representation of the tokens, and assemble them into tensors."),Ee.forEach(e),ss=m(O),H=r(O,"LI",{});var Pp=o(H);V=l(Pp,"Speech and audio, use a "),C=r(Pp,"A",{href:!0});var Wm=o(C);Ie=l(Wm,"Feature extractor"),Wm.forEach(e),Ue=l(Pp," to extract sequential features from audio waveforms and convert them into tensors."),Pp.forEach(e),xe=m(O),as=r(O,"LI",{});var Dp=o(as);es=l(Dp,"Image inputs use a "),ws=r(Dp,"A",{href:!0});var Nm=o(ws);Ce=l(Nm,"ImageProcessor"),Nm.forEach(e),_r=l(Dp," to convert images into tensors."),Dp.forEach(e),vr=m(O),ca=r(O,"LI",{});var Sp=o(ca);$r=l(Sp,"Multimodal inputs, use a "),Ge=r(Sp,"A",{href:!0});var Rm=o(Ge);Mr=l(Rm,"Processor"),Rm.forEach(e),Tr=l(Sp," to combine a tokenizer and a feature extractor or image processor."),Sp.forEach(e),O.forEach(e),Ll=m(s),f(Us.$$.fragment,s),Ol=m(s),Ze=r(s,"P",{});var Ym=o(Ze);Er=l(Ym,"Before you begin, install \u{1F917} Datasets so you can load some datasets to experiment with:"),Ym.forEach(e),Kl=m(s),f(ha.$$.fragment,s),st=m(s),Js=r(s,"H2",{class:!0});var Hp=o(Js);xs=r(Hp,"A",{id:!0,class:!0,href:!0});var qm=o(xs);xn=r(qm,"SPAN",{});var Fm=o(xn);f(ma.$$.fragment,Fm),Fm.forEach(e),qm.forEach(e),kr=m(Hp),Cn=r(Hp,"SPAN",{});var Xm=o(Cn);Ir=l(Xm,"Natural Language Processing"),Xm.forEach(e),Hp.forEach(e),at=m(s),f(ua.$$.fragment,s),et=m(s),ns=r(s,"P",{});var fn=o(ns);Ur=l(fn,"The main tool for preprocessing textual data is a "),Ae=r(fn,"A",{href:!0});var Qm=o(Ae);xr=l(Qm,"tokenizer"),Qm.forEach(e),Cr=l(fn,". A tokenizer splits text into "),Gn=r(fn,"EM",{});var Pm=o(Gn);Gr=l(Pm,"tokens"),Pm.forEach(e),Zr=l(fn," according to a set of rules. The tokens are converted into numbers and then tensors, which become the model inputs. Any additional inputs required by the model are added by the tokenizer."),fn.forEach(e),nt=m(s),f(Cs.$$.fragment,s),lt=m(s),ls=r(s,"P",{});var bn=o(ls);Ar=l(bn,"Get started by loading a pretrained tokenizer with the "),Ve=r(bn,"A",{href:!0});var Dm=o(Ve);Vr=l(Dm,"AutoTokenizer.from_pretrained()"),Dm.forEach(e),zr=l(bn," method. This downloads the "),Zn=r(bn,"EM",{});var Sm=o(Zn);Br=l(Sm,"vocab"),Sm.forEach(e),Wr=l(bn," a model was pretrained with:"),bn.forEach(e),tt=m(s),f(ia.$$.fragment,s),pt=m(s),ze=r(s,"P",{});var Hm=o(ze);Nr=l(Hm,"Then pass your text to the tokenizer:"),Hm.forEach(e),rt=m(s),f(da.$$.fragment,s),ot=m(s),Be=r(s,"P",{});var Lm=o(Be);Rr=l(Lm,"The tokenizer returns a dictionary with three important items:"),Lm.forEach(e),ct=m(s),ts=r(s,"UL",{});var gn=o(ts);We=r(gn,"LI",{});var xm=o(We);Ne=r(xm,"A",{href:!0});var Om=o(Ne);Yr=l(Om,"input_ids"),Om.forEach(e),qr=l(xm," are the indices corresponding to each token in the sentence."),xm.forEach(e),Fr=m(gn),Re=r(gn,"LI",{});var Cm=o(Re);Ye=r(Cm,"A",{href:!0});var Km=o(Ye);Xr=l(Km,"attention_mask"),Km.forEach(e),Qr=l(Cm," indicates whether a token should be attended to or not."),Cm.forEach(e),Pr=m(gn),qe=r(gn,"LI",{});var Gm=o(qe);Fe=r(Gm,"A",{href:!0});var su=o(Fe);Dr=l(su,"token_type_ids"),su.forEach(e),Sr=l(Gm," identifies which sequence a token belongs to when there is more than one sequence."),Gm.forEach(e),gn.forEach(e),ht=m(s),Gs=r(s,"P",{});var Lp=o(Gs);Hr=l(Lp,"Return your input by decoding the "),An=r(Lp,"CODE",{});var au=o(An);Lr=l(au,"input_ids"),au.forEach(e),Or=l(Lp,":"),Lp.forEach(e),mt=m(s),f(ja.$$.fragment,s),ut=m(s),ps=r(s,"P",{});var yn=o(ps);Kr=l(yn,"As you can see, the tokenizer added two special tokens - "),Vn=r(yn,"CODE",{});var eu=o(Vn);so=l(eu,"CLS"),eu.forEach(e),ao=l(yn," and "),zn=r(yn,"CODE",{});var nu=o(zn);eo=l(nu,"SEP"),nu.forEach(e),no=l(yn,` (classifier and separator) - to the sentence. Not all models need
special tokens, but if they do, the tokenizer automatically adds them for you.`),yn.forEach(e),it=m(s),Xe=r(s,"P",{});var lu=o(Xe);lo=l(lu,"If there are several sentences you want to preprocess, pass them as a list to the tokenizer:"),lu.forEach(e),dt=m(s),f(fa.$$.fragment,s),jt=m(s),_s=r(s,"H3",{class:!0});var Op=o(_s);Zs=r(Op,"A",{id:!0,class:!0,href:!0});var tu=o(Zs);Bn=r(tu,"SPAN",{});var pu=o(Bn);f(ba.$$.fragment,pu),pu.forEach(e),tu.forEach(e),to=m(Op),Wn=r(Op,"SPAN",{});var ru=o(Wn);po=l(ru,"Pad"),ru.forEach(e),Op.forEach(e),ft=m(s),As=r(s,"P",{});var Kp=o(As);ro=l(Kp,"Sentences aren\u2019t always the same length which can be an issue because tensors, the model inputs, need to have a uniform shape. Padding is a strategy for ensuring tensors are rectangular by adding a special "),Nn=r(Kp,"EM",{});var ou=o(Nn);oo=l(ou,"padding token"),ou.forEach(e),co=l(Kp," to shorter sentences."),Kp.forEach(e),bt=m(s),rs=r(s,"P",{});var wn=o(rs);ho=l(wn,"Set the "),Rn=r(wn,"CODE",{});var cu=o(Rn);mo=l(cu,"padding"),cu.forEach(e),uo=l(wn," parameter to "),Yn=r(wn,"CODE",{});var hu=o(Yn);io=l(hu,"True"),hu.forEach(e),jo=l(wn," to pad the shorter sequences in the batch to match the longest sequence:"),wn.forEach(e),gt=m(s),f(ga.$$.fragment,s),yt=m(s),Vs=r(s,"P",{});var sr=o(Vs);fo=l(sr,"The first and third sentences are now padded with "),qn=r(sr,"CODE",{});var mu=o(qn);bo=l(mu,"0"),mu.forEach(e),go=l(sr,"\u2019s because they are shorter."),sr.forEach(e),wt=m(s),vs=r(s,"H3",{class:!0});var ar=o(vs);zs=r(ar,"A",{id:!0,class:!0,href:!0});var uu=o(zs);Fn=r(uu,"SPAN",{});var iu=o(Fn);f(ya.$$.fragment,iu),iu.forEach(e),uu.forEach(e),yo=m(ar),Xn=r(ar,"SPAN",{});var du=o(Xn);wo=l(du,"Truncation"),du.forEach(e),ar.forEach(e),Jt=m(s),Qe=r(s,"P",{});var ju=o(Qe);Jo=l(ju,"On the other end of the spectrum, sometimes a sequence may be too long for a model to handle. In this case, you\u2019ll need to truncate the sequence to a shorter length."),ju.forEach(e),_t=m(s),os=r(s,"P",{});var Jn=o(os);_o=l(Jn,"Set the "),Qn=r(Jn,"CODE",{});var fu=o(Qn);vo=l(fu,"truncation"),fu.forEach(e),$o=l(Jn," parameter to "),Pn=r(Jn,"CODE",{});var bu=o(Pn);Mo=l(bu,"True"),bu.forEach(e),To=l(Jn," to truncate a sequence to the maximum length accepted by the model:"),Jn.forEach(e),vt=m(s),f(wa.$$.fragment,s),$t=m(s),f(Bs.$$.fragment,s),Mt=m(s),$s=r(s,"H3",{class:!0});var er=o($s);Ws=r(er,"A",{id:!0,class:!0,href:!0});var gu=o(Ws);Dn=r(gu,"SPAN",{});var yu=o(Dn);f(Ja.$$.fragment,yu),yu.forEach(e),gu.forEach(e),Eo=m(er),Sn=r(er,"SPAN",{});var wu=o(Sn);ko=l(wu,"Build tensors"),wu.forEach(e),er.forEach(e),Tt=m(s),Pe=r(s,"P",{});var Ju=o(Pe);Io=l(Ju,"Finally, you want the tokenizer to return the actual tensors that get fed to the model."),Ju.forEach(e),Et=m(s),X=r(s,"P",{});var ta=o(X);Uo=l(ta,"Set the "),Hn=r(ta,"CODE",{});var _u=o(Hn);xo=l(_u,"return_tensors"),_u.forEach(e),Co=l(ta," parameter to either "),Ln=r(ta,"CODE",{});var vu=o(Ln);Go=l(vu,"pt"),vu.forEach(e),Zo=l(ta," for PyTorch, or "),On=r(ta,"CODE",{});var $u=o(On);Ao=l($u,"tf"),$u.forEach(e),Vo=l(ta," for TensorFlow:"),ta.forEach(e),kt=m(s),f(Ns.$$.fragment,s),It=m(s),Ms=r(s,"H2",{class:!0});var nr=o(Ms);Rs=r(nr,"A",{id:!0,class:!0,href:!0});var Mu=o(Rs);Kn=r(Mu,"SPAN",{});var Tu=o(Kn);f(_a.$$.fragment,Tu),Tu.forEach(e),Mu.forEach(e),zo=m(nr),sl=r(nr,"SPAN",{});var Eu=o(sl);Bo=l(Eu,"Audio"),Eu.forEach(e),nr.forEach(e),Ut=m(s),Ys=r(s,"P",{});var lr=o(Ys);Wo=l(lr,"For audio tasks, you\u2019ll need a "),De=r(lr,"A",{href:!0});var ku=o(De);No=l(ku,"feature extractor"),ku.forEach(e),Ro=l(lr," to prepare your dataset for the model. The feature extractor is designed to extract features from raw audio data, and convert them into tensors."),lr.forEach(e),xt=m(s),cs=r(s,"P",{});var _n=o(cs);Yo=l(_n,"Load the "),va=r(_n,"A",{href:!0,rel:!0});var Iu=o(va);qo=l(Iu,"MInDS-14"),Iu.forEach(e),Fo=l(_n," dataset (see the \u{1F917} "),$a=r(_n,"A",{href:!0,rel:!0});var Uu=o($a);Xo=l(Uu,"Datasets tutorial"),Uu.forEach(e),Qo=l(_n," for more details on how to load a dataset) to see how you can use a feature extractor with audio datasets:"),_n.forEach(e),Ct=m(s),f(Ma.$$.fragment,s),Gt=m(s),hs=r(s,"P",{});var vn=o(hs);Po=l(vn,"Access the first element of the "),al=r(vn,"CODE",{});var xu=o(al);Do=l(xu,"audio"),xu.forEach(e),So=l(vn," column to take a look at the input. Calling the "),el=r(vn,"CODE",{});var Cu=o(el);Ho=l(Cu,"audio"),Cu.forEach(e),Lo=l(vn," column automatically loads and resamples the audio file:"),vn.forEach(e),Zt=m(s),f(Ta.$$.fragment,s),At=m(s),Se=r(s,"P",{});var Gu=o(Se);Oo=l(Gu,"This returns three items:"),Gu.forEach(e),Vt=m(s),ms=r(s,"UL",{});var $n=o(ms);He=r($n,"LI",{});var Zm=o(He);nl=r(Zm,"CODE",{});var Zu=o(nl);Ko=l(Zu,"array"),Zu.forEach(e),sc=l(Zm," is the speech signal loaded - and potentially resampled - as a 1D array."),Zm.forEach(e),ac=m($n),Le=r($n,"LI",{});var Am=o(Le);ll=r(Am,"CODE",{});var Au=o(ll);ec=l(Au,"path"),Au.forEach(e),nc=l(Am," points to the location of the audio file."),Am.forEach(e),lc=m($n),Oe=r($n,"LI",{});var Vm=o(Oe);tl=r(Vm,"CODE",{});var Vu=o(tl);tc=l(Vu,"sampling_rate"),Vu.forEach(e),pc=l(Vm," refers to how many data points in the speech signal are measured per second."),Vm.forEach(e),$n.forEach(e),zt=m(s),qs=r(s,"P",{});var tr=o(qs);rc=l(tr,"For this tutorial, you\u2019ll use the "),Ea=r(tr,"A",{href:!0,rel:!0});var zu=o(Ea);oc=l(zu,"Wav2Vec2"),zu.forEach(e),cc=l(tr," model. Take a look at the model card, and you\u2019ll learn Wav2Vec2 is pretrained on 16kHz sampled speech audio. It is important your audio data\u2019s sampling rate matches the sampling rate of the dataset used to pretrain the model. If your data\u2019s sampling rate isn\u2019t the same, then you need to resample your data."),tr.forEach(e),Bt=m(s),Ke=r(s,"OL",{});var Bu=o(Ke);ka=r(Bu,"LI",{});var pr=o(ka);hc=l(pr,"Use \u{1F917} Datasets\u2019 "),Ia=r(pr,"A",{href:!0,rel:!0});var Wu=o(Ia);mc=l(Wu,"cast_column"),Wu.forEach(e),uc=l(pr," method to upsample the sampling rate to 16kHz:"),pr.forEach(e),Bu.forEach(e),Wt=m(s),f(Ua.$$.fragment,s),Nt=m(s),xa=r(s,"OL",{start:!0});var Nu=o(xa);Ca=r(Nu,"LI",{});var rr=o(Ca);ic=l(rr,"Call the "),pl=r(rr,"CODE",{});var Ru=o(pl);dc=l(Ru,"audio"),Ru.forEach(e),jc=l(rr," column again to resample the audio file:"),rr.forEach(e),Nu.forEach(e),Rt=m(s),f(Ga.$$.fragment,s),Yt=m(s),Q=r(s,"P",{});var pa=o(Q);fc=l(pa,"Next, load a feature extractor to normalize and pad the input. When padding textual data, a "),rl=r(pa,"CODE",{});var Yu=o(rl);bc=l(Yu,"0"),Yu.forEach(e),gc=l(pa," is added for shorter sequences. The same idea applies to audio data. The feature extractor adds a "),ol=r(pa,"CODE",{});var qu=o(ol);yc=l(qu,"0"),qu.forEach(e),wc=l(pa," - interpreted as silence - to "),cl=r(pa,"CODE",{});var Fu=o(cl);Jc=l(Fu,"array"),Fu.forEach(e),_c=l(pa,"."),pa.forEach(e),qt=m(s),Fs=r(s,"P",{});var or=o(Fs);vc=l(or,"Load the feature extractor with "),sn=r(or,"A",{href:!0});var Xu=o(sn);$c=l(Xu,"AutoFeatureExtractor.from_pretrained()"),Xu.forEach(e),Mc=l(or,":"),or.forEach(e),Ft=m(s),f(Za.$$.fragment,s),Xt=m(s),us=r(s,"P",{});var Mn=o(us);Tc=l(Mn,"Pass the audio "),hl=r(Mn,"CODE",{});var Qu=o(hl);Ec=l(Qu,"array"),Qu.forEach(e),kc=l(Mn," to the feature extractor. We also recommend adding the "),ml=r(Mn,"CODE",{});var Pu=o(ml);Ic=l(Pu,"sampling_rate"),Pu.forEach(e),Uc=l(Mn," argument in the feature extractor in order to better debug any silent errors that may occur."),Mn.forEach(e),Qt=m(s),f(Aa.$$.fragment,s),Pt=m(s),an=r(s,"P",{});var Du=o(an);xc=l(Du,"Just like the tokenizer, you can apply padding or truncation to handle variable sequences in a batch. Take a look at the sequence length of these two audio samples:"),Du.forEach(e),Dt=m(s),f(Va.$$.fragment,s),St=m(s),en=r(s,"P",{});var Su=o(en);Cc=l(Su,"Create a function to preprocess the dataset so the audio samples are the same lengths. Specify a maximum sample length, and the feature extractor will either pad or truncate the sequences to match it:"),Su.forEach(e),Ht=m(s),f(za.$$.fragment,s),Lt=m(s),Xs=r(s,"P",{});var cr=o(Xs);Gc=l(cr,"Apply the "),ul=r(cr,"CODE",{});var Hu=o(ul);Zc=l(Hu,"preprocess_function"),Hu.forEach(e),Ac=l(cr," to the the first few examples in the dataset:"),cr.forEach(e),Ot=m(s),f(Ba.$$.fragment,s),Kt=m(s),nn=r(s,"P",{});var Lu=o(nn);Vc=l(Lu,"The sample lengths are now the same and match the specified maximum length. You can pass your processed dataset to the model now!"),Lu.forEach(e),sp=m(s),f(Wa.$$.fragment,s),ap=m(s),Ts=r(s,"H2",{class:!0});var hr=o(Ts);Qs=r(hr,"A",{id:!0,class:!0,href:!0});var Ou=o(Qs);il=r(Ou,"SPAN",{});var Ku=o(il);f(Na.$$.fragment,Ku),Ku.forEach(e),Ou.forEach(e),zc=m(hr),dl=r(hr,"SPAN",{});var si=o(dl);Bc=l(si,"Computer vision"),si.forEach(e),hr.forEach(e),ep=m(s),Ps=r(s,"P",{});var mr=o(Ps);Wc=l(mr,"For computer vision tasks, you\u2019ll need an "),ln=r(mr,"A",{href:!0});var ai=o(ln);Nc=l(ai,"image processor"),ai.forEach(e),Rc=l(mr,` to prepare your dataset for the model.
Image preprocessing consists of several steps that convert images into the input expected by the model. These steps
include but are not limited to resizing, normalizing, color channel correction, and converting images to tensors.`),mr.forEach(e),np=m(s),f(Ds.$$.fragment,s),lp=m(s),is=r(s,"P",{});var Tn=o(is);Yc=l(Tn,"Load the "),Ra=r(Tn,"A",{href:!0,rel:!0});var ei=o(Ra);qc=l(ei,"food101"),ei.forEach(e),Fc=l(Tn," dataset (see the \u{1F917} "),Ya=r(Tn,"A",{href:!0,rel:!0});var ni=o(Ya);Xc=l(ni,"Datasets tutorial"),ni.forEach(e),Qc=l(Tn," for more details on how to load a dataset) to see how you can use an image processor with computer vision datasets:"),Tn.forEach(e),tp=m(s),f(Ss.$$.fragment,s),pp=m(s),f(qa.$$.fragment,s),rp=m(s),Hs=r(s,"P",{});var ur=o(Hs);Pc=l(ur,"Next, take a look at the image with \u{1F917} Datasets "),Fa=r(ur,"A",{href:!0,rel:!0});var li=o(Fa);jl=r(li,"CODE",{});var ti=o(jl);Dc=l(ti,"Image"),ti.forEach(e),li.forEach(e),Sc=l(ur," feature:"),ur.forEach(e),op=m(s),f(Xa.$$.fragment,s),cp=m(s),Qa=r(s,"DIV",{class:!0});var pi=o(Qa);fl=r(pi,"IMG",{src:!0}),pi.forEach(e),hp=m(s),Ls=r(s,"P",{});var ir=o(Ls);Hc=l(ir,"Load the image processor with "),tn=r(ir,"A",{href:!0});var ri=o(tn);Lc=l(ri,"AutoImageProcessor.from_pretrained()"),ri.forEach(e),Oc=l(ir,":"),ir.forEach(e),mp=m(s),f(Pa.$$.fragment,s),up=m(s),P=r(s,"P",{});var ra=o(P);Kc=l(ra,"First, let\u2019s add some image augmentation. You can use any library you prefer, but in this tutorial, we\u2019ll use torchvision\u2019s "),Da=r(ra,"A",{href:!0,rel:!0});var oi=o(Da);bl=r(oi,"CODE",{});var ci=o(bl);sh=l(ci,"transforms"),ci.forEach(e),oi.forEach(e),ah=l(ra," module. If you\u2019re interested in using another data augmentation library, learn how in the "),Sa=r(ra,"A",{href:!0,rel:!0});var hi=o(Sa);eh=l(hi,"Albumentations"),hi.forEach(e),nh=l(ra," or "),Ha=r(ra,"A",{href:!0,rel:!0});var mi=o(Ha);lh=l(mi,"Kornia notebooks"),mi.forEach(e),th=l(ra,"."),ra.forEach(e),ip=m(s),pn=r(s,"OL",{});var ui=o(pn);z=r(ui,"LI",{});var D=o(z);ph=l(D,"Here we use "),La=r(D,"A",{href:!0,rel:!0});var ii=o(La);gl=r(ii,"CODE",{});var di=o(gl);rh=l(di,"Compose"),di.forEach(e),ii.forEach(e),oh=l(D,` to chain together a couple of
transforms - `),Oa=r(D,"A",{href:!0,rel:!0});var ji=o(Oa);yl=r(ji,"CODE",{});var fi=o(yl);ch=l(fi,"RandomResizedCrop"),fi.forEach(e),ji.forEach(e),hh=l(D," and "),Ka=r(D,"A",{href:!0,rel:!0});var bi=o(Ka);wl=r(bi,"CODE",{});var gi=o(wl);mh=l(gi,"ColorJitter"),gi.forEach(e),bi.forEach(e),uh=l(D,`.
Note that for resizing, we can get the image size requirements from the `),Jl=r(D,"CODE",{});var yi=o(Jl);ih=l(yi,"image_processor"),yi.forEach(e),dh=l(D,`. For some models, an exact height and
width are expected, for others only the `),_l=r(D,"CODE",{});var wi=o(_l);jh=l(wi,"shortest_edge"),wi.forEach(e),fh=l(D," is defined."),D.forEach(e),ui.forEach(e),dp=m(s),f(se.$$.fragment,s),jp=m(s),ae=r(s,"OL",{start:!0});var Ji=o(ae);L=r(Ji,"LI",{});var oa=o(L);bh=l(oa,"The model accepts "),rn=r(oa,"A",{href:!0});var _i=o(rn);vl=r(_i,"CODE",{});var vi=o(vl);gh=l(vi,"pixel_values"),vi.forEach(e),_i.forEach(e),yh=l(oa,`
as its input. `),$l=r(oa,"CODE",{});var $i=o($l);wh=l($i,"ImageProcessor"),$i.forEach(e),Jh=l(oa,` can take care of normalizing the images, and generating appropriate tensors.
Create a function that combines image augmentation and image preprocessing for a batch of images and generates `),Ml=r(oa,"CODE",{});var Mi=o(Ml);_h=l(Mi,"pixel_values"),Mi.forEach(e),vh=l(oa,":"),oa.forEach(e),Ji.forEach(e),fp=m(s),f(ee.$$.fragment,s),bp=m(s),f(Os.$$.fragment,s),gp=m(s),ne=r(s,"OL",{start:!0});var Ti=o(ne);le=r(Ti,"LI",{});var dr=o(le);$h=l(dr,"Then use \u{1F917} Datasets "),te=r(dr,"A",{href:!0,rel:!0});var Ei=o(te);Tl=r(Ei,"CODE",{});var ki=o(Tl);Mh=l(ki,"set_transform"),ki.forEach(e),Ei.forEach(e),Th=l(dr," to apply the transforms on the fly:"),dr.forEach(e),Ti.forEach(e),yp=m(s),f(pe.$$.fragment,s),wp=m(s),re=r(s,"OL",{start:!0});var Ii=o(re);oe=r(Ii,"LI",{});var jr=o(oe);Eh=l(jr,"Now when you access the image, you\u2019ll notice the image processor has added "),El=r(jr,"CODE",{});var Ui=o(El);kh=l(Ui,"pixel_values"),Ui.forEach(e),Ih=l(jr,". You can pass your processed dataset to the model now!"),jr.forEach(e),Ii.forEach(e),Jp=m(s),f(ce.$$.fragment,s),_p=m(s),on=r(s,"P",{});var xi=o(on);Uh=l(xi,"Here is what the image looks like after the transforms are applied. The image has been randomly cropped and it\u2019s color properties are different."),xi.forEach(e),vp=m(s),f(he.$$.fragment,s),$p=m(s),me=r(s,"DIV",{class:!0});var Ci=o(me);kl=r(Ci,"IMG",{src:!0}),Ci.forEach(e),Mp=m(s),f(Ks.$$.fragment,s),Tp=m(s),Es=r(s,"H3",{class:!0});var fr=o(Es);sa=r(fr,"A",{id:!0,class:!0,href:!0});var Gi=o(sa);Il=r(Gi,"SPAN",{});var Zi=o(Il);f(ue.$$.fragment,Zi),Zi.forEach(e),Gi.forEach(e),xh=m(fr),Ul=r(fr,"SPAN",{});var Ai=o(Ul);Ch=l(Ai,"Pad"),Ai.forEach(e),fr.forEach(e),Ep=m(s),R=r(s,"P",{});var gs=o(R);Gh=l(gs,"In some cases, for instance, when fine-tuning "),cn=r(gs,"A",{href:!0});var Vi=o(cn);Zh=l(Vi,"DETR"),Vi.forEach(e),Ah=l(gs,`, the model applies scale augmentation at training
time. This may cause images to be different sizes in a batch. You can use `),xl=r(gs,"CODE",{});var zi=o(xl);Vh=l(zi,"DetrImageProcessor.pad()"),zi.forEach(e),zh=l(gs,`
from `),hn=r(gs,"A",{href:!0});var Bi=o(hn);Bh=l(Bi,"DetrImageProcessor"),Bi.forEach(e),Wh=l(gs," and define a custom "),Cl=r(gs,"CODE",{});var Wi=o(Cl);Nh=l(Wi,"collate_fn"),Wi.forEach(e),Rh=l(gs," to batch images together."),gs.forEach(e),kp=m(s),f(ie.$$.fragment,s),Ip=m(s),ks=r(s,"H2",{class:!0});var br=o(ks);aa=r(br,"A",{id:!0,class:!0,href:!0});var Ni=o(aa);Gl=r(Ni,"SPAN",{});var Ri=o(Gl);f(de.$$.fragment,Ri),Ri.forEach(e),Ni.forEach(e),Yh=m(br),Zl=r(br,"SPAN",{});var Yi=o(Zl);qh=l(Yi,"Multimodal"),Yi.forEach(e),br.forEach(e),Up=m(s),ea=r(s,"P",{});var gr=o(ea);Fh=l(gr,"For tasks involving multimodal inputs, you\u2019ll need a "),mn=r(gr,"A",{href:!0});var qi=o(mn);Xh=l(qi,"processor"),qi.forEach(e),Qh=l(gr," to prepare your dataset for the model. A processor couples together two processing objects such as as tokenizer and feature extractor."),gr.forEach(e),xp=m(s),ds=r(s,"P",{});var En=o(ds);Ph=l(En,"Load the "),je=r(En,"A",{href:!0,rel:!0});var Fi=o(je);Dh=l(Fi,"LJ Speech"),Fi.forEach(e),Sh=l(En," dataset (see the \u{1F917} "),fe=r(En,"A",{href:!0,rel:!0});var Xi=o(fe);Hh=l(Xi,"Datasets tutorial"),Xi.forEach(e),Lh=l(En," for more details on how to load a dataset) to see how you can use a processor for automatic speech recognition (ASR):"),En.forEach(e),Cp=m(s),f(be.$$.fragment,s),Gp=m(s),js=r(s,"P",{});var kn=o(js);Oh=l(kn,"For ASR, you\u2019re mainly focused on "),Al=r(kn,"CODE",{});var Qi=o(Al);Kh=l(Qi,"audio"),Qi.forEach(e),sm=l(kn," and "),Vl=r(kn,"CODE",{});var Pi=o(Vl);am=l(Pi,"text"),Pi.forEach(e),em=l(kn," so you can remove the other columns:"),kn.forEach(e),Zp=m(s),f(ge.$$.fragment,s),Ap=m(s),fs=r(s,"P",{});var In=o(fs);nm=l(In,"Now take a look at the "),zl=r(In,"CODE",{});var Di=o(zl);lm=l(Di,"audio"),Di.forEach(e),tm=l(In," and "),Bl=r(In,"CODE",{});var Si=o(Bl);pm=l(Si,"text"),Si.forEach(e),rm=l(In," columns:"),In.forEach(e),Vp=m(s),f(ye.$$.fragment,s),zp=m(s),na=r(s,"P",{});var yr=o(na);om=l(yr,"Remember you should always "),un=r(yr,"A",{href:!0});var Hi=o(un);cm=l(Hi,"resample"),Hi.forEach(e),hm=l(yr," your audio dataset\u2019s sampling rate to match the sampling rate of the dataset used to pretrain a model!"),yr.forEach(e),Bp=m(s),f(we.$$.fragment,s),Wp=m(s),la=r(s,"P",{});var wr=o(la);mm=l(wr,"Load a processor with "),dn=r(wr,"A",{href:!0});var Li=o(dn);um=l(Li,"AutoProcessor.from_pretrained()"),Li.forEach(e),im=l(wr,":"),wr.forEach(e),Np=m(s),f(Je.$$.fragment,s),Rp=m(s),jn=r(s,"OL",{});var Oi=o(jn);F=r(Oi,"LI",{});var ys=o(F);dm=l(ys,"Create a function to process the audio data contained in "),Wl=r(ys,"CODE",{});var Ki=o(Wl);jm=l(Ki,"array"),Ki.forEach(e),fm=l(ys," to "),Nl=r(ys,"CODE",{});var sd=o(Nl);bm=l(sd,"input_values"),sd.forEach(e),gm=l(ys,", and tokenize "),Rl=r(ys,"CODE",{});var ad=o(Rl);ym=l(ad,"text"),ad.forEach(e),wm=l(ys," to "),Yl=r(ys,"CODE",{});var ed=o(Yl);Jm=l(ed,"labels"),ed.forEach(e),_m=l(ys,". These are the inputs to the model:"),ys.forEach(e),Oi.forEach(e),Yp=m(s),f(_e.$$.fragment,s),qp=m(s),ve=r(s,"OL",{start:!0});var nd=o(ve);$e=r(nd,"LI",{});var Jr=o($e);vm=l(Jr,"Apply the "),ql=r(Jr,"CODE",{});var ld=o(ql);$m=l(ld,"prepare_dataset"),ld.forEach(e),Mm=l(Jr," function to a sample:"),Jr.forEach(e),nd.forEach(e),Fp=m(s),f(Me.$$.fragment,s),Xp=m(s),bs=r(s,"P",{});var Un=o(bs);Tm=l(Un,"The processor has now added "),Fl=r(Un,"CODE",{});var td=o(Fl);Em=l(td,"input_values"),td.forEach(e),km=l(Un," and "),Xl=r(Un,"CODE",{});var pd=o(Xl);Im=l(pd,"labels"),pd.forEach(e),Um=l(Un,", and the sampling rate has also been correctly downsampled to 16kHz. You can pass your processed dataset to the model now!"),Un.forEach(e),this.h()},h(){i(u,"name","hf:doc:metadata"),i(u,"content",JSON.stringify(Ud)),i(J,"id","preprocess"),i(J,"class","header-link block pr-1.5 text-lg no-hover:hidden with-hover:absolute with-hover:p-1.5 with-hover:opacity-0 with-hover:group-hover:opacity-100 with-hover:right-full"),i(J,"href","#preprocess"),i(d,"class","relative group"),i(q,"href","./main_classes/tokenizer"),i(C,"href","./main_classes/feature_extractor"),i(ws,"href","./main_classes/image"),i(Ge,"href","./main_classes/processors"),i(xs,"id","natural-language-processing"),i(xs,"class","header-link block pr-1.5 text-lg no-hover:hidden with-hover:absolute with-hover:p-1.5 with-hover:opacity-0 with-hover:group-hover:opacity-100 with-hover:right-full"),i(xs,"href","#natural-language-processing"),i(Js,"class","relative group"),i(Ae,"href","main_classes/tokenizer"),i(Ve,"href","/docs/transformers/v4.31.0/en/model_doc/auto#transformers.AutoTokenizer.from_pretrained"),i(Ne,"href","glossary#input-ids"),i(Ye,"href","glossary#attention-mask"),i(Fe,"href","glossary#token-type-ids"),i(Zs,"id","pad"),i(Zs,"class","header-link block pr-1.5 text-lg no-hover:hidden with-hover:absolute with-hover:p-1.5 with-hover:opacity-0 with-hover:group-hover:opacity-100 with-hover:right-full"),i(Zs,"href","#pad"),i(_s,"class","relative group"),i(zs,"id","truncation"),i(zs,"class","header-link block pr-1.5 text-lg no-hover:hidden with-hover:absolute with-hover:p-1.5 with-hover:opacity-0 with-hover:group-hover:opacity-100 with-hover:right-full"),i(zs,"href","#truncation"),i(vs,"class","relative group"),i(Ws,"id","build-tensors"),i(Ws,"class","header-link block pr-1.5 text-lg no-hover:hidden with-hover:absolute with-hover:p-1.5 with-hover:opacity-0 with-hover:group-hover:opacity-100 with-hover:right-full"),i(Ws,"href","#build-tensors"),i($s,"class","relative group"),i(Rs,"id","audio"),i(Rs,"class","header-link block pr-1.5 text-lg no-hover:hidden with-hover:absolute with-hover:p-1.5 with-hover:opacity-0 with-hover:group-hover:opacity-100 with-hover:right-full"),i(Rs,"href","#audio"),i(Ms,"class","relative group"),i(De,"href","main_classes/feature_extractor"),i(va,"href","https://huggingface.co/datasets/PolyAI/minds14"),i(va,"rel","nofollow"),i($a,"href","https://huggingface.co/docs/datasets/load_hub.html"),i($a,"rel","nofollow"),i(Ea,"href","https://huggingface.co/facebook/wav2vec2-base"),i(Ea,"rel","nofollow"),i(Ia,"href","https://huggingface.co/docs/datasets/v2.13.1/en/package_reference/main_classes#datasets.Dataset.cast_column"),i(Ia,"rel","nofollow"),i(xa,"start","2"),i(sn,"href","/docs/transformers/v4.31.0/en/model_doc/auto#transformers.AutoFeatureExtractor.from_pretrained"),i(Qs,"id","computer-vision"),i(Qs,"class","header-link block pr-1.5 text-lg no-hover:hidden with-hover:absolute with-hover:p-1.5 with-hover:opacity-0 with-hover:group-hover:opacity-100 with-hover:right-full"),i(Qs,"href","#computer-vision"),i(Ts,"class","relative group"),i(ln,"href","main_classes/image_processor"),i(Ra,"href","https://huggingface.co/datasets/food101"),i(Ra,"rel","nofollow"),i(Ya,"href","https://huggingface.co/docs/datasets/load_hub.html"),i(Ya,"rel","nofollow"),i(Fa,"href","https://huggingface.co/docs/datasets/package_reference/main_classes.html?highlight=image#datasets.Image"),i(Fa,"rel","nofollow"),rd(fl.src,zm="https://huggingface.co/datasets/huggingface/documentation-images/resolve/main/vision-preprocess-tutorial.png")||i(fl,"src",zm),i(Qa,"class","flex justify-center"),i(tn,"href","/docs/transformers/v4.31.0/en/model_doc/auto#transformers.AutoImageProcessor.from_pretrained"),i(Da,"href","https://pytorch.org/vision/stable/transforms.html"),i(Da,"rel","nofollow"),i(Sa,"href","https://colab.research.google.com/github/huggingface/notebooks/blob/main/examples/image_classification_albumentations.ipynb"),i(Sa,"rel","nofollow"),i(Ha,"href","https://colab.research.google.com/github/huggingface/notebooks/blob/main/examples/image_classification_kornia.ipynb"),i(Ha,"rel","nofollow"),i(La,"href","https://pytorch.org/vision/master/generated/torchvision.transforms.Compose.html"),i(La,"rel","nofollow"),i(Oa,"href","https://pytorch.org/vision/main/generated/torchvision.transforms.RandomResizedCrop.html"),i(Oa,"rel","nofollow"),i(Ka,"href","https://pytorch.org/vision/main/generated/torchvision.transforms.ColorJitter.html"),i(Ka,"rel","nofollow"),i(rn,"href","model_doc/visionencoderdecoder#transformers.VisionEncoderDecoderModel.forward.pixel_values"),i(ae,"start","2"),i(te,"href","https://huggingface.co/docs/datasets/process.html#format-transform"),i(te,"rel","nofollow"),i(ne,"start","3"),i(re,"start","4"),rd(kl.src,Bm="https://huggingface.co/datasets/huggingface/documentation-images/resolve/main/preprocessed_image.png")||i(kl,"src",Bm),i(me,"class","flex justify-center"),i(sa,"id","pad"),i(sa,"class","header-link block pr-1.5 text-lg no-hover:hidden with-hover:absolute with-hover:p-1.5 with-hover:opacity-0 with-hover:group-hover:opacity-100 with-hover:right-full"),i(sa,"href","#pad"),i(Es,"class","relative group"),i(cn,"href","./model_doc/detr"),i(hn,"href","/docs/transformers/v4.31.0/en/model_doc/detr#transformers.DetrImageProcessor"),i(aa,"id","multimodal"),i(aa,"class","header-link block pr-1.5 text-lg no-hover:hidden with-hover:absolute with-hover:p-1.5 with-hover:opacity-0 with-hover:group-hover:opacity-100 with-hover:right-full"),i(aa,"href","#multimodal"),i(ks,"class","relative group"),i(mn,"href","main_classes/processors"),i(je,"href","https://huggingface.co/datasets/lj_speech"),i(je,"rel","nofollow"),i(fe,"href","https://huggingface.co/docs/datasets/load_hub.html"),i(fe,"rel","nofollow"),i(un,"href","preprocessing#audio"),i(dn,"href","/docs/transformers/v4.31.0/en/model_doc/auto#transformers.AutoProcessor.from_pretrained"),i(ve,"start","2")},m(s,t){a(document.head,u),c(s,_,t),c(s,d,t),a(d,J),a(J,$),b(v,$,null),a(d,M),a(d,k),a(k,x),c(s,Z,t),b(U,s,t),c(s,B,t),c(s,A,t),a(A,S),c(s,Y,t),c(s,T,t),a(T,G),a(G,W),a(G,q),a(q,K),a(G,N),a(T,ss),a(T,H),a(H,V),a(H,C),a(C,Ie),a(H,Ue),a(T,xe),a(T,as),a(as,es),a(as,ws),a(ws,Ce),a(as,_r),a(T,vr),a(T,ca),a(ca,$r),a(ca,Ge),a(Ge,Mr),a(ca,Tr),c(s,Ll,t),b(Us,s,t),c(s,Ol,t),c(s,Ze,t),a(Ze,Er),c(s,Kl,t),b(ha,s,t),c(s,st,t),c(s,Js,t),a(Js,xs),a(xs,xn),b(ma,xn,null),a(Js,kr),a(Js,Cn),a(Cn,Ir),c(s,at,t),b(ua,s,t),c(s,et,t),c(s,ns,t),a(ns,Ur),a(ns,Ae),a(Ae,xr),a(ns,Cr),a(ns,Gn),a(Gn,Gr),a(ns,Zr),c(s,nt,t),b(Cs,s,t),c(s,lt,t),c(s,ls,t),a(ls,Ar),a(ls,Ve),a(Ve,Vr),a(ls,zr),a(ls,Zn),a(Zn,Br),a(ls,Wr),c(s,tt,t),b(ia,s,t),c(s,pt,t),c(s,ze,t),a(ze,Nr),c(s,rt,t),b(da,s,t),c(s,ot,t),c(s,Be,t),a(Be,Rr),c(s,ct,t),c(s,ts,t),a(ts,We),a(We,Ne),a(Ne,Yr),a(We,qr),a(ts,Fr),a(ts,Re),a(Re,Ye),a(Ye,Xr),a(Re,Qr),a(ts,Pr),a(ts,qe),a(qe,Fe),a(Fe,Dr),a(qe,Sr),c(s,ht,t),c(s,Gs,t),a(Gs,Hr),a(Gs,An),a(An,Lr),a(Gs,Or),c(s,mt,t),b(ja,s,t),c(s,ut,t),c(s,ps,t),a(ps,Kr),a(ps,Vn),a(Vn,so),a(ps,ao),a(ps,zn),a(zn,eo),a(ps,no),c(s,it,t),c(s,Xe,t),a(Xe,lo),c(s,dt,t),b(fa,s,t),c(s,jt,t),c(s,_s,t),a(_s,Zs),a(Zs,Bn),b(ba,Bn,null),a(_s,to),a(_s,Wn),a(Wn,po),c(s,ft,t),c(s,As,t),a(As,ro),a(As,Nn),a(Nn,oo),a(As,co),c(s,bt,t),c(s,rs,t),a(rs,ho),a(rs,Rn),a(Rn,mo),a(rs,uo),a(rs,Yn),a(Yn,io),a(rs,jo),c(s,gt,t),b(ga,s,t),c(s,yt,t),c(s,Vs,t),a(Vs,fo),a(Vs,qn),a(qn,bo),a(Vs,go),c(s,wt,t),c(s,vs,t),a(vs,zs),a(zs,Fn),b(ya,Fn,null),a(vs,yo),a(vs,Xn),a(Xn,wo),c(s,Jt,t),c(s,Qe,t),a(Qe,Jo),c(s,_t,t),c(s,os,t),a(os,_o),a(os,Qn),a(Qn,vo),a(os,$o),a(os,Pn),a(Pn,Mo),a(os,To),c(s,vt,t),b(wa,s,t),c(s,$t,t),b(Bs,s,t),c(s,Mt,t),c(s,$s,t),a($s,Ws),a(Ws,Dn),b(Ja,Dn,null),a($s,Eo),a($s,Sn),a(Sn,ko),c(s,Tt,t),c(s,Pe,t),a(Pe,Io),c(s,Et,t),c(s,X,t),a(X,Uo),a(X,Hn),a(Hn,xo),a(X,Co),a(X,Ln),a(Ln,Go),a(X,Zo),a(X,On),a(On,Ao),a(X,Vo),c(s,kt,t),b(Ns,s,t),c(s,It,t),c(s,Ms,t),a(Ms,Rs),a(Rs,Kn),b(_a,Kn,null),a(Ms,zo),a(Ms,sl),a(sl,Bo),c(s,Ut,t),c(s,Ys,t),a(Ys,Wo),a(Ys,De),a(De,No),a(Ys,Ro),c(s,xt,t),c(s,cs,t),a(cs,Yo),a(cs,va),a(va,qo),a(cs,Fo),a(cs,$a),a($a,Xo),a(cs,Qo),c(s,Ct,t),b(Ma,s,t),c(s,Gt,t),c(s,hs,t),a(hs,Po),a(hs,al),a(al,Do),a(hs,So),a(hs,el),a(el,Ho),a(hs,Lo),c(s,Zt,t),b(Ta,s,t),c(s,At,t),c(s,Se,t),a(Se,Oo),c(s,Vt,t),c(s,ms,t),a(ms,He),a(He,nl),a(nl,Ko),a(He,sc),a(ms,ac),a(ms,Le),a(Le,ll),a(ll,ec),a(Le,nc),a(ms,lc),a(ms,Oe),a(Oe,tl),a(tl,tc),a(Oe,pc),c(s,zt,t),c(s,qs,t),a(qs,rc),a(qs,Ea),a(Ea,oc),a(qs,cc),c(s,Bt,t),c(s,Ke,t),a(Ke,ka),a(ka,hc),a(ka,Ia),a(Ia,mc),a(ka,uc),c(s,Wt,t),b(Ua,s,t),c(s,Nt,t),c(s,xa,t),a(xa,Ca),a(Ca,ic),a(Ca,pl),a(pl,dc),a(Ca,jc),c(s,Rt,t),b(Ga,s,t),c(s,Yt,t),c(s,Q,t),a(Q,fc),a(Q,rl),a(rl,bc),a(Q,gc),a(Q,ol),a(ol,yc),a(Q,wc),a(Q,cl),a(cl,Jc),a(Q,_c),c(s,qt,t),c(s,Fs,t),a(Fs,vc),a(Fs,sn),a(sn,$c),a(Fs,Mc),c(s,Ft,t),b(Za,s,t),c(s,Xt,t),c(s,us,t),a(us,Tc),a(us,hl),a(hl,Ec),a(us,kc),a(us,ml),a(ml,Ic),a(us,Uc),c(s,Qt,t),b(Aa,s,t),c(s,Pt,t),c(s,an,t),a(an,xc),c(s,Dt,t),b(Va,s,t),c(s,St,t),c(s,en,t),a(en,Cc),c(s,Ht,t),b(za,s,t),c(s,Lt,t),c(s,Xs,t),a(Xs,Gc),a(Xs,ul),a(ul,Zc),a(Xs,Ac),c(s,Ot,t),b(Ba,s,t),c(s,Kt,t),c(s,nn,t),a(nn,Vc),c(s,sp,t),b(Wa,s,t),c(s,ap,t),c(s,Ts,t),a(Ts,Qs),a(Qs,il),b(Na,il,null),a(Ts,zc),a(Ts,dl),a(dl,Bc),c(s,ep,t),c(s,Ps,t),a(Ps,Wc),a(Ps,ln),a(ln,Nc),a(Ps,Rc),c(s,np,t),b(Ds,s,t),c(s,lp,t),c(s,is,t),a(is,Yc),a(is,Ra),a(Ra,qc),a(is,Fc),a(is,Ya),a(Ya,Xc),a(is,Qc),c(s,tp,t),b(Ss,s,t),c(s,pp,t),b(qa,s,t),c(s,rp,t),c(s,Hs,t),a(Hs,Pc),a(Hs,Fa),a(Fa,jl),a(jl,Dc),a(Hs,Sc),c(s,op,t),b(Xa,s,t),c(s,cp,t),c(s,Qa,t),a(Qa,fl),c(s,hp,t),c(s,Ls,t),a(Ls,Hc),a(Ls,tn),a(tn,Lc),a(Ls,Oc),c(s,mp,t),b(Pa,s,t),c(s,up,t),c(s,P,t),a(P,Kc),a(P,Da),a(Da,bl),a(bl,sh),a(P,ah),a(P,Sa),a(Sa,eh),a(P,nh),a(P,Ha),a(Ha,lh),a(P,th),c(s,ip,t),c(s,pn,t),a(pn,z),a(z,ph),a(z,La),a(La,gl),a(gl,rh),a(z,oh),a(z,Oa),a(Oa,yl),a(yl,ch),a(z,hh),a(z,Ka),a(Ka,wl),a(wl,mh),a(z,uh),a(z,Jl),a(Jl,ih),a(z,dh),a(z,_l),a(_l,jh),a(z,fh),c(s,dp,t),b(se,s,t),c(s,jp,t),c(s,ae,t),a(ae,L),a(L,bh),a(L,rn),a(rn,vl),a(vl,gh),a(L,yh),a(L,$l),a($l,wh),a(L,Jh),a(L,Ml),a(Ml,_h),a(L,vh),c(s,fp,t),b(ee,s,t),c(s,bp,t),b(Os,s,t),c(s,gp,t),c(s,ne,t),a(ne,le),a(le,$h),a(le,te),a(te,Tl),a(Tl,Mh),a(le,Th),c(s,yp,t),b(pe,s,t),c(s,wp,t),c(s,re,t),a(re,oe),a(oe,Eh),a(oe,El),a(El,kh),a(oe,Ih),c(s,Jp,t),b(ce,s,t),c(s,_p,t),c(s,on,t),a(on,Uh),c(s,vp,t),b(he,s,t),c(s,$p,t),c(s,me,t),a(me,kl),c(s,Mp,t),b(Ks,s,t),c(s,Tp,t),c(s,Es,t),a(Es,sa),a(sa,Il),b(ue,Il,null),a(Es,xh),a(Es,Ul),a(Ul,Ch),c(s,Ep,t),c(s,R,t),a(R,Gh),a(R,cn),a(cn,Zh),a(R,Ah),a(R,xl),a(xl,Vh),a(R,zh),a(R,hn),a(hn,Bh),a(R,Wh),a(R,Cl),a(Cl,Nh),a(R,Rh),c(s,kp,t),b(ie,s,t),c(s,Ip,t),c(s,ks,t),a(ks,aa),a(aa,Gl),b(de,Gl,null),a(ks,Yh),a(ks,Zl),a(Zl,qh),c(s,Up,t),c(s,ea,t),a(ea,Fh),a(ea,mn),a(mn,Xh),a(ea,Qh),c(s,xp,t),c(s,ds,t),a(ds,Ph),a(ds,je),a(je,Dh),a(ds,Sh),a(ds,fe),a(fe,Hh),a(ds,Lh),c(s,Cp,t),b(be,s,t),c(s,Gp,t),c(s,js,t),a(js,Oh),a(js,Al),a(Al,Kh),a(js,sm),a(js,Vl),a(Vl,am),a(js,em),c(s,Zp,t),b(ge,s,t),c(s,Ap,t),c(s,fs,t),a(fs,nm),a(fs,zl),a(zl,lm),a(fs,tm),a(fs,Bl),a(Bl,pm),a(fs,rm),c(s,Vp,t),b(ye,s,t),c(s,zp,t),c(s,na,t),a(na,om),a(na,un),a(un,cm),a(na,hm),c(s,Bp,t),b(we,s,t),c(s,Wp,t),c(s,la,t),a(la,mm),a(la,dn),a(dn,um),a(la,im),c(s,Np,t),b(Je,s,t),c(s,Rp,t),c(s,jn,t),a(jn,F),a(F,dm),a(F,Wl),a(Wl,jm),a(F,fm),a(F,Nl),a(Nl,bm),a(F,gm),a(F,Rl),a(Rl,ym),a(F,wm),a(F,Yl),a(Yl,Jm),a(F,_m),c(s,Yp,t),b(_e,s,t),c(s,qp,t),c(s,ve,t),a(ve,$e),a($e,vm),a($e,ql),a(ql,$m),a($e,Mm),c(s,Fp,t),b(Me,s,t),c(s,Xp,t),c(s,bs,t),a(bs,Tm),a(bs,Fl),a(Fl,Em),a(bs,km),a(bs,Xl),a(Xl,Im),a(bs,Um),Qp=!0},p(s,[t]){const Te={};t&2&&(Te.$$scope={dirty:t,ctx:s}),Us.$set(Te);const Ql={};t&2&&(Ql.$$scope={dirty:t,ctx:s}),Cs.$set(Ql);const Pl={};t&2&&(Pl.$$scope={dirty:t,ctx:s}),Bs.$set(Pl);const Dl={};t&2&&(Dl.$$scope={dirty:t,ctx:s}),Ns.$set(Dl);const Sl={};t&2&&(Sl.$$scope={dirty:t,ctx:s}),Ds.$set(Sl);const O={};t&2&&(O.$$scope={dirty:t,ctx:s}),Ss.$set(O);const Ee={};t&2&&(Ee.$$scope={dirty:t,ctx:s}),Os.$set(Ee);const Hl={};t&2&&(Hl.$$scope={dirty:t,ctx:s}),Ks.$set(Hl)},i(s){Qp||(g(v.$$.fragment,s),g(U.$$.fragment,s),g(Us.$$.fragment,s),g(ha.$$.fragment,s),g(ma.$$.fragment,s),g(ua.$$.fragment,s),g(Cs.$$.fragment,s),g(ia.$$.fragment,s),g(da.$$.fragment,s),g(ja.$$.fragment,s),g(fa.$$.fragment,s),g(ba.$$.fragment,s),g(ga.$$.fragment,s),g(ya.$$.fragment,s),g(wa.$$.fragment,s),g(Bs.$$.fragment,s),g(Ja.$$.fragment,s),g(Ns.$$.fragment,s),g(_a.$$.fragment,s),g(Ma.$$.fragment,s),g(Ta.$$.fragment,s),g(Ua.$$.fragment,s),g(Ga.$$.fragment,s),g(Za.$$.fragment,s),g(Aa.$$.fragment,s),g(Va.$$.fragment,s),g(za.$$.fragment,s),g(Ba.$$.fragment,s),g(Wa.$$.fragment,s),g(Na.$$.fragment,s),g(Ds.$$.fragment,s),g(Ss.$$.fragment,s),g(qa.$$.fragment,s),g(Xa.$$.fragment,s),g(Pa.$$.fragment,s),g(se.$$.fragment,s),g(ee.$$.fragment,s),g(Os.$$.fragment,s),g(pe.$$.fragment,s),g(ce.$$.fragment,s),g(he.$$.fragment,s),g(Ks.$$.fragment,s),g(ue.$$.fragment,s),g(ie.$$.fragment,s),g(de.$$.fragment,s),g(be.$$.fragment,s),g(ge.$$.fragment,s),g(ye.$$.fragment,s),g(we.$$.fragment,s),g(Je.$$.fragment,s),g(_e.$$.fragment,s),g(Me.$$.fragment,s),Qp=!0)},o(s){y(v.$$.fragment,s),y(U.$$.fragment,s),y(Us.$$.fragment,s),y(ha.$$.fragment,s),y(ma.$$.fragment,s),y(ua.$$.fragment,s),y(Cs.$$.fragment,s),y(ia.$$.fragment,s),y(da.$$.fragment,s),y(ja.$$.fragment,s),y(fa.$$.fragment,s),y(ba.$$.fragment,s),y(ga.$$.fragment,s),y(ya.$$.fragment,s),y(wa.$$.fragment,s),y(Bs.$$.fragment,s),y(Ja.$$.fragment,s),y(Ns.$$.fragment,s),y(_a.$$.fragment,s),y(Ma.$$.fragment,s),y(Ta.$$.fragment,s),y(Ua.$$.fragment,s),y(Ga.$$.fragment,s),y(Za.$$.fragment,s),y(Aa.$$.fragment,s),y(Va.$$.fragment,s),y(za.$$.fragment,s),y(Ba.$$.fragment,s),y(Wa.$$.fragment,s),y(Na.$$.fragment,s),y(Ds.$$.fragment,s),y(Ss.$$.fragment,s),y(qa.$$.fragment,s),y(Xa.$$.fragment,s),y(Pa.$$.fragment,s),y(se.$$.fragment,s),y(ee.$$.fragment,s),y(Os.$$.fragment,s),y(pe.$$.fragment,s),y(ce.$$.fragment,s),y(he.$$.fragment,s),y(Ks.$$.fragment,s),y(ue.$$.fragment,s),y(ie.$$.fragment,s),y(de.$$.fragment,s),y(be.$$.fragment,s),y(ge.$$.fragment,s),y(ye.$$.fragment,s),y(we.$$.fragment,s),y(Je.$$.fragment,s),y(_e.$$.fragment,s),y(Me.$$.fragment,s),Qp=!1},d(s){e(u),s&&e(_),s&&e(d),w(v),s&&e(Z),w(U,s),s&&e(B),s&&e(A),s&&e(Y),s&&e(T),s&&e(Ll),w(Us,s),s&&e(Ol),s&&e(Ze),s&&e(Kl),w(ha,s),s&&e(st),s&&e(Js),w(ma),s&&e(at),w(ua,s),s&&e(et),s&&e(ns),s&&e(nt),w(Cs,s),s&&e(lt),s&&e(ls),s&&e(tt),w(ia,s),s&&e(pt),s&&e(ze),s&&e(rt),w(da,s),s&&e(ot),s&&e(Be),s&&e(ct),s&&e(ts),s&&e(ht),s&&e(Gs),s&&e(mt),w(ja,s),s&&e(ut),s&&e(ps),s&&e(it),s&&e(Xe),s&&e(dt),w(fa,s),s&&e(jt),s&&e(_s),w(ba),s&&e(ft),s&&e(As),s&&e(bt),s&&e(rs),s&&e(gt),w(ga,s),s&&e(yt),s&&e(Vs),s&&e(wt),s&&e(vs),w(ya),s&&e(Jt),s&&e(Qe),s&&e(_t),s&&e(os),s&&e(vt),w(wa,s),s&&e($t),w(Bs,s),s&&e(Mt),s&&e($s),w(Ja),s&&e(Tt),s&&e(Pe),s&&e(Et),s&&e(X),s&&e(kt),w(Ns,s),s&&e(It),s&&e(Ms),w(_a),s&&e(Ut),s&&e(Ys),s&&e(xt),s&&e(cs),s&&e(Ct),w(Ma,s),s&&e(Gt),s&&e(hs),s&&e(Zt),w(Ta,s),s&&e(At),s&&e(Se),s&&e(Vt),s&&e(ms),s&&e(zt),s&&e(qs),s&&e(Bt),s&&e(Ke),s&&e(Wt),w(Ua,s),s&&e(Nt),s&&e(xa),s&&e(Rt),w(Ga,s),s&&e(Yt),s&&e(Q),s&&e(qt),s&&e(Fs),s&&e(Ft),w(Za,s),s&&e(Xt),s&&e(us),s&&e(Qt),w(Aa,s),s&&e(Pt),s&&e(an),s&&e(Dt),w(Va,s),s&&e(St),s&&e(en),s&&e(Ht),w(za,s),s&&e(Lt),s&&e(Xs),s&&e(Ot),w(Ba,s),s&&e(Kt),s&&e(nn),s&&e(sp),w(Wa,s),s&&e(ap),s&&e(Ts),w(Na),s&&e(ep),s&&e(Ps),s&&e(np),w(Ds,s),s&&e(lp),s&&e(is),s&&e(tp),w(Ss,s),s&&e(pp),w(qa,s),s&&e(rp),s&&e(Hs),s&&e(op),w(Xa,s),s&&e(cp),s&&e(Qa),s&&e(hp),s&&e(Ls),s&&e(mp),w(Pa,s),s&&e(up),s&&e(P),s&&e(ip),s&&e(pn),s&&e(dp),w(se,s),s&&e(jp),s&&e(ae),s&&e(fp),w(ee,s),s&&e(bp),w(Os,s),s&&e(gp),s&&e(ne),s&&e(yp),w(pe,s),s&&e(wp),s&&e(re),s&&e(Jp),w(ce,s),s&&e(_p),s&&e(on),s&&e(vp),w(he,s),s&&e($p),s&&e(me),s&&e(Mp),w(Ks,s),s&&e(Tp),s&&e(Es),w(ue),s&&e(Ep),s&&e(R),s&&e(kp),w(ie,s),s&&e(Ip),s&&e(ks),w(de),s&&e(Up),s&&e(ea),s&&e(xp),s&&e(ds),s&&e(Cp),w(be,s),s&&e(Gp),s&&e(js),s&&e(Zp),w(ge,s),s&&e(Ap),s&&e(fs),s&&e(Vp),w(ye,s),s&&e(zp),s&&e(na),s&&e(Bp),w(we,s),s&&e(Wp),s&&e(la),s&&e(Np),w(Je,s),s&&e(Rp),s&&e(jn),s&&e(Yp),w(_e,s),s&&e(qp),s&&e(ve),s&&e(Fp),w(Me,s),s&&e(Xp),s&&e(bs)}}}const Ud={local:"preprocess",sections:[{local:"natural-language-processing",sections:[{local:"pad",title:"Pad"},{local:"truncation",title:"Truncation"},{local:"build-tensors",title:"Build tensors"}],title:"Natural Language Processing"},{local:"audio",title:"Audio"},{local:"computer-vision",sections:[{local:"pad",title:"Pad"}],title:"Computer vision"},{local:"multimodal",title:"Multimodal"}],title:"Preprocess"};function xd(I){return dd(()=>{new URLSearchParams(window.location.search).get("fw")}),[]}class Wd extends hd{constructor(u){super();md(this,u,xd,Id,ud,{})}}export{Wd as default,Ud as metadata};
