import{S as uf,i as hf,s as mf,e as r,k as u,w as d,t as n,M as ff,c as p,d as e,m as h,a as o,x as b,h as t,b as i,N as pf,G as a,g as c,y as j,q as g,o as _,B as $,v as df,L as of}from"../chunks/vendor-hf-doc-builder.js";import{T as Pe}from"../chunks/Tip-hf-doc-builder.js";import{Y as bf}from"../chunks/Youtube-hf-doc-builder.js";import{I as As}from"../chunks/IconCopyLink-hf-doc-builder.js";import{C as q}from"../chunks/CodeBlock-hf-doc-builder.js";import{D as jf}from"../chunks/DocNotebookDropdown-hf-doc-builder.js";import{F as gf,M as cf}from"../chunks/Markdown-hf-doc-builder.js";function _f(A){let m,w,f,v,k,y,E;return{c(){m=r("p"),w=r("code"),f=n("AutoProcessor"),v=u(),k=r("strong"),y=n("always"),E=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(P){m=p(P,"P",{});var C=o(m);w=p(C,"CODE",{});var I=o(w);f=t(I,"AutoProcessor"),I.forEach(e),v=h(C),k=p(C,"STRONG",{});var z=o(k);y=t(z,"always"),z.forEach(e),E=t(C," 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."),C.forEach(e)},m(P,C){c(P,m,C),a(m,w),a(w,f),a(m,v),a(m,k),a(k,y),a(m,E)},d(P){P&&e(m)}}}function $f(A){let m,w,f,v,k;return{c(){m=r("p"),w=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 "),f=r("em"),v=n("vocab"),k=n(") during pretraining.")},l(y){m=p(y,"P",{});var E=o(m);w=t(E,"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 "),f=p(E,"EM",{});var P=o(f);v=t(P,"vocab"),P.forEach(e),k=t(E,") during pretraining."),E.forEach(e)},m(y,E){c(y,m,E),a(m,w),a(m,f),a(f,v),a(m,k)},d(y){y&&e(m)}}}function vf(A){let m,w,f,v,k;return{c(){m=r("p"),w=n("Check out the "),f=r("a"),v=n("Padding and truncation"),k=n(" concept guide to learn more different padding and truncation arguments."),this.h()},l(y){m=p(y,"P",{});var E=o(m);w=t(E,"Check out the "),f=p(E,"A",{href:!0});var P=o(f);v=t(P,"Padding and truncation"),P.forEach(e),k=t(E," concept guide to learn more different padding and truncation arguments."),E.forEach(e),this.h()},h(){i(f,"href","./pad_truncation")},m(y,E){c(y,m,E),a(m,w),a(m,f),a(f,v),a(m,k)},d(y){y&&e(m)}}}function wf(A){let m,w;return m=new q({props:{code:`batch_sentences = [
    "But what about second breakfast?",
    "Don't think he knows about second breakfast, Pip.",
    "What about elevensies?",
]
encoded_input = tokenizer(batch_sentences, padding=True, truncation=True, return_tensors="pt")
print(encoded_input)`,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(){d(m.$$.fragment)},l(f){b(m.$$.fragment,f)},m(f,v){j(m,f,v),w=!0},p:of,i(f){w||(g(m.$$.fragment,f),w=!0)},o(f){_(m.$$.fragment,f),w=!1},d(f){$(m,f)}}}function yf(A){let m,w;return m=new cf({props:{$$slots:{default:[wf]},$$scope:{ctx:A}}}),{c(){d(m.$$.fragment)},l(f){b(m.$$.fragment,f)},m(f,v){j(m,f,v),w=!0},p(f,v){const k={};v&2&&(k.$$scope={dirty:v,ctx:f}),m.$set(k)},i(f){w||(g(m.$$.fragment,f),w=!0)},o(f){_(m.$$.fragment,f),w=!1},d(f){$(m,f)}}}function kf(A){let m,w;return m=new q({props:{code:`batch_sentences = [
    "But what about second breakfast?",
    "Don't think he knows about second breakfast, Pip.",
    "What about elevensies?",
]
encoded_input = tokenizer(batch_sentences, padding=True, truncation=True, return_tensors="tf")
print(encoded_input)`,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(){d(m.$$.fragment)},l(f){b(m.$$.fragment,f)},m(f,v){j(m,f,v),w=!0},p:of,i(f){w||(g(m.$$.fragment,f),w=!0)},o(f){_(m.$$.fragment,f),w=!1},d(f){$(m,f)}}}function Ef(A){let m,w;return m=new cf({props:{$$slots:{default:[kf]},$$scope:{ctx:A}}}),{c(){d(m.$$.fragment)},l(f){b(m.$$.fragment,f)},m(f,v){j(m,f,v),w=!0},p(f,v){const k={};v&2&&(k.$$scope={dirty:v,ctx:f}),m.$set(k)},i(f){w||(g(m.$$.fragment,f),w=!0)},o(f){_(m.$$.fragment,f),w=!1},d(f){$(m,f)}}}function xf(A){let m,w,f,v,k,y,E,P,C,I,z,N,O,V,W;return{c(){m=r("p"),w=n(`Image preprocessing often follows some form of image augmentation. Both image preprocessing and image augmentation
transform image data, but they serve different purposes:`),f=u(),v=r("ul"),k=r("li"),y=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."),E=u(),P=r("li"),C=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."),I=u(),z=r("p"),N=n("You can use any library you like for image augmentation. For image preprocessing, use the "),O=r("code"),V=n("ImageProcessor"),W=n(" associated with the model.")},l(x){m=p(x,"P",{});var T=o(m);w=t(T,`Image preprocessing often follows some form of image augmentation. Both image preprocessing and image augmentation
transform image data, but they serve different purposes:`),T.forEach(e),f=h(x),v=p(x,"UL",{});var F=o(v);k=p(F,"LI",{});var H=o(k);y=t(H,"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."),H.forEach(e),E=h(F),P=p(F,"LI",{});var Z=o(P);C=t(Z,"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.forEach(e),F.forEach(e),I=h(x),z=p(x,"P",{});var R=o(z);N=t(R,"You can use any library you like for image augmentation. For image preprocessing, use the "),O=p(R,"CODE",{});var ss=o(O);V=t(ss,"ImageProcessor"),ss.forEach(e),W=t(R," associated with the model."),R.forEach(e)},m(x,T){c(x,m,T),a(m,w),c(x,f,T),c(x,v,T),a(v,k),a(k,y),a(v,E),a(v,P),a(P,C),c(x,I,T),c(x,z,T),a(z,N),a(z,O),a(O,V),a(z,W)},d(x){x&&e(m),x&&e(f),x&&e(v),x&&e(I),x&&e(z)}}}function qf(A){let m,w,f,v,k;return{c(){m=r("p"),w=n("Use \u{1F917} Datasets "),f=r("code"),v=n("split"),k=n(" parameter to only load a small sample from the training split since the dataset is quite large!")},l(y){m=p(y,"P",{});var E=o(m);w=t(E,"Use \u{1F917} Datasets "),f=p(E,"CODE",{});var P=o(f);v=t(P,"split"),P.forEach(e),k=t(E," parameter to only load a small sample from the training split since the dataset is quite large!"),E.forEach(e)},m(y,E){c(y,m,E),a(m,w),a(m,f),a(f,v),a(m,k)},d(y){y&&e(m)}}}function Pf(A){let m,w,f,v,k,y,E,P,C,I,z,N,O,V,W,x,T,F,H,Z,R,ss,K;return{c(){m=r("p"),w=n("In the example above we set "),f=r("code"),v=n("do_resize=False"),k=n(` because we have already resized the images in the image augmentation transformation,
and leveraged the `),y=r("code"),E=n("size"),P=n(" attribute from the appropriate "),C=r("code"),I=n("image_processor"),z=n(`. If you do not resize images during image augmentation,
leave this parameter out. By default, `),N=r("code"),O=n("ImageProcessor"),V=n(" will handle the resizing."),W=u(),x=r("p"),T=n("If you wish to normalize images as a part of the augmentation transformation, use the "),F=r("code"),H=n("image_processor.image_mean"),Z=n(`,
and `),R=r("code"),ss=n("image_processor.image_std"),K=n(" values.")},l(L){m=p(L,"P",{});var D=o(m);w=t(D,"In the example above we set "),f=p(D,"CODE",{});var Ae=o(f);v=t(Ae,"do_resize=False"),Ae.forEach(e),k=t(D,` because we have already resized the images in the image augmentation transformation,
and leveraged the `),y=p(D,"CODE",{});var ze=o(y);E=t(ze,"size"),ze.forEach(e),P=t(D," attribute from the appropriate "),C=p(D,"CODE",{});var Ce=o(C);I=t(Ce,"image_processor"),Ce.forEach(e),z=t(D,`. If you do not resize images during image augmentation,
leave this parameter out. By default, `),N=p(D,"CODE",{});var as=o(N);O=t(as,"ImageProcessor"),as.forEach(e),V=t(D," will handle the resizing."),D.forEach(e),W=h(L),x=p(L,"P",{});var es=o(x);T=t(es,"If you wish to normalize images as a part of the augmentation transformation, use the "),F=p(es,"CODE",{});var $s=o(F);H=t($s,"image_processor.image_mean"),$s.forEach(e),Z=t(es,`,
and `),R=p(es,"CODE",{});var De=o(R);ss=t(De,"image_processor.image_std"),De.forEach(e),K=t(es," values."),es.forEach(e)},m(L,D){c(L,m,D),a(m,w),a(m,f),a(f,v),a(m,k),a(m,y),a(y,E),a(m,P),a(m,C),a(C,I),a(m,z),a(m,N),a(N,O),a(m,V),c(L,W,D),c(L,x,D),a(x,T),a(x,F),a(F,H),a(x,Z),a(x,R),a(R,ss),a(x,K)},d(L){L&&e(m),L&&e(W),L&&e(x)}}}function Af(A){let m,w,f,v,k;return{c(){m=r("p"),w=n("For tasks like object detection, semantic segmentation, instance segmentation, and panoptic segmentation, "),f=r("code"),v=n("ImageProcessor"),k=n(`
offers post processing methods. These methods convert model\u2019s raw outputs into meaningful predictions such as bounding boxes,
or segmentation maps.`)},l(y){m=p(y,"P",{});var E=o(m);w=t(E,"For tasks like object detection, semantic segmentation, instance segmentation, and panoptic segmentation, "),f=p(E,"CODE",{});var P=o(f);v=t(P,"ImageProcessor"),P.forEach(e),k=t(E,`
offers post processing methods. These methods convert model\u2019s raw outputs into meaningful predictions such as bounding boxes,
or segmentation maps.`),E.forEach(e)},m(y,E){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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"}]}}),zs=new Pe({props:{$$slots:{default:[_f]},$$scope:{ctx:A}}}),ua=new q({props:{code:"pip install datasets",highlighted:"pip install datasets"}}),ha=new As({}),ma=new bf({props:{id:"Yffk5aydLzg"}}),Ds=new Pe({props:{$$slots:{default:[$f]},$$scope:{ctx:A}}}),ia=new q({props:{code:`from transformers import AutoTokenizer

tokenizer = AutoTokenizer.from_pretrained("bert-base-cased")`,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>)`}}),fa=new q({props:{code:`encoded_input = tokenizer("Do not meddle in the affairs of wizards, for they are subtle and quick to anger.")
print(encoded_input)`,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>]}`}}),da=new q({props:{code:'tokenizer.decode(encoded_input["input_ids"])',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>`}}),ba=new q({props:{code:`batch_sentences = [
    "But what about second breakfast?",
    "Don't think he knows about second breakfast, Pip.",
    "What about elevensies?",
]
encoded_inputs = tokenizer(batch_sentences)
print(encoded_inputs)`,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>]]}`}}),ja=new As({}),ga=new q({props:{code:`batch_sentences = [
    "But what about second breakfast?",
    "Don't think he knows about second breakfast, Pip.",
    "What about elevensies?",
]
encoded_input = tokenizer(batch_sentences, padding=True)
print(encoded_input)`,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>]]}`}}),_a=new As({}),$a=new q({props:{code:`batch_sentences = [
    "But what about second breakfast?",
    "Don't think he knows about second breakfast, Pip.",
    "What about elevensies?",
]
encoded_input = tokenizer(batch_sentences, padding=True, truncation=True)
print(encoded_input)`,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>]]}`}}),Ns=new Pe({props:{$$slots:{default:[vf]},$$scope:{ctx:A}}}),va=new As({}),Rs=new gf({props:{pytorch:!0,tensorflow:!0,jax:!1,$$slots:{tensorflow:[Ef],pytorch:[yf]},$$scope:{ctx:A}}}),wa=new As({}),Ea=new q({props:{code:`from datasets import load_dataset, Audio

dataset = load_dataset("PolyAI/minds14", name="en-US", split="train")`,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>)`}}),xa=new q({props:{code:'dataset[0]["audio"]',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>}`}}),za=new q({props:{code:'dataset = dataset.cast_column("audio", Audio(sampling_rate=16_000))',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>))'}}),Ta=new q({props:{code:'dataset[0]["audio"]',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>}`}}),Ia=new q({props:{code:`from transformers import AutoFeatureExtractor

feature_extractor = AutoFeatureExtractor.from_pretrained("facebook/wav2vec2-base")`,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>)`}}),Oa=new q({props:{code:`audio_input = [dataset[0]["audio"]["array"]]
feature_extractor(audio_input, sampling_rate=16000)`,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)]}`}}),La=new q({props:{code:`dataset[0]["audio"]["array"].shape

dataset[1]["audio"]["array"].shape`,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>,)`}}),Sa=new q({props:{code:`def preprocess_function(examples):
    audio_arrays = [x["array"] for x in examples["audio"]]
    inputs = feature_extractor(
        audio_arrays,
        sampling_rate=16000,
        padding=True,
        max_length=100000,
        truncation=True,
    )
    return inputs`,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`}}),Na=new q({props:{code:"processed_dataset = preprocess_function(dataset[:5])",highlighted:'<span class="hljs-meta">&gt;&gt;&gt; </span>processed_dataset = preprocess_function(dataset[:<span class="hljs-number">5</span>])'}}),Fa=new q({props:{code:`processed_dataset["input_values"][0].shape

processed_dataset["input_values"][1].shape`,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>,)`}}),Ra=new As({}),Gs=new Pe({props:{$$slots:{default:[xf]},$$scope:{ctx:A}}}),Vs=new Pe({props:{$$slots:{default:[qf]},$$scope:{ctx:A}}}),Ha=new q({props:{code:`from datasets import load_dataset

dataset = load_dataset("food101", split="train[:100]")`,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>)`}}),Ya=new q({props:{code:'dataset[0]["image"]',highlighted:'<span class="hljs-meta">&gt;&gt;&gt; </span>dataset[<span class="hljs-number">0</span>][<span class="hljs-string">&quot;image&quot;</span>]'}}),Ua=new q({props:{code:`from transformers import AutoImageProcessor

image_processor = AutoImageProcessor.from_pretrained("google/vit-base-patch16-224")`,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 q({props:{code:`from torchvision.transforms import RandomResizedCrop, ColorJitter, Compose

size = (
    image_processor.size["shortest_edge"]
    if "shortest_edge" in image_processor.size
    else (image_processor.size["height"], image_processor.size["width"])
)

_transforms = Compose([RandomResizedCrop(size), ColorJitter(brightness=0.5, hue=0.5)])`,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 q({props:{code:`def transforms(examples):
    images = [_transforms(img.convert("RGB")) for img in examples["image"]]
    examples["pixel_values"] = image_processor(images, do_resize=False, return_tensors="pt")["pixel_values"]
    return examples`,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`}}),Xs=new Pe({props:{$$slots:{default:[Pf]},$$scope:{ctx:A}}}),re=new q({props:{code:"dataset.set_transform(transforms)",highlighted:'<span class="hljs-meta">&gt;&gt;&gt; </span>dataset.set_transform(transforms)'}}),ce=new q({props:{code:"dataset[0].keys()",highlighted:'<span class="hljs-meta">&gt;&gt;&gt; </span>dataset[<span class="hljs-number">0</span>].keys()'}}),ue=new q({props:{code:`import numpy as np
import matplotlib.pyplot as plt

img = dataset[0]["pixel_values"]
plt.imshow(img.permute(1, 2, 0))`,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>))`}}),Zs=new Pe({props:{$$slots:{default:[Af]},$$scope:{ctx:A}}}),me=new As({}),ie=new q({props:{code:`def collate_fn(batch):
    pixel_values = [item["pixel_values"] for item in batch]
    encoding = image_processor.pad_and_create_pixel_mask(pixel_values, return_tensors="pt")
    labels = [item["labels"] for item in batch]
    batch = {}
    batch["pixel_values"] = encoding["pixel_values"]
    batch["pixel_mask"] = encoding["pixel_mask"]
    batch["labels"] = labels
    return batch`,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_and_create_pixel_mask(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`}}),fe=new As({}),je=new q({props:{code:`from datasets import load_dataset

lj_speech = load_dataset("lj_speech", split="train")`,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 q({props:{code:'lj_speech = lj_speech.map(remove_columns=["file", "id", "normalized_text"])',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>])'}}),_e=new q({props:{code:`lj_speech[0]["audio"]

lj_speech[0]["text"]`,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>`}}),$e=new q({props:{code:'lj_speech = lj_speech.cast_column("audio", Audio(sampling_rate=16_000))',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>))'}}),ve=new q({props:{code:`from transformers import AutoProcessor

processor = AutoProcessor.from_pretrained("facebook/wav2vec2-base-960h")`,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>)`}}),we=new q({props:{code:`def prepare_dataset(example):
    audio = example["audio"]

    example.update(processor(audio=audio["array"], text=example["text"], sampling_rate=16000))

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