import{S as cc,i as hc,s as mc,e as o,k as c,w as M,t,M as Mc,c as i,d as e,m as h,a as p,x as d,h as n,b as m,N as rc,G as a,g as r,y,q as w,o as f,B as u,v as dc}from"../../chunks/vendor-hf-doc-builder.js";import{T as yc}from"../../chunks/Tip-hf-doc-builder.js";import{I as Ze}from"../../chunks/IconCopyLink-hf-doc-builder.js";import{C as J}from"../../chunks/CodeBlock-hf-doc-builder.js";import{D as wc}from"../../chunks/DocNotebookDropdown-hf-doc-builder.js";function fc(tl){let v,I,T,A,S,g,_s,F,B,P;return{c(){v=t(`The task illustrated in this tutorial is supported by the following model architectures:

`),I=o("p"),T=o("a"),A=t("TimeSformer"),S=t(", "),g=o("a"),_s=t("VideoMAE"),F=t(", "),B=o("a"),P=t("ViViT"),this.h()},l(b){v=n(b,`The task illustrated in this tutorial is supported by the following model architectures:

`),I=i(b,"P",{});var C=p(I);T=i(C,"A",{href:!0});var x=p(T);A=n(x,"TimeSformer"),x.forEach(e),S=n(C,", "),g=i(C,"A",{href:!0});var Ae=p(g);_s=n(Ae,"VideoMAE"),Ae.forEach(e),F=n(C,", "),B=i(C,"A",{href:!0});var Zs=p(B);P=n(Zs,"ViViT"),Zs.forEach(e),C.forEach(e),this.h()},h(){m(T,"href","../model_doc/timesformer"),m(g,"href","../model_doc/videomae"),m(B,"href","../model_doc/vivit")},m(b,C){r(b,v,C),r(b,I,C),a(I,T),a(T,A),a(I,S),a(I,g),a(g,_s),a(I,F),a(I,B),a(B,P)},d(b){b&&e(v),b&&e(I)}}}function uc(tl){let v,I,T,A,S,g,_s,F,B,P,b,C,x,Ae,Zs,Ee,en,nl,K,N,an,As,ln,tn,Es,nn,on,pn,sa,rn,ol,O,il,ke,cn,pl,ks,rl,V,hn,Gs,mn,Mn,ea,dn,yn,cl,Ge,wn,hl,Ws,ml,z,ss,aa,Bs,fn,la,un,Ml,es,Jn,Vs,jn,Un,dl,Rs,yl,We,Tn,wl,Xs,fl,Be,bn,ul,$s,Jl,as,In,ta,vn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ut,X,Li,be,Oa,Pi,Ki,sl,Oi,sp,Tt,Ie,bt,Us,ep,el,ap,lp,It,ve,vt,Ts,tp,al,np,op,gt,ge,Ct,bs,ip,ll,pp,rp,_t,Ce,Zt;return g=new Ze({}),b=new wc({props:{classNames:"absolute z-10 right-0 top-0",options:[{label:"Mixed",value:"https://colab.research.google.com/github/huggingface/notebooks/blob/main/transformers_doc/en/video_classification.ipynb"},{label:"PyTorch",value:"https://colab.research.google.com/github/huggingface/notebooks/blob/main/transformers_doc/en/pytorch/video_classification.ipynb"},{label:"TensorFlow",value:"https://colab.research.google.com/github/huggingface/notebooks/blob/main/transformers_doc/en/tensorflow/video_classification.ipynb"},{label:"Mixed",value:"https://studiolab.sagemaker.aws/import/github/huggingface/notebooks/blob/main/transformers_doc/en/video_classification.ipynb"},{label:"PyTorch",value:"https://studiolab.sagemaker.aws/import/github/huggingface/notebooks/blob/main/transformers_doc/en/pytorch/video_classification.ipynb"},{label:"TensorFlow",value:"https://studiolab.sagemaker.aws/import/github/huggingface/notebooks/blob/main/transformers_doc/en/tensorflow/video_classification.ipynb"}]}}),O=new yc({props:{$$slots:{default:[fc]},$$scope:{ctx:tl}}}),ks=new J({props:{code:"cGlwJTIwaW5zdGFsbCUyMC1xJTIwcHl0b3JjaHZpZGVvJTIwdHJhbnNmb3JtZXJzJTIwZXZhbHVhdGU=",highlighted:"pip install -q pytorchvideo transformers evaluate"}}),Ws=new J({props:{code:"ZnJvbSUyMGh1Z2dpbmdmYWNlX2h1YiUyMGltcG9ydCUyMG5vdGVib29rX2xvZ2luJTBBJTBBbm90ZWJvb2tfbG9naW4oKQ==",highlighted:`<span class="hljs-meta">&gt;&gt;&gt; </span><span class="hljs-keyword">from</span> huggingface_hub <span class="hljs-keyword">import</span> notebook_login

<span class="hljs-meta">&gt;&gt;&gt; </span>notebook_login()`}}),Bs=new Ze({}),Rs=new J({props:{code:"ZnJvbSUyMGh1Z2dpbmdmYWNlX2h1YiUyMGltcG9ydCUyMGhmX2h1Yl9kb3dubG9hZCUwQSUwQWhmX2RhdGFzZXRfaWRlbnRpZmllciUyMCUzRCUyMCUyMnNheWFrcGF1bCUyRnVjZjEwMS1zdWJzZXQlMjIlMEFmaWxlbmFtZSUyMCUzRCUyMCUyMlVDRjEwMV9zdWJzZXQudGFyLmd6JTIyJTBBZmlsZV9wYXRoJTIwJTNEJTIwaGZfaHViX2Rvd25sb2FkKHJlcG9faWQlM0RoZl9kYXRhc2V0X2lkZW50aWZpZXIlMkMlMjBmaWxlbmFtZSUzRGZpbGVuYW1lJTJDJTIwcmVwb190eXBlJTNEJTIyZGF0YXNldCUyMik=",highlighted:`<span class="hljs-meta">&gt;&gt;&gt; </span><span class="hljs-keyword">from</span> huggingface_hub <span class="hljs-keyword">import</span> hf_hub_download

<span class="hljs-meta">&gt;&gt;&gt; </span>hf_dataset_identifier = <span class="hljs-string">&quot;sayakpaul/ucf101-subset&quot;</span>
<span class="hljs-meta">&gt;&gt;&gt; </span>filename = <span class="hljs-string">&quot;UCF101_subset.tar.gz&quot;</span>
<span class="hljs-meta">&gt;&gt;&gt; </span>file_path = hf_hub_download(repo_id=hf_dataset_identifier, filename=filename, repo_type=<span class="hljs-string">&quot;dataset&quot;</span>)`}}),Xs=new J({props:{code:"aW1wb3J0JTIwdGFyZmlsZSUwQSUwQXdpdGglMjB0YXJmaWxlLm9wZW4oZmlsZV9wYXRoKSUyMGFzJTIwdCUzQSUwQSUyMCUyMCUyMCUyMCUyMHQuZXh0cmFjdGFsbCglMjIuJTIyKQ==",highlighted:`<span class="hljs-meta">&gt;&gt;&gt; </span><span class="hljs-keyword">import</span> tarfile

<span class="hljs-meta">&gt;&gt;&gt; </span><span class="hljs-keyword">with</span> tarfile.<span class="hljs-built_in">open</span>(file_path) <span class="hljs-keyword">as</span> t:
<span class="hljs-meta">... </span>     t.extractall(<span class="hljs-string">&quot;.&quot;</span>)`}}),$s=new J({props:{code:"VUNGMTAxX3N1YnNldCUyRiUwQSUyMCUyMCUyMCUyMH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uJTBBJTIwJTIwJTIwJTIwJTIwJTIwJTIwJTIwLi4uJTBBJTIwJTIwJTIwJTIwdGVzdCUyRiUwQSUyMCUyMCUyMCUyMCUyMCUyMCUyMCUyMEJhbmRNYXJjaGluZyUyRiUwQSUyMCUyMCUyMCUyMCUyMCUyMCUyMCUyMCUyMCUyMCUyMCUyMHZpZGVvXzEubXA0JTBBJTIwJTIwJTIwJTIwJTIwJTIwJTIwJTIwJTIwJTIwJTIwJTIwdmlkZW9fMi5tcDQlMEElMjAlMjAlMjAlMjAlMjAlMjAlMjAlMjAlMjAlMjAlMjAlMjAuLi4lMEElMjAlMjAlMjAlMjAlMjAlMjAlMjAlMjBBcmNoZXJ5JTBBJTIwJTIwJTIwJTIwJTIwJTIwJTIwJTIwJTIwJTIwJTIwJTIwdmlkZW9fMS5tcDQlMEElMjAlMjAlMjAlMjAlMjAlMjAlMjAlMjAlMjAlMjAlMjAlMjB2aWRlb18yLm1wNCUwQSUyMCUyMCUyMCUyMCUyMCUyMCUyMCUyMCUyMCUyMCUyMCUyMC4uLiUwQSUyMCUyMCUyMCUyMCUyMCUyMCUyMCUyMC4uLg==",highlighted:`UCF101_subset/
    train/
        BandMarching/
            video_1.mp4
            video_2.mp4
            ...
        Archery
            video_1.mp4
            video_2.mp4
            ...
        ...
    val/
        BandMarching/
            video_1.mp4
            video_2.mp4
            ...
        Archery
            video_1.mp4
            video_2.mp4
            ...
        ...
    <span class="hljs-built_in">test</span>/
        BandMarching/
            video_1.mp4
            video_2.mp4
            ...
        Archery
            video_1.mp4
            video_2.mp4
            ...
        ...`}}),Ss=new J({props:{code:"",highlighted:`...
<span class="hljs-string">&#x27;UCF101_subset/train/ApplyEyeMakeup/v_ApplyEyeMakeup_g07_c04.avi&#x27;</span>,
<span class="hljs-string">&#x27;UCF101_subset/train/ApplyEyeMakeup/v_ApplyEyeMakeup_g07_c06.avi&#x27;</span>,
<span class="hljs-string">&#x27;UCF101_subset/train/ApplyEyeMakeup/v_ApplyEyeMakeup_g08_c01.avi&#x27;</span>,
<span class="hljs-string">&#x27;UCF101_subset/train/ApplyEyeMakeup/v_ApplyEyeMakeup_g09_c02.avi&#x27;</span>,
<span class="hljs-string">&#x27;UCF101_subset/train/ApplyEyeMakeup/v_ApplyEyeMakeup_g09_c06.avi&#x27;</span>
...`}}),xs=new J({props:{code:"Y2xhc3NfbGFiZWxzJTIwJTNEJTIwc29ydGVkKCU3QnN0cihwYXRoKS5zcGxpdCglMjIlMkYlMjIpJTVCMiU1RCUyMGZvciUyMHBhdGglMjBpbiUyMGFsbF92aWRlb19maWxlX3BhdGhzJTdEKSUwQWxhYmVsMmlkJTIwJTNEJTIwJTdCbGFiZWwlM0ElMjBpJTIwZm9yJTIwaSUyQyUyMGxhYmVsJTIwaW4lMjBlbnVtZXJhdGUoY2xhc3NfbGFiZWxzKSU3RCUwQWlkMmxhYmVsJTIwJTNEJTIwJTdCaSUzQSUyMGxhYmVsJTIwZm9yJTIwbGFiZWwlMkMlMjBpJTIwaW4lMjBsYWJlbDJpZC5pdGVtcygpJTdEJTBBJTBBcHJpbnQoZiUyMlVuaXF1ZSUyMGNsYXNzZXMlM0ElMjAlN0JsaXN0KGxhYmVsMmlkLmtleXMoKSklN0QuJTIyKSUwQQ==",highlighted:`<span class="hljs-meta">&gt;&gt;&gt; </span>class_labels = <span class="hljs-built_in">sorted</span>({<span class="hljs-built_in">str</span>(path).split(<span class="hljs-string">&quot;/&quot;</span>)[<span class="hljs-number">2</span>] <span class="hljs-keyword">for</span> path <span class="hljs-keyword">in</span> all_video_file_paths})
<span class="hljs-meta">&gt;&gt;&gt; </span>label2id = {label: i <span class="hljs-keyword">for</span> i, label <span class="hljs-keyword">in</span> <span class="hljs-built_in">enumerate</span>(class_labels)}
<span class="hljs-meta">&gt;&gt;&gt; </span>id2label = {i: label <span class="hljs-keyword">for</span> label, i <span class="hljs-keyword">in</span> label2id.items()}

<span class="hljs-meta">&gt;&gt;&gt; </span><span class="hljs-built_in">print</span>(<span class="hljs-string">f&quot;Unique classes: <span class="hljs-subst">{<span class="hljs-built_in">list</span>(label2id.keys())}</span>.&quot;</span>)

<span class="hljs-comment"># Unique classes: [&#x27;ApplyEyeMakeup&#x27;, &#x27;ApplyLipstick&#x27;, &#x27;Archery&#x27;, &#x27;BabyCrawling&#x27;, &#x27;BalanceBeam&#x27;, &#x27;BandMarching&#x27;, &#x27;BaseballPitch&#x27;, &#x27;Basketball&#x27;, &#x27;BasketballDunk&#x27;, &#x27;BenchPress&#x27;].</span>`}}),Ns=new Ze({}),zs=new J({props:{code:"ZnJvbSUyMHRyYW5zZm9ybWVycyUyMGltcG9ydCUyMFZpZGVvTUFFSW1hZ2VQcm9jZXNzb3IlMkMlMjBWaWRlb01BRUZvclZpZGVvQ2xhc3NpZmljYXRpb24lMEElMEFtb2RlbF9ja3B0JTIwJTNEJTIwJTIyTUNHLU5KVSUyRnZpZGVvbWFlLWJhc2UlMjIlMEFpbWFnZV9wcm9jZXNzb3IlMjAlM0QlMjBWaWRlb01BRUltYWdlUHJvY2Vzc29yLmZyb21fcHJldHJhaW5lZChtb2RlbF9ja3B0KSUwQW1vZGVsJTIwJTNEJTIwVmlkZW9NQUVGb3JWaWRlb0NsYXNzaWZpY2F0aW9uLmZyb21fcHJldHJhaW5lZCglMEElMjAlMjAlMjAlMjBtb2RlbF9ja3B0JTJDJTBBJTIwJTIwJTIwJTIwbGFiZWwyaWQlM0RsYWJlbDJpZCUyQyUwQSUyMCUyMCUyMCUyMGlkMmxhYmVsJTNEaWQybGFiZWwlMkMlMEElMjAlMjAlMjAlMjBpZ25vcmVfbWlzbWF0Y2hlZF9zaXplcyUzRFRydWUlMkMlMjAlMjAlMjMlMjBwcm92aWRlJTIwdGhpcyUyMGluJTIwY2FzZSUyMHlvdSdyZSUyMHBsYW5uaW5nJTIwdG8lMjBmaW5lLXR1bmUlMjBhbiUyMGFscmVhZHklMjBmaW5lLXR1bmVkJTIwY2hlY2twb2ludCUwQSk=",highlighted:`<span class="hljs-meta">&gt;&gt;&gt; </span><span class="hljs-keyword">from</span> transformers <span class="hljs-keyword">import</span> VideoMAEImageProcessor, VideoMAEForVideoClassification

<span class="hljs-meta">&gt;&gt;&gt; </span>model_ckpt = <span class="hljs-string">&quot;MCG-NJU/videomae-base&quot;</span>
<span class="hljs-meta">&gt;&gt;&gt; </span>image_processor = VideoMAEImageProcessor.from_pretrained(model_ckpt)
<span class="hljs-meta">&gt;&gt;&gt; </span>model = VideoMAEForVideoClassification.from_pretrained(
<span class="hljs-meta">... </span>    model_ckpt,
<span class="hljs-meta">... </span>    label2id=label2id,
<span class="hljs-meta">... </span>    id2label=id2label,
<span class="hljs-meta">... </span>    ignore_mismatched_sizes=<span class="hljs-literal">True</span>,  <span class="hljs-comment"># provide this in case you&#x27;re planning to fine-tune an already fine-tuned checkpoint</span>
<span class="hljs-meta">... </span>)`}}),Ys=new J({props:{code:"U29tZSUyMHdlaWdodHMlMjBvZiUyMHRoZSUyMG1vZGVsJTIwY2hlY2twb2ludCUyMGF0JTIwTUNHLU5KVSUyRnZpZGVvbWFlLWJhc2UlMjB3ZXJlJTIwbm90JTIwdXNlZCUyMHdoZW4lMjBpbml0aWFsaXppbmclMjBWaWRlb01BRUZvclZpZGVvQ2xhc3NpZmljYXRpb24lM0ElMjAlNUIuLi4lMkMlMjAnZGVjb2Rlci5kZWNvZGVyX2xheWVycy4xLmF0dGVudGlvbi5vdXRwdXQuZGVuc2UuYmlhcyclMkMlMjAnZGVjb2Rlci5kZWNvZGVyX2xheWVycy4yLmF0dGVudGlvbi5hdHRlbnRpb24ua2V5LndlaWdodCclNUQlMEEtJTIwVGhpcyUyMElTJTIwZXhwZWN0ZWQlMjBpZiUyMHlvdSUyMGFyZSUyMGluaXRpYWxpemluZyUyMFZpZGVvTUFFRm9yVmlkZW9DbGFzc2lmaWNhdGlvbiUyMGZyb20lMjB0aGUlMjBjaGVja3BvaW50JTIwb2YlMjBhJTIwbW9kZWwlMjB0cmFpbmVkJTIwb24lMjBhbm90aGV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YmxlJTIwdG8lMjB1c2UlMjBpdCUyMGZvciUyMHByZWRpY3Rpb25zJTIwYW5kJTIwaW5mZXJlbmNlLg==",highlighted:`Some weights of the model checkpoint at MCG-NJU/videomae-base were not used when initializing VideoMAEForVideoClassification: [..., <span class="hljs-string">&#x27;decoder.decoder_layers.1.attention.output.dense.bias&#x27;</span>, <span class="hljs-string">&#x27;decoder.decoder_layers.2.attention.attention.key.weight&#x27;</span>]
- This IS expected <span class="hljs-keyword">if</span> you are initializing VideoMAEForVideoClassification from the checkpoint of a model trained on another task or with another architecture (e.g. initializing a BertForSequenceClassification model from a BertForPreTraining model).
- This IS NOT expected <span class="hljs-keyword">if</span> you are initializing VideoMAEForVideoClassification from the checkpoint of a model that you expect to be exactly identical (initializing a BertForSequenceClassification model from a BertForSequenceClassification model).
Some weights of VideoMAEForVideoClassification were not initialized from the model checkpoint at MCG-NJU/videomae-base and are newly initialized: [<span class="hljs-string">&#x27;classifier.bias&#x27;</span>, <span class="hljs-string">&#x27;classifier.weight&#x27;</span>]
You should probably TRAIN this model on a down-stream task to be able to use it <span class="hljs-keyword">for</span> predictions and inference.`}}),Ds=new Ze({}),Ls=new J({props:{code:"aW1wb3J0JTIwcHl0b3JjaHZpZGVvLmRhdGElMEElMEFmcm9tJTIwcHl0b3JjaHZpZGVvLnRyYW5zZm9ybXMlMjBpbXBvcnQlMjAoJTBBJTIwJTIwJTIwJTIwQXBwbHlUcmFuc2Zvcm1Ub0tleSUyQyUwQSUyMCUyMCUyMCUyME5vcm1hbGl6ZSUyQyUwQSUyMCUyMCUyMCUyMFJhbmRvbVNob3J0U2lkZVNjYWxlJTJDJTBBJTIwJTIwJTIwJTIwUmVtb3ZlS2V5JTJDJTBBJTIwJTIwJTIwJTIwU2hvcnRTaWRlU2NhbGUlMkMlMEElMjAlMjAlMjAlMjBVbmlmb3JtVGVtcG9yYWxTdWJzYW1wbGUlMkMlMEEpJTBBJTBBZnJvbSUyMHRvcmNodmlzaW9uLnRyYW5zZm9ybXMlMjBpbXBvcnQlMjAoJTBBJTIwJTIwJTIwJTIwQ29tcG9zZSUyQyUwQSUyMCUyMCUyMCUyMExhbWJkYSUyQyUwQSUyMCUyMCUyMCUyMFJhbmRvbUNyb3AlMkMlMEElMjAlMjAlMjAlMjBSYW5kb21Ib3Jpem9udGFsRmxpcCUyQyUwQSUyMCUyMCUyMCUyMFJlc2l6ZSUyQyUwQSk=",highlighted:`<span class="hljs-meta">&gt;&gt;&gt; </span><span class="hljs-keyword">import</span> pytorchvideo.data

<span class="hljs-meta">&gt;&gt;&gt; </span><span class="hljs-keyword">from</span> pytorchvideo.transforms <span class="hljs-keyword">import</span> (
<span class="hljs-meta">... </span>    ApplyTransformToKey,
<span class="hljs-meta">... </span>    Normalize,
<span class="hljs-meta">... </span>    RandomShortSideScale,
<span class="hljs-meta">... </span>    RemoveKey,
<span class="hljs-meta">... </span>    ShortSideScale,
<span class="hljs-meta">... </span>    UniformTemporalSubsample,
<span class="hljs-meta">... </span>)

<span class="hljs-meta">&gt;&gt;&gt; </span><span class="hljs-keyword">from</span> torchvision.transforms <span class="hljs-keyword">import</span> (
<span class="hljs-meta">... </span>    Compose,
<span class="hljs-meta">... </span>    Lambda,
<span class="hljs-meta">... </span>    RandomCrop,
<span class="hljs-meta">... </span>    RandomHorizontalFlip,
<span class="hljs-meta">... </span>    Resize,
<span class="hljs-meta">... </span>)`}}),Ks=new J({props:{code:"bWVhbiUyMCUzRCUyMGltYWdlX3Byb2Nlc3Nvci5pbWFnZV9tZWFuJTBBc3RkJTIwJTNEJTIwaW1hZ2VfcHJvY2Vzc29yLmltYWdlX3N0ZCUwQWlmJTIwJTIyc2hvcnRlc3RfZWRnZSUyMiUyMGluJTIwaW1hZ2VfcHJvY2Vzc29yLnNpemUlM0ElMEElMjAlMjAlMjAlMjBoZWlnaHQlMjAlM0QlMjB3aWR0aCUyMCUzRCUyMGltYWdlX3Byb2Nlc3Nvci5zaXplJTVCJTIyc2hvcnRlc3RfZWRnZSUyMiU1RCUwQWVsc2UlM0ElMEElMjAlMjAlMjAlMjBoZWlnaHQlMjAlM0QlMjBpbWFnZV9wcm9jZXNzb3Iuc2l6ZSU1QiUyMmhlaWdodCUyMiU1RCUwQSUyMCUyMCUyMCUyMHdpZHRoJTIwJTNEJTIwaW1hZ2VfcHJvY2Vzc29yLnNpemUlNUIlMjJ3aWR0aCUyMiU1RCUwQXJlc2l6ZV90byUyMCUzRCUyMChoZWlnaHQlMkMlMjB3aWR0aCklMEElMEFudW1fZnJhbWVzX3RvX3NhbXBsZSUyMCUzRCUyMG1vZGVsLmNvbmZpZy5udW1fZnJhbWVzJTBBc2FtcGxlX3JhdGUlMjAlM0QlMjA0JTBBZnBzJTIwJTNEJTIwMzAlMEFjbGlwX2R1cmF0aW9uJTIwJTNEJTIwbnVtX2ZyYW1lc190b19zYW1wbGUlMjAqJTIwc2FtcGxlX3JhdGUlMjAlMkYlMjBmcHM=",highlighted:`<span class="hljs-meta">&gt;&gt;&gt; </span>mean = image_processor.image_mean
<span class="hljs-meta">&gt;&gt;&gt; </span>std = image_processor.image_std
<span class="hljs-meta">&gt;&gt;&gt; </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>    height = width = image_processor.size[<span class="hljs-string">&quot;shortest_edge&quot;</span>]
<span class="hljs-meta">&gt;&gt;&gt; </span><span class="hljs-keyword">else</span>:
<span class="hljs-meta">... </span>    height = image_processor.size[<span class="hljs-string">&quot;height&quot;</span>]
<span class="hljs-meta">... </span>    width = image_processor.size[<span class="hljs-string">&quot;width&quot;</span>]
<span class="hljs-meta">&gt;&gt;&gt; </span>resize_to = (height, width)

<span class="hljs-meta">&gt;&gt;&gt; </span>num_frames_to_sample = model.config.num_frames
<span class="hljs-meta">&gt;&gt;&gt; </span>sample_rate = <span class="hljs-number">4</span>
<span class="hljs-meta">&gt;&gt;&gt; </span>fps = <span class="hljs-number">30</span>
<span class="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MjAlMjAlMjAlMjAlMjAlMjAlMjAlMjAlMjBSYW5kb21Dcm9wKHJlc2l6ZV90byklMkMlMEElMjAlMjAlMjAlMjAlMjAlMjAlMjAlMjAlMjAlMjAlMjAlMjAlMjAlMjAlMjAlMjAlMjAlMjAlMjAlMjBSYW5kb21Ib3Jpem9udGFsRmxpcChwJTNEMC41KSUyQyUwQSUyMCUyMCUyMCUyMCUyMCUyMCUyMCUyMCUyMCUyMCUyMCUyMCUyMCUyMCUyMCUyMCU1RCUwQSUyMCUyMCUyMCUyMCUyMCUyMCUyMCUyMCUyMCUyMCUyMCUyMCklMkMlMEElMjAlMjAlMjAlMjAlMjAlMjAlMjAlMjApJTJDJTBBJTIwJTIwJTIwJTIwJTVEJTBBKSUwQSUwQXRyYWluX2RhdGFzZXQlMjAlM0QlMjBweXRvcmNodmlkZW8uZGF0YS5VY2YxMDEoJTBBJTIwJTIwJTIwJTIwZGF0YV9wYXRoJTNEb3MucGF0aC5qb2luKGRhdGFzZXRfcm9vdF9wYXRoJTJDJTIwJTIydHJhaW4lMjIpJTJDJTBBJTIwJTIwJTIwJTIwY2xpcF9zYW1wbGVyJTNEcHl0b3JjaHZpZGVvLmRhdGEubWFrZV9jbGlwX3NhbXBsZXIoJTIycmFuZG9tJTIyJTJDJTIwY2xpcF9kdXJhdGlvbiklMkMlMEElMjAlMjAlMjAlMjBkZWNvZGVfYXVkaW8lM0RGYWxzZSUyQyUwQSUyMCUyMCUyMCUyMHRyYW5zZm9ybSUzRHRyYWluX3RyYW5zZm9ybSUyQyUwQSk=",highlighted:`<span class="hljs-meta">&gt;&gt;&gt; </span>train_transform = Compose(
<span class="hljs-meta">... </span>    [
<span class="hljs-meta">... </span>        ApplyTransformToKey(
<span class="hljs-meta">... </span>            key=<span class="hljs-string">&quot;video&quot;</span>,
<span class="hljs-meta">... </span>            transform=Compose(
<span class="hljs-meta">... </span>                [
<span class="hljs-meta">... </span>                    UniformTemporalSubsample(num_frames_to_sample),
<span class="hljs-meta">... </span>                    Lambda(<span class="hljs-keyword">lambda</span> x: x / <span class="hljs-number">255.0</span>),
<span class="hljs-meta">... </span>                    Normalize(mean, std),
<span class="hljs-meta">... </span>                    RandomShortSideScale(min_size=<span class="hljs-number">256</span>, max_size=<span class="hljs-number">320</span>),
<span class="hljs-meta">... </span>                    RandomCrop(resize_to),
<span class="hljs-meta">... </span>                    RandomHorizontalFlip(p=<span class="hljs-number">0.5</span>),
<span class="hljs-meta">... </span>                ]
<span class="hljs-meta">... </span>            ),
<span class="hljs-meta">... </span>        ),
<span class="hljs-meta">... </span>    ]
<span class="hljs-meta">... </span>)

<span class="hljs-meta">&gt;&gt;&gt; </span>train_dataset = pytorchvideo.data.Ucf101(
<span class="hljs-meta">... </span>    data_path=os.path.join(dataset_root_path, <span class="hljs-string">&quot;train&quot;</span>),
<span class="hljs-meta">... </span>    clip_sampler=pytorchvideo.data.make_clip_sampler(<span class="hljs-string">&quot;random&quot;</span>, clip_duration),
<span class="hljs-meta">... </span>    decode_audio=<span class="hljs-literal">False</span>,
<span class="hljs-meta">... </span>    transform=train_transform,
<span class="hljs-meta">... </span>)`}}),se=new J({props:{code:"dmFsX3RyYW5zZm9ybSUyMCUzRCUyMENvbXBvc2UoJTBBJTIwJTIwJTIwJTIwJTVCJTBBJTIwJTIwJTIwJTIwJTIwJTIwJTIwJTIwQXBwbHlUcmFuc2Zvcm1Ub0tleSglMEElMjAlMjAlMjAlMjAlMjAlMjAlMjAlMjAlMjAlMjAlMjAlMjBrZXklM0QlMjJ2aWRlbyUyMiUyQyUwQSUyMCUyMCUyMCUyMCUyMCUyMCUyMCUyMCUyMCUyMCUyMCUyMHRyYW5zZm9ybSUzRENvbXBvc2UoJTBBJTIwJTIwJTIwJTIwJTIwJTIwJTIwJTIwJTIwJTIwJTIwJTIwJTIwJTIwJTIwJTIwJTVCJTBBJTIwJTIwJTIwJTIwJTIwJTIwJTIwJTIwJTIwJTIwJTIwJTIwJTIwJTIwJTIwJTIwJTIwJTIwJTIw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5zZm9ybSUyQyUwQSklMEElMEF0ZXN0X2RhdGFzZXQlMjAlM0QlMjBweXRvcmNodmlkZW8uZGF0YS5VY2YxMDEoJTBBJTIwJTIwJTIwJTIwZGF0YV9wYXRoJTNEb3MucGF0aC5qb2luKGRhdGFzZXRfcm9vdF9wYXRoJTJDJTIwJTIydGVzdCUyMiklMkMlMEElMjAlMjAlMjAlMjBjbGlwX3NhbXBsZXIlM0RweXRvcmNodmlkZW8uZGF0YS5tYWtlX2NsaXBfc2FtcGxlciglMjJ1bmlmb3JtJTIyJTJDJTIwY2xpcF9kdXJhdGlvbiklMkMlMEElMjAlMjAlMjAlMjBkZWNvZGVfYXVkaW8lM0RGYWxzZSUyQyUwQSUyMCUyMCUyMCUyMHRyYW5zZm9ybSUzRHZhbF90cmFuc2Zvcm0lMkMlMEEp",highlighted:`<span class="hljs-meta">&gt;&gt;&gt; </span>val_transform = Compose(
<span class="hljs-meta">... </span>    [
<span class="hljs-meta">... </span>        ApplyTransformToKey(
<span class="hljs-meta">... </span>            key=<span class="hljs-string">&quot;video&quot;</span>,
<span class="hljs-meta">... </span>            transform=Compose(
<span class="hljs-meta">... </span>                [
<span class="hljs-meta">... </span>                    UniformTemporalSubsample(num_frames_to_sample),
<span class="hljs-meta">... </span>                    Lambda(<span class="hljs-keyword">lambda</span> x: x / <span class="hljs-number">255.0</span>),
<span class="hljs-meta">... </span>                    Normalize(mean, std),
<span class="hljs-meta">... </span>                    Resize(resize_to),
<span class="hljs-meta">... </span>                ]
<span class="hljs-meta">... </span>            ),
<span class="hljs-meta">... </span>        ),
<span class="hljs-meta">... </span>    ]
<span class="hljs-meta">... </span>)

<span class="hljs-meta">&gt;&gt;&gt; </span>val_dataset = pytorchvideo.data.Ucf101(
<span class="hljs-meta">... </span>    data_path=os.path.join(dataset_root_path, <span class="hljs-string">&quot;val&quot;</span>),
<span class="hljs-meta">... </span>    clip_sampler=pytorchvideo.data.make_clip_sampler(<span class="hljs-string">&quot;uniform&quot;</span>, clip_duration),
<span class="hljs-meta">... </span>    decode_audio=<span class="hljs-literal">False</span>,
<span class="hljs-meta">... </span>    transform=val_transform,
<span class="hljs-meta">... </span>)

<span class="hljs-meta">&gt;&gt;&gt; </span>test_dataset = pytorchvideo.data.Ucf101(
<span class="hljs-meta">... </span>    data_path=os.path.join(dataset_root_path, <span class="hljs-string">&quot;test&quot;</span>),
<span class="hljs-meta">... </span>    clip_sampler=pytorchvideo.data.make_clip_sampler(<span class="hljs-string">&quot;uniform&quot;</span>, clip_duration),
<span class="hljs-meta">... </span>    decode_audio=<span class="hljs-literal">False</span>,
<span class="hljs-meta">... </span>    transform=val_transform,
<span class="hljs-meta">... </span>)`}}),ne=new J({props:{code:"cHJpbnQodHJhaW5fZGF0YXNldC5udW1fdmlkZW9zJTJDJTIwdmFsX2RhdGFzZXQubnVtX3ZpZGVvcyUyQyUyMHRlc3RfZGF0YXNldC5udW1fdmlkZW9zKQ==",highlighted:`<span class="hljs-meta">&gt;&gt;&gt; </span><span class="hljs-built_in">print</span>(train_dataset.num_videos, val_dataset.num_videos, test_dataset.num_videos)
<span class="hljs-comment"># (300, 30, 75)</span>`}}),oe=new Ze({}),ie=new J({props:{code:"aW1wb3J0JTIwaW1hZ2VpbyUwQWltcG9ydCUyMG51bXB5JTIwYXMlMjBucCUwQWZyb20lMjBJUHl0aG9uLmRpc3BsYXklMjBpbXBvcnQlMjBJbWFnZSUwQSUwQWRlZiUyMHVubm9ybWFsaXplX2ltZyhpbWcpJTNBJTBBJTIwJTIwJTIwJTIwJTIyJTIyJTIyVW4tbm9ybWFsaXplcyUyMHRoZSUyMGltYWdlJTIwcGl4ZWxzLiUyMiUyMiUyMiUwQSUyMCUyMCUyMCUyMGltZyUyMCUzRCUyMChpbWclMjAqJTIwc3RkKSUyMCUyQiUyMG1lYW4lMEElMjAlMjAlMjAlMjBpbWclMjAlM0QlMjAoaW1nJTIwKiUyMDI1NSkuYXN0eXBlKCUyMnVpbnQ4JTIyKSUwQSUyMCUyMCUy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QSUyMCUyMCUyMCUyMHJldHVybiUyMGZpbGVuYW1lJTBBJTBBZGVmJTIwZGlzcGxheV9naWYodmlkZW9fdGVuc29yJTJDJTIwZ2lmX25hbWUlM0QlMjJzYW1wbGUuZ2lmJTIyKSUzQSUwQSUyMCUyMCUyMCUyMCUyMiUyMiUyMlByZXBhcmVzJTIwYW5kJTIwZGlzcGxheXMlMjBhJTIwR0lGJTIwZnJvbSUyMGElMjB2aWRlbyUyMHRlbnNvci4lMjIlMjIlMjIlMEElMjAlMjAlMjAlMjB2aWRlb190ZW5zb3IlMjAlM0QlMjB2aWRlb190ZW5zb3IucGVybXV0ZSgxJTJDJTIwMCUyQyUyMDIlMkMlMjAzKSUwQSUyMCUyMCUyMCUyMGdpZl9maWxlbmFtZSUyMCUzRCUyMGNyZWF0ZV9naWYodmlkZW9fdGVuc29yJTJDJTIwZ2lmX25hbWUpJTBBJTIwJTIwJTIwJTIwcmV0dXJuJTIwSW1hZ2UoZmlsZW5hbWUlM0RnaWZfZmlsZW5hbWUpJTBBJTBBc2FtcGxlX3ZpZGVvJTIwJTNEJTIwbmV4dChpdGVyKHRyYWluX2RhdGFzZXQpKSUwQXZpZGVvX3RlbnNvciUyMCUzRCUyMHNhbXBsZV92aWRlbyU1QiUyMnZpZGVvJTIyJTVEJTBBZGlzcGxheV9naWYodmlkZW9fdGVuc29yKQ==",highlighted:`<span class="hljs-meta">&gt;&gt;&gt; </span><span class="hljs-keyword">import</span> imageio
<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">from</span> IPython.display <span class="hljs-keyword">import</span> Image

<span class="hljs-meta">&gt;&gt;&gt; </span><span class="hljs-keyword">def</span> <span class="hljs-title function_">unnormalize_img</span>(<span class="hljs-params">img</span>):
<span class="hljs-meta">... </span>    <span class="hljs-string">&quot;&quot;&quot;Un-normalizes the image pixels.&quot;&quot;&quot;</span>
<span class="hljs-meta">... </span>    img = (img * std) + mean
<span class="hljs-meta">... </span>    img = (img * <span class="hljs-number">255</span>).astype(<span class="hljs-string">&quot;uint8&quot;</span>)
<span class="hljs-meta">... </span>    <span class="hljs-keyword">return</span> img.clip(<span class="hljs-number">0</span>, <span class="hljs-number">255</span>)

<span class="hljs-meta">&gt;&gt;&gt; </span><span class="hljs-keyword">def</span> <span class="hljs-title function_">create_gif</span>(<span class="hljs-params">video_tensor, filename=<span class="hljs-string">&quot;sample.gif&quot;</span></span>):
<span class="hljs-meta">... </span>    <span class="hljs-string">&quot;&quot;&quot;Prepares a GIF from a video tensor.
<span class="hljs-meta">... </span>    
<span class="hljs-meta">... </span>    The video tensor is expected to have the following shape:
<span class="hljs-meta">... </span>    (num_frames, num_channels, height, width).
<span class="hljs-meta">... </span>    &quot;&quot;&quot;</span>
<span class="hljs-meta">... </span>    frames = []
<span class="hljs-meta">... </span>    <span class="hljs-keyword">for</span> video_frame <span class="hljs-keyword">in</span> video_tensor:
<span class="hljs-meta">... </span>        frame_unnormalized = unnormalize_img(video_frame.permute(<span class="hljs-number">1</span>, <span class="hljs-number">2</span>, <span class="hljs-number">0</span>).numpy())
<span class="hljs-meta">... </span>        frames.append(frame_unnormalized)
<span class="hljs-meta">... </span>    kargs = {<span class="hljs-string">&quot;duration&quot;</span>: <span class="hljs-number">0.25</span>}
<span class="hljs-meta">... </span>    imageio.mimsave(filename, frames, <span class="hljs-string">&quot;GIF&quot;</span>, **kargs)
<span class="hljs-meta">... </span>    <span class="hljs-keyword">return</span> filename

<span class="hljs-meta">&gt;&gt;&gt; </span><span class="hljs-keyword">def</span> <span class="hljs-title function_">display_gif</span>(<span class="hljs-params">video_tensor, gif_name=<span class="hljs-string">&quot;sample.gif&quot;</span></span>):
<span class="hljs-meta">... </span>    <span class="hljs-string">&quot;&quot;&quot;Prepares and displays a GIF from a video tensor.&quot;&quot;&quot;</span>
<span class="hljs-meta">... </span>    video_tensor = video_tensor.permute(<span class="hljs-number">1</span>, <span class="hljs-number">0</span>, <span class="hljs-number">2</span>, <span class="hljs-number">3</span>)
<span class="hljs-meta">... </span>    gif_filename = create_gif(video_tensor, gif_name)
<span class="hljs-meta">... </span>    <span class="hljs-keyword">return</span> Image(filename=gif_filename)

<span class="hljs-meta">&gt;&gt;&gt; </span>sample_video = <span class="hljs-built_in">next</span>(<span class="hljs-built_in">iter</span>(train_dataset))
<span class="hljs-meta">&gt;&gt;&gt; </span>video_tensor = sample_video[<span class="hljs-string">&quot;video&quot;</span>]
<span class="hljs-meta">&gt;&gt;&gt; </span>display_gif(video_tensor)`}}),re=new Ze({}),me=new J({props:{code:"ZnJvbSUyMHRyYW5zZm9ybWVycyUyMGltcG9ydCUyMFRyYWluaW5nQXJndW1lbnRzJTJDJTIwVHJhaW5lciUwQSUwQW1vZGVsX25hbWUlMjAlM0QlMjBtb2RlbF9ja3B0LnNwbGl0KCUyMiUyRiUyMiklNUItMSU1RCUwQW5ld19tb2RlbF9uYW1lJTIwJTNEJTIwZiUyMiU3Qm1vZGVsX25hbWUlN0QtZmluZXR1bmVkLXVjZjEwMS1zdWJzZXQlMjIlMEFudW1fZXBvY2hzJTIwJTNEJTIwNCUwQSUwQWFyZ3MlMjAlM0QlMjBUcmFpbmluZ0FyZ3VtZW50cyglMEElMjAlMjAlMjAlMjBuZXdfbW9kZWxfbmFtZSUyQyUwQSUyMCUyMCUyMCUyMHJlbW92ZV91bnVzZWRfY29sdW1ucyUzREZhbHNlJTJDJTBBJTIwJTIwJTIwJTIwZXZhbHVhdGlvbl9zdHJhdGVneSUzRCUyMmVwb2NoJTIyJTJDJTBBJTIwJTIwJTIwJTIwc2F2ZV9zdHJhdGVneSUzRCUyMmVwb2NoJTIyJTJDJTBBJTIwJTIwJTIwJTIwbGVhcm5pbmdfcmF0ZSUzRDVlLTUlMkMlMEElMjAlMjAlMjAlMjBwZXJfZGV2aWNlX3RyYWluX2JhdGNoX3NpemUlM0RiYXRjaF9zaXplJTJDJTBBJTIwJTIwJTIwJTIwcGVyX2RldmljZV9ldmFsX2JhdGNoX3NpemUlM0RiYXRjaF9zaXplJTJDJTBBJTIwJTIwJTIwJTIwd2FybXVwX3JhdGlvJTNEMC4xJTJDJTBBJTIwJTIwJTIwJTIwbG9nZ2luZ19zdGVwcyUzRDEwJTJDJTBBJTIwJTIwJTIwJTIwbG9hZF9iZXN0X21vZGVsX2F0X2VuZCUzRFRydWUlMkMlMEElMjAlMjAlMjAlMjBtZXRyaWNfZm9yX2Jlc3RfbW9kZWwlM0QlMjJhY2N1cmFjeSUyMiUyQyUwQSUyMCUyMCUyMCUyMHB1c2hfdG9faHViJTNEVHJ1ZSUyQyUwQSUyMCUyMCUyMCUyMG1heF9zdGVwcyUzRCh0cmFpbl9kYXRhc2V0Lm51bV92aWRlb3MlMjAlMkYlMkYlMjBiYXRjaF9zaXplKSUyMColMjBudW1fZXBvY2hzJTJDJTBBKQ==",highlighted:`<span class="hljs-meta">&gt;&gt;&gt; </span><span class="hljs-keyword">from</span> transformers <span class="hljs-keyword">import</span> TrainingArguments, Trainer

<span class="hljs-meta">&gt;&gt;&gt; </span>model_name = model_ckpt.split(<span class="hljs-string">&quot;/&quot;</span>)[-<span class="hljs-number">1</span>]
<span class="hljs-meta">&gt;&gt;&gt; </span>new_model_name = <span class="hljs-string">f&quot;<span class="hljs-subst">{model_name}</span>-finetuned-ucf101-subset&quot;</span>
<span class="hljs-meta">&gt;&gt;&gt; </span>num_epochs = <span class="hljs-number">4</span>

<span class="hljs-meta">&gt;&gt;&gt; </span>args = TrainingArguments(
<span class="hljs-meta">... </span>    new_model_name,
<span class="hljs-meta">... </span>    remove_unused_columns=<span class="hljs-literal">False</span>,
<span class="hljs-meta">... </span>    evaluation_strategy=<span class="hljs-string">&quot;epoch&quot;</span>,
<span class="hljs-meta">... </span>    save_strategy=<span class="hljs-string">&quot;epoch&quot;</span>,
<span class="hljs-meta">... </span>    learning_rate=<span class="hljs-number">5e-5</span>,
<span class="hljs-meta">... </span>    per_device_train_batch_size=batch_size,
<span class="hljs-meta">... </span>    per_device_eval_batch_size=batch_size,
<span class="hljs-meta">... </span>    warmup_ratio=<span class="hljs-number">0.1</span>,
<span class="hljs-meta">... </span>    logging_steps=<span class="hljs-number">10</span>,
<span class="hljs-meta">... </span>    load_best_model_at_end=<span class="hljs-literal">True</span>,
<span class="hljs-meta">... </span>    metric_for_best_model=<span class="hljs-string">&quot;accuracy&quot;</span>,
<span class="hljs-meta">... </span>    push_to_hub=<span class="hljs-literal">True</span>,
<span class="hljs-meta">... </span>    max_steps=(train_dataset.num_videos // batch_size) * num_epochs,
<span class="hljs-meta">... </span>)`}}),Me=new J({props:{code:"aW1wb3J0JTIwZXZhbHVhdGUlMEElMEFtZXRyaWMlMjAlM0QlMjBldmFsdWF0ZS5sb2FkKCUyMmFjY3VyYWN5JTIyKSUwQSUwQSUwQWRlZiUyMGNvbXB1dGVfbWV0cmljcyhldmFsX3ByZWQpJTNBJTBBJTIwJTIwJTIwJTIwcHJlZGljdGlvbnMlMjAlM0QlMjBucC5hcmdtYXgoZXZhbF9wcmVkLnByZWRpY3Rpb25zJTJDJTIwYXhpcyUzRDEpJTBBJTIwJTIwJTIwJTIwcmV0dXJuJTIwbWV0cmljLmNvbXB1dGUocHJlZGljdGlvbnMlM0RwcmVkaWN0aW9ucyUyQyUyMHJlZmVyZW5jZXMlM0RldmFsX3ByZWQubGFiZWxfaWRzKQ==",highlighted:`<span class="hljs-keyword">import</span> evaluate

metric = evaluate.load(<span class="hljs-string">&quot;accuracy&quot;</span>)


<span class="hljs-keyword">def</span> <span class="hljs-title function_">compute_metrics</span>(<span class="hljs-params">eval_pred</span>):
    predictions = np.argmax(eval_pred.predictions, axis=<span class="hljs-number">1</span>)
    <span class="hljs-keyword">return</span> metric.compute(predictions=predictions, references=eval_pred.label_ids)`}}),we=new J({props:{code:"ZGVmJTIwY29sbGF0ZV9mbihleGFtcGxlcyklM0ElMEElMjAlMjAlMjAlMjAlMjMlMjBwZXJtdXRlJTIwdG8lMjAobnVtX2ZyYW1lcyUyQyUyMG51bV9jaGFubmVscyUyQyUyMGhlaWdodCUyQyUyMHdpZHRoKSUwQSUyMCUyMCUyMCUyMHBpeGVsX3ZhbHVlcyUyMCUzRCUyMHRvcmNoLnN0YWNrKCUwQSUyMCUyMCUyMCUyMCUyMCUyMCUyMCUyMCU1QmV4YW1wbGUlNUIlMjJ2aWRlbyUyMiU1RC5wZXJtdXRlKDElMkMlMjAwJTJDJTIwMiUyQyUyMDMpJTIwZm9yJTIwZXhhbXBsZSUyMGluJTIwZXhhbXBsZXMlNUQlMEElMjAlMjAlMjAlMjApJTBBJTIwJTIwJTIwJTIwbGFiZWxzJTIwJTNEJTIwdG9yY2gudGVuc29yKCU1QmV4YW1wbGUlNUIlMjJsYWJlbCUyMiU1RCUyMGZvciUyMGV4YW1wbGUlMjBpbiUyMGV4YW1wbGVzJTVEKSUwQSUyMCUyMCUyMCUyMHJldHVybiUyMCU3QiUyMnBpeGVsX3ZhbHVlcyUyMiUzQSUyMHBpeGVsX3ZhbHVlcyUyQyUyMCUyMmxhYmVscyUyMiUzQSUyMGxhYmVscyU3RA==",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">examples</span>):
<span class="hljs-meta">... </span>    <span class="hljs-comment"># permute to (num_frames, num_channels, height, width)</span>
<span class="hljs-meta">... </span>    pixel_values = torch.stack(
<span class="hljs-meta">... </span>        [example[<span class="hljs-string">&quot;video&quot;</span>].permute(<span class="hljs-number">1</span>, <span class="hljs-number">0</span>, <span class="hljs-number">2</span>, <span class="hljs-number">3</span>) <span class="hljs-keyword">for</span> example <span class="hljs-keyword">in</span> examples]
<span class="hljs-meta">... </span>    )
<span class="hljs-meta">... </span>    labels = torch.tensor([example[<span class="hljs-string">&quot;label&quot;</span>] <span class="hljs-keyword">for</span> example <span class="hljs-keyword">in</span> examples])
<span class="hljs-meta">... </span>    <span class="hljs-keyword">return</span> {<span class="hljs-string">&quot;pixel_values&quot;</span>: pixel_values, <span class="hljs-string">&quot;labels&quot;</span>: labels}`}}),fe=new J({props:{code:"dHJhaW5lciUyMCUzRCUyMFRyYWluZXIoJTBBJTIwJTIwJTIwJTIwbW9kZWwlMkMlMEElMjAlMjAlMjAlMjBhcmdzJTJDJTBBJTIwJTIwJTIwJTIwdHJhaW5fZGF0YXNldCUzRHRyYWluX2RhdGFzZXQlMkMlMEElMjAlMjAlMjAlMjBldmFsX2RhdGFzZXQlM0R2YWxfZGF0YXNldCUyQyUwQSUyMCUyMCUyMCUyMHRva2VuaXplciUzRGltYWdlX3Byb2Nlc3NvciUyQyUwQSUyMCUyMCUyMCUyMGNvbXB1dGVfbWV0cmljcyUzRGNvbXB1dGVfbWV0cmljcyUyQyUwQSUyMCUyMCUyMCUyMGRhdGFfY29sbGF0b3IlM0Rjb2xsYXRlX2ZuJTJDJTBBKQ==",highlighted:`<span class="hljs-meta">&gt;&gt;&gt; </span>trainer = Trainer(
<span class="hljs-meta">... </span>    model,
<span class="hljs-meta">... </span>    args,
<span class="hljs-meta">... </span>    train_dataset=train_dataset,
<span class="hljs-meta">... </span>    eval_dataset=val_dataset,
<span class="hljs-meta">... </span>    tokenizer=image_processor,
<span class="hljs-meta">... </span>    compute_metrics=compute_metrics,
<span class="hljs-meta">... </span>    data_collator=collate_fn,
<span class="hljs-meta">... </span>)`}}),ue=new J({props:{code:"dHJhaW5fcmVzdWx0cyUyMCUzRCUyMHRyYWluZXIudHJhaW4oKQ==",highlighted:'<span class="hljs-meta">&gt;&gt;&gt; </span>train_results = trainer.train()'}}),Je=new J({props:{code:"dHJhaW5lci5wdXNoX3RvX2h1Yigp",highlighted:'<span class="hljs-meta">&gt;&gt;&gt; </span>trainer.push_to_hub()'}}),je=new Ze({}),Ue=new J({props:{code:"c2FtcGxlX3Rlc3RfdmlkZW8lMjAlM0QlMjBuZXh0KGl0ZXIodGVzdF9kYXRhc2V0KSk=",highlighted:'<span class="hljs-meta">&gt;&gt;&gt; </span>sample_test_video = <span class="hljs-built_in">next</span>(<span class="hljs-built_in">iter</span>(test_dataset))'}}),Ie=new J({props:{code:"ZnJvbSUyMHRyYW5zZm9ybWVycyUyMGltcG9ydCUyMHBpcGVsaW5lJTBBJTBBdmlkZW9fY2xzJTIwJTNEJTIwcGlwZWxpbmUobW9kZWwlM0QlMjJteV9hd2Vzb21lX3ZpZGVvX2Nsc19tb2RlbCUyMiklMEF2aWRlb19jbHMoJTIyaHR0cHMlM0ElMkYlMkZodWdnaW5nZmFjZS5jbyUyRmRhdGFzZXRzJTJGc2F5YWtwYXVsJTJGdWNmMTAxLXN1YnNldCUyRnJlc29sdmUlMkZtYWluJTJGdl9CYXNrZXRiYWxsRHVua19nMTRfYzA2LmF2aSUyMik=",highlighted:`<span class="hljs-meta">&gt;&gt;&gt; </span><span class="hljs-keyword">from</span> transformers <span class="hljs-keyword">import</span> pipeline

<span class="hljs-meta">&gt;&gt;&gt; </span>video_cls = pipeline(model=<span class="hljs-string">&quot;my_awesome_video_cls_model&quot;</span>)
<span class="hljs-meta">&gt;&gt;&gt; </span>video_cls(<span class="hljs-string">&quot;https://huggingface.co/datasets/sayakpaul/ucf101-subset/resolve/main/v_BasketballDunk_g14_c06.avi&quot;</span>)
[{<span class="hljs-string">&#x27;score&#x27;</span>: <span class="hljs-number">0.9272987842559814</span>, <span class="hljs-string">&#x27;label&#x27;</span>: <span class="hljs-string">&#x27;BasketballDunk&#x27;</span>},
 {<span class="hljs-string">&#x27;score&#x27;</span>: <span class="hljs-number">0.017777055501937866</span>, <span class="hljs-string">&#x27;label&#x27;</span>: <span class="hljs-string">&#x27;BabyCrawling&#x27;</span>},
 {<span class="hljs-string">&#x27;score&#x27;</span>: <span class="hljs-number">0.01663011871278286</span>, <span class="hljs-string">&#x27;label&#x27;</span>: <span class="hljs-string">&#x27;BalanceBeam&#x27;</span>},
 {<span class="hljs-string">&#x27;score&#x27;</span>: <span class="hljs-number">0.009560945443809032</span>, <span class="hljs-string">&#x27;label&#x27;</span>: <span class="hljs-string">&#x27;BandMarching&#x27;</span>},
 {<span class="hljs-string">&#x27;score&#x27;</span>: <span class="hljs-number">0.0068979403004050255</span>, <span class="hljs-string">&#x27;label&#x27;</span>: <span class="hljs-string">&#x27;BaseballPitch&#x27;</span>}]`}}),ve=new J({props:{code:"ZGVmJTIwcnVuX2luZmVyZW5jZShtb2RlbCUyQyUyMHZpZGVvKSUzQSUwQSUyMCUyMCUyMCUyMCUyMyUyMChudW1fZnJhbWVzJTJDJTIwbnVtX2NoYW5uZWxzJTJDJTIwaGVpZ2h0JTJDJTIwd2lkdGgpJTBBJTIwJTIwJTIwJTIwcGVydW11dGVkX3NhbXBsZV90ZXN0X3ZpZGVvJTIwJTNEJTIwdmlkZW8ucGVybXV0ZSgxJTJDJTIwMCUyQyUyMDIlMkMlMjAzKSUwQSUyMCUyMCUyMCUyMGlucHV0cyUyMCUzRCUyMCU3QiUwQSUyMCUyMCUyMCUyMCUyMCUyMCUyMCUyMCUyMnBpeGVsX3ZhbHVlcyUyMiUzQSUyMHBlcnVtdXRlZF9zYW1wbGVfdGVzdF92aWRlby51bnNxdWVlemUoMCklMkMlMEElMjAlMjAlMjAlMjAlMjAlMjAlMjAlMjAlMjJsYWJlbHMlMjIlM0ElMjB0b3JjaC50ZW5zb3IoJTBBJTIwJTIwJTIwJTIwJTIwJTIwJTIwJTIwJTIwJTIwJTIwJTIwJTVCc2FtcGxlX3Rlc3RfdmlkZW8lNUIlMjJsYWJlbCUyMiU1RCU1RCUwQSUyMCUyMCUyMCUyMCUyMCUyMCUyMCUyMCklMkMlMjAlMjAlMjMlMjB0aGlzJTIwY2FuJTIwYmUlMjBza2lwcGVkJTIwaWYlMjB5b3UlMjBkb24ndCUyMGhhdmUlMjBsYWJlbHMlMjBhdmFpbGFibGUuJTBBJTIwJTIwJTIwJTIwJTdEJTBBJTBBJTIwJTIwJTIwJTIwZGV2aWNlJTIwJTNEJTIwdG9yY2guZGV2aWNlKCUyMmN1ZGElMjIlMjBpZiUyMHRvcmNoLmN1ZGEuaXNfYXZhaWxhYmxlKCklMjBlbHNlJTIwJTIyY3B1JTIyKSUwQSUyMCUyMCUyMCUyMGlucHV0cyUyMCUzRCUyMCU3QmslM0ElMjB2LnRvKGRldmljZSklMjBmb3IlMjBrJTJDJTIwdiUyMGluJTIwaW5wdXRzLml0ZW1zKCklN0QlMEElMjAlMjAlMjAlMjBtb2RlbCUyMCUzRCUyMG1vZGVsLnRvKGRldmljZSklMEElMEElMjAlMjAlMjAlMjAlMjMlMjBmb3J3YXJkJTIwcGFzcyUwQSUyMCUyMCUyMCUyMHdpdGglMjB0b3JjaC5ub19ncmFkKCklM0ElMEElMjAlMjAlMjAlMjAlMjAlMjAlMjAlMjBvdXRwdXRzJTIwJTNEJTIwbW9kZWwoKippbnB1dHMpJTBBJTIwJTIwJTIwJTIwJTIwJTIwJTIwJTIwbG9naXRzJTIwJTNEJTIwb3V0cHV0cy5sb2dpdHMlMEElMEElMjAlMjAlMjAlMjByZXR1cm4lMjBsb2dpdHM=",highlighted:`<span class="hljs-meta">&gt;&gt;&gt; </span><span class="hljs-keyword">def</span> <span class="hljs-title function_">run_inference</span>(<span class="hljs-params">model, video</span>):
<span class="hljs-meta">... </span>    <span class="hljs-comment"># (num_frames, num_channels, height, width)</span>
<span class="hljs-meta">... </span>    perumuted_sample_test_video = video.permute(<span class="hljs-number">1</span>, <span class="hljs-number">0</span>, <span class="hljs-number">2</span>, <span class="hljs-number">3</span>)
<span class="hljs-meta">... </span>    inputs = {
<span class="hljs-meta">... </span>        <span class="hljs-string">&quot;pixel_values&quot;</span>: perumuted_sample_test_video.unsqueeze(<span class="hljs-number">0</span>),
<span class="hljs-meta">... </span>        <span class="hljs-string">&quot;labels&quot;</span>: torch.tensor(
<span class="hljs-meta">... </span>            [sample_test_video[<span class="hljs-string">&quot;label&quot;</span>]]
<span class="hljs-meta">... </span>        ),  <span class="hljs-comment"># this can be skipped if you don&#x27;t have labels available.</span>
<span class="hljs-meta">... </span>    }

<span class="hljs-meta">... </span>    device = torch.device(<span class="hljs-string">&quot;cuda&quot;</span> <span class="hljs-keyword">if</span> torch.cuda.is_available() <span class="hljs-keyword">else</span> <span class="hljs-string">&quot;cpu&quot;</span>)
<span class="hljs-meta">... </span>    inputs = {k: v.to(device) <span class="hljs-keyword">for</span> k, v <span class="hljs-keyword">in</span> inputs.items()}
<span class="hljs-meta">... </span>    model = model.to(device)

<span class="hljs-meta">... </span>    <span class="hljs-comment"># forward pass</span>
<span class="hljs-meta">... </span>    <span class="hljs-keyword">with</span> torch.no_grad():
<span class="hljs-meta">... </span>        outputs = model(**inputs)
<span class="hljs-meta">... </span>        logits = outputs.logits

<span class="hljs-meta">... </span>    <span class="hljs-keyword">return</span> logits`}}),ge=new J({props:{code:"bG9naXRzJTIwJTNEJTIwcnVuX2luZmVyZW5jZSh0cmFpbmVkX21vZGVsJTJDJTIwc2FtcGxlX3Rlc3RfdmlkZW8lNUIlMjJ2aWRlbyUyMiU1RCk=",highlighted:'&gt;&gt;&gt; logits = run<span class="hljs-constructor">_inference(<span class="hljs-params">trained_model</span>, <span class="hljs-params">sample_test_video</span>[<span class="hljs-string">&quot;video&quot;</span>])</span>'}}),Ce=new J({props:{code:"cHJlZGljdGVkX2NsYXNzX2lkeCUyMCUzRCUyMGxvZ2l0cy5hcmdtYXgoLTEpLml0ZW0oKSUwQXByaW50KCUyMlByZWRpY3RlZCUyMGNsYXNzJTNBJTIyJTJDJTIwbW9kZWwuY29uZmlnLmlkMmxhYmVsJTVCcHJlZGljdGVkX2NsYXNzX2lkeCU1RCk=",highlighted:`<span class="hljs-meta">&gt;&gt;&gt; </span>predicted_class_idx = logits.argmax(-<span class="hljs-number">1</span>).item()
<span class="hljs-meta">&gt;&gt;&gt; </span><span class="hljs-built_in">print</span>(<span class="hljs-string">&quot;Predicted class:&quot;</span>, model.config.id2label[predicted_class_idx])
<span class="hljs-comment"># Predicted class: BasketballDunk</span>`}}),{c(){v=o("meta"),I=c(),T=o("h1"),A=o("a"),S=o("span"),M(g.$$.fragment),_s=c(),F=o("span"),B=t("Video classification"),P=c(),M(b.$$.fragment),C=c(),x=o("p"),Ae=t("Video classification is the task of assigning a label or class to an entire video. Videos are expected to have only one class for each video. Video classification models take a video as input and return a prediction about which class the video belongs to. These models can be used to categorize what a video is all about. A real-world application of video classification is action / activity recognition, which is useful for fitness applications. It is also helpful for vision-impaired individuals, especially when they are commuting."),Zs=c(),Ee=o("p"),en=t("This guide will show you how to:"),nl=c(),K=o("ol"),N=o("li"),an=t("Fine-tune "),As=o("a"),ln=t("VideoMAE"),tn=t(" on a subset of the "),Es=o("a"),nn=t("UCF101"),on=t(" dataset."),pn=c(),sa=o("li"),rn=t("Use your fine-tuned model for inference."),ol=c(),M(O.$$.fragment),il=c(),ke=o("p"),cn=t("Before you begin, make sure you have all the necessary libraries installed:"),pl=c(),M(ks.$$.fragment),rl=c(),V=o("p"),hn=t("You will use "),Gs=o("a"),mn=t("PyTorchVideo"),Mn=t(" (dubbed "),ea=o("code"),dn=t("pytorchvideo"),yn=t(") to process and prepare the videos."),cl=c(),Ge=o("p"),wn=t("We encourage you to log in to your Hugging Face account so you can upload and share your model with the community. When prompted, enter your token to log in:"),hl=c(),M(Ws.$$.fragment),ml=c(),z=o("h2"),ss=o("a"),aa=o("span"),M(Bs.$$.fragment),fn=c(),la=o("span"),un=t("Load UCF101 dataset"),Ml=c(),es=o("p"),Jn=t("Start by loading a subset of the "),Vs=o("a"),jn=t("UCF-101 dataset"),Un=t(". This will give you a chance to experiment and make sure everything works before spending more time training on the full dataset."),dl=c(),M(Rs.$$.fragment),yl=c(),We=o("p"),Tn=t("After the subset has been downloaded, you need to extract the compressed archive:"),wl=c(),M(Xs.$$.fragment),fl=c(),Be=o("p"),bn=t("At a high level, the dataset is organized like so:"),ul=c(),M($s.$$.fragment),Jl=c(),as=o("p"),In=t("The ("),ta=o("code"),vn=t("sorted"),gn=t(") video paths appear like so:"),jl=c(),M(Ss.$$.fragment),Ul=c(),E=o("p"),Cn=t("You will notice that there are video clips belonging to the same group / scene where group is denoted by "),na=o("code"),_n=t("g"),Zn=t(" in the video file paths. "),oa=o("code"),An=t("v_ApplyEyeMakeup_g07_c04.avi"),En=t(" and "),ia=o("code"),kn=t("v_ApplyEyeMakeup_g07_c06.avi"),Gn=t(", for example."),Tl=c(),ls=o("p"),Wn=t("For the validation and evaluation splits, you wouldn\u2019t want to have video clips from the same group / scene to prevent "),Fs=o("a"),Bn=t("data leakage"),Vn=t(". The subset that you are using in this tutorial takes this information into account."),bl=c(),Ve=o("p"),Rn=t("Next up, you will derive the set of labels present in the dataset. Also, create two dictionaries that\u2019ll be helpful when initializing the model:"),Il=c(),ts=o("ul"),Re=o("li"),pa=o("code"),Xn=t("label2id"),$n=t(": maps the class names to integers."),Sn=c(),Xe=o("li"),ra=o("code"),Fn=t("id2label"),xn=t(": maps the integers to class names."),vl=c(),M(xs.$$.fragment),gl=c(),$e=o("p"),Nn=t("There are 10 unique classes. For each class, there are 30 videos in the training set."),Cl=c(),Y=o("h2"),ns=o("a"),ca=o("span"),M(Ns.$$.fragment),zn=c(),ha=o("span"),Yn=t("Load a model to fine-tune"),_l=c(),Se=o("p"),Qn=t("Instantiate a video classification model from a pretrained checkpoint and its associated image processor. The model\u2019s encoder comes with pre-trained parameters, and the classification head is randomly initialized. The image processor will come in handy when writing the preprocessing pipeline for our dataset."),Zl=c(),M(zs.$$.fragment),Al=c(),Fe=o("p"),Hn=t("While the model is loading, you might notice the following warning:"),El=c(),M(Ys.$$.fragment),kl=c(),R=o("p"),Dn=t("The warning is telling us we are throwing away some weights (e.g. the weights and bias of the "),ma=o("code"),qn=t("classifier"),Ln=t(" layer) and randomly initializing some others (the weights and bias of a new "),Ma=o("code"),Pn=t("classifier"),Kn=t(" layer). This is expected in this case, because we are adding a new head for which we don\u2019t have pretrained weights, so the library warns us we should fine-tune this model before using it for inference, which is exactly what we are going to do."),Gl=c(),Z=o("p"),da=o("strong"),On=t("Note"),so=t(" that "),Qs=o("a"),eo=t("this checkpoint"),ao=t(" leads to better performance on this task as the checkpoint was obtained fine-tuning on a similar downstream task having considerable domain overlap. You can check out "),Hs=o("a"),lo=t("this checkpoint"),to=t(" which was obtained by fine-tuning "),ya=o("code"),no=t("MCG-NJU/videomae-base-finetuned-kinetics"),oo=t("."),Wl=c(),Q=o("h2"),os=o("a"),wa=o("span"),M(Ds.$$.fragment),io=c(),fa=o("span"),po=t("Prepare the datasets for training"),Bl=c(),is=o("p"),ro=t("For preprocessing the videos, you will leverage the "),qs=o("a"),co=t("PyTorchVideo library"),ho=t(". Start by importing the dependencies we need."),Vl=c(),M(Ls.$$.fragment),Rl=c(),ps=o("p"),mo=t("For the training dataset transformations, use a combination of uniform temporal subsampling, pixel normalization, random cropping, and random horizontal flipping. For the validation and evaluation dataset transformations, keep the same transformation chain except for random cropping and horizontal flipping. To learn more about the details of these transformations check out the "),Ps=o("a"),Mo=t("official documentation of PyTorchVideo"),yo=t("."),Xl=c(),rs=o("p"),wo=t("Use the "),ua=o("code"),fo=t("image_processor"),uo=t(" associated with the pre-trained model to obtain the following information:"),$l=c(),cs=o("ul"),Ja=o("li"),Jo=t("Image mean and standard deviation with which the video frame pixels will be normalized."),jo=c(),ja=o("li"),Uo=t("Spatial resolution to which the video frames will be resized."),Sl=c(),xe=o("p"),To=t("Start by defining some constants."),Fl=c(),M(Ks.$$.fragment),xl=c(),Ne=o("p"),bo=t("Now, define the dataset-specific transformations and the datasets respectively. Starting with the training set:"),Nl=c(),M(Os.$$.fragment),zl=c(),ze=o("p"),Io=t("The same sequence of workflow can be applied to the validation and evaluation sets:"),Yl=c(),M(se.$$.fragment),Ql=c(),j=o("p"),Ua=o("strong"),vo=t("Note"),go=t(": The above dataset pipelines are taken from the "),ee=o("a"),Co=t("official PyTorchVideo example"),_o=t(". We\u2019re using the "),ae=o("a"),Ta=o("code"),Zo=t("pytorchvideo.data.Ucf101()"),Ao=t(" function because it\u2019s tailored for the UCF-101 dataset. Under the hood, it returns a "),le=o("a"),ba=o("code"),Eo=t("pytorchvideo.data.labeled_video_dataset.LabeledVideoDataset"),ko=t(" object. "),Ia=o("code"),Go=t("LabeledVideoDataset"),Wo=t(" class is the base class for all things video in the PyTorchVideo dataset. So, if you want to use a custom dataset not supported off-the-shelf by PyTorchVideo, you can extend the "),va=o("code"),Bo=t("LabeledVideoDataset"),Vo=t(" class accordingly. Refer to the "),ga=o("code"),Ro=t("data"),Xo=t(" API "),te=o("a"),$o=t("documentation to"),So=t(" learn more. Also, if your dataset follows a similar structure (as shown above), then using the "),Ca=o("code"),Fo=t("pytorchvideo.data.Ucf101()"),xo=t(" should work just fine."),Hl=c(),hs=o("p"),No=t("You can access the "),_a=o("code"),zo=t("num_videos"),Yo=t(" argument to know the number of videos in the dataset."),Dl=c(),M(ne.$$.fragment),ql=c(),H=o("h2"),ms=o("a"),Za=o("span"),M(oe.$$.fragment),Qo=c(),Aa=o("span"),Ho=t("Visualize the preprocessed video for better debugging"),Ll=c(),M(ie.$$.fragment),Pl=c(),pe=o("div"),Ye=o("img"),Kl=c(),D=o("h2"),Ms=o("a"),Ea=o("span"),M(re.$$.fragment),Do=c(),ka=o("span"),qo=t("Train the model"),Ol=c(),k=o("p"),Lo=t("Leverage "),ce=o("a"),Ga=o("code"),Po=t("Trainer"),Ko=t(" from  \u{1F917} Transformers for training the model. To instantiate a "),Wa=o("code"),Oo=t("Trainer"),si=t(", you need to define the training configuration and an evaluation metric. The most important is the "),he=o("a"),Ba=o("code"),ei=t("TrainingArguments"),ai=t(", which is a class that contains all the attributes to configure the training. It requires an output folder name, which will be used to save the checkpoints of the model. It also helps sync all the information in the model repository on \u{1F917} Hub."),st=c(),G=o("p"),li=t("Most of the training arguments are self-explanatory, but one that is quite important here is "),Va=o("code"),ti=t("remove_unused_columns=False"),ni=t(". This one will drop any features not used by the model\u2019s call function. By default it\u2019s "),Ra=o("code"),oi=t("True"),ii=t(" because usually it\u2019s ideal to drop unused feature columns, making it easier to unpack inputs into the model\u2019s call function. But, in this case, you need the unused features (\u2018video\u2019 in particular) in order to create "),Xa=o("code"),pi=t("pixel_values"),ri=t(" (which is a mandatory key our model expects in its inputs)."),et=c(),M(me.$$.fragment),at=c(),_=o("p"),ci=t("The dataset returned by "),$a=o("code"),hi=t("pytorchvideo.data.Ucf101()"),mi=t(" doesn\u2019t implement the "),Sa=o("code"),Mi=t("__len__"),di=t(" method. As such, we must define "),Fa=o("code"),yi=t("max_steps"),wi=t(" when instantiating "),xa=o("code"),fi=t("TrainingArguments"),ui=t("."),lt=c(),ds=o("p"),Ji=t("Next, you need to define a function to compute the metrics from the predictions, which will use the "),Na=o("code"),ji=t("metric"),Ui=t(" you\u2019ll load now. The only preprocessing you have to do is to take the argmax of our predicted logits:"),tt=c(),M(Me.$$.fragment),nt=c(),de=o("p"),za=o("strong"),Ti=t("A note on evaluation"),bi=t(":"),ot=c(),ys=o("p"),Ii=t("In the "),ye=o("a"),vi=t("VideoMAE paper"),gi=t(", the authors use the following evaluation strategy. They evaluate the model on several clips from test videos and apply different crops to those clips and report the aggregate score. However, in the interest of simplicity and brevity, we don\u2019t consider that in this tutorial."),it=c(),W=o("p"),Ci=t("Also, define a "),Ya=o("code"),_i=t("collate_fn"),Zi=t(", which will be used to batch examples together. Each batch consists of 2 keys, namely "),Qa=o("code"),Ai=t("pixel_values"),Ei=t(" and "),Ha=o("code"),ki=t("labels"),Gi=t("."),pt=c(),M(we.$$.fragment),rt=c(),ws=o("p"),Wi=t("Then you just pass all of this along with the datasets to "),Da=o("code"),Bi=t("Trainer"),Vi=t(":"),ct=c(),M(fe.$$.fragment),ht=c(),fs=o("p"),Ri=t("You might wonder why you passed along the "),qa=o("code"),Xi=t("image_processor"),$i=t(" as a tokenizer when you preprocessed the data already. This is only to make sure the image processor configuration file (stored as JSON) will also be uploaded to the repo on the Hub."),mt=c(),us=o("p"),Si=t("Now fine-tune our model by calling the "),La=o("code"),Fi=t("train"),xi=t(" method:"),Mt=c(),M(ue.$$.fragment),dt=c(),Js=o("p"),Ni=t("Once training is completed, share your model to the Hub with the "),Qe=o("a"),zi=t("push_to_hub()"),Yi=t(" method so everyone can use your model:"),yt=c(),M(Je.$$.fragment),wt=c(),q=o("h2"),js=o("a"),Pa=o("span"),M(je.$$.fragment),Qi=c(),Ka=o("span"),Hi=t("Inference"),ft=c(),He=o("p"),Di=t("Great, now that you have fine-tuned a model, you can use it for inference!"),ut=c(),De=o("p"),qi=t("Load a video for inference:"),Jt=c(),M(Ue.$$.fragment),jt=c(),Te=o("div"),qe=o("img"),Ut=c(),X=o("p"),Li=t("The simplest way to try out your fine-tuned model for inference is to use it in a "),be=o("a"),Oa=o("code"),Pi=t("pipeline"),Ki=t(". Instantiate a "),sl=o("code"),Oi=t("pipeline"),sp=t(" for video classification with your model, and pass your video to it:"),Tt=c(),M(Ie.$$.fragment),bt=c(),Us=o("p"),ep=t("You can also manually replicate the results of the "),el=o("code"),ap=t("pipeline"),lp=t(" if you\u2019d like."),It=c(),M(ve.$$.fragment),vt=c(),Ts=o("p"),tp=t("Now, pass your input to the model and return the "),al=o("code"),np=t("logits"),op=t(":"),gt=c(),M(ge.$$.fragment),Ct=c(),bs=o("p"),ip=t("Decoding the "),ll=o("code"),pp=t("logits"),rp=t(", we get:"),_t=c(),M(Ce.$$.fragment),this.h()},l(s){const l=Mc('[data-svelte="svelte-1phssyn"]',document.head);v=i(l,"META",{name:!0,content:!0}),l.forEach(e),I=h(s),T=i(s,"H1",{class:!0});var _e=p(T);A=i(_e,"A",{id:!0,class:!0,href:!0});var yp=p(A);S=i(yp,"SPAN",{});var wp=p(S);d(g.$$.fragment,wp),wp.forEach(e),yp.forEach(e),_s=h(_e),F=i(_e,"SPAN",{});var fp=p(F);B=n(fp,"Video classification"),fp.forEach(e),_e.forEach(e),P=h(s),d(b.$$.fragment,s),C=h(s),x=i(s,"P",{});var up=p(x);Ae=n(up,"Video classification is the task of assigning a label or class to an entire video. Videos are expected to have only one class for each video. Video classification models take a video as input and return a prediction about which class the video belongs to. These models can be used to categorize what a video is all about. A real-world application of video classification is action / activity recognition, which is useful for fitness applications. It is also helpful for vision-impaired individuals, especially when they are commuting."),up.forEach(e),Zs=h(s),Ee=i(s,"P",{});var Jp=p(Ee);en=n(Jp,"This guide will show you how to:"),Jp.forEach(e),nl=h(s),K=i(s,"OL",{});var At=p(K);N=i(At,"LI",{});var Le=p(N);an=n(Le,"Fine-tune "),As=i(Le,"A",{href:!0,rel:!0});var jp=p(As);ln=n(jp,"VideoMAE"),jp.forEach(e),tn=n(Le," on a subset of the "),Es=i(Le,"A",{href:!0,rel:!0});var Up=p(Es);nn=n(Up,"UCF101"),Up.forEach(e),on=n(Le," dataset."),Le.forEach(e),pn=h(At),sa=i(At,"LI",{});var Tp=p(sa);rn=n(Tp,"Use your fine-tuned model for inference."),Tp.forEach(e),At.forEach(e),ol=h(s),d(O.$$.fragment,s),il=h(s),ke=i(s,"P",{});var bp=p(ke);cn=n(bp,"Before you begin, make sure you have all the necessary libraries installed:"),bp.forEach(e),pl=h(s),d(ks.$$.fragment,s),rl=h(s),V=i(s,"P",{});var Pe=p(V);hn=n(Pe,"You will use "),Gs=i(Pe,"A",{href:!0,rel:!0});var Ip=p(Gs);mn=n(Ip,"PyTorchVideo"),Ip.forEach(e),Mn=n(Pe," (dubbed "),ea=i(Pe,"CODE",{});var vp=p(ea);dn=n(vp,"pytorchvideo"),vp.forEach(e),yn=n(Pe,") to process and prepare the videos."),Pe.forEach(e),cl=h(s),Ge=i(s,"P",{});var gp=p(Ge);wn=n(gp,"We encourage you to log in to your Hugging Face account so you can upload and share your model with the community. When prompted, enter your token to log in:"),gp.forEach(e),hl=h(s),d(Ws.$$.fragment,s),ml=h(s),z=i(s,"H2",{class:!0});var Et=p(z);ss=i(Et,"A",{id:!0,class:!0,href:!0});var Cp=p(ss);aa=i(Cp,"SPAN",{});var _p=p(aa);d(Bs.$$.fragment,_p),_p.forEach(e),Cp.forEach(e),fn=h(Et),la=i(Et,"SPAN",{});var Zp=p(la);un=n(Zp,"Load UCF101 dataset"),Zp.forEach(e),Et.forEach(e),Ml=h(s),es=i(s,"P",{});var kt=p(es);Jn=n(kt,"Start by loading a subset of the "),Vs=i(kt,"A",{href:!0,rel:!0});var Ap=p(Vs);jn=n(Ap,"UCF-101 dataset"),Ap.forEach(e),Un=n(kt,". This will give you a chance to experiment and make sure everything works before spending more time training on the full dataset."),kt.forEach(e),dl=h(s),d(Rs.$$.fragment,s),yl=h(s),We=i(s,"P",{});var Ep=p(We);Tn=n(Ep,"After the subset has been downloaded, you need to extract the compressed archive:"),Ep.forEach(e),wl=h(s),d(Xs.$$.fragment,s),fl=h(s),Be=i(s,"P",{});var kp=p(Be);bn=n(kp,"At a high level, the dataset is organized like so:"),kp.forEach(e),ul=h(s),d($s.$$.fragment,s),Jl=h(s),as=i(s,"P",{});var Gt=p(as);In=n(Gt,"The ("),ta=i(Gt,"CODE",{});var Gp=p(ta);vn=n(Gp,"sorted"),Gp.forEach(e),gn=n(Gt,") video paths appear like so:"),Gt.forEach(e),jl=h(s),d(Ss.$$.fragment,s),Ul=h(s),E=i(s,"P",{});var Is=p(E);Cn=n(Is,"You will notice that there are video clips belonging to the same group / scene where group is denoted by "),na=i(Is,"CODE",{});var Wp=p(na);_n=n(Wp,"g"),Wp.forEach(e),Zn=n(Is," in the video file paths. "),oa=i(Is,"CODE",{});var Bp=p(oa);An=n(Bp,"v_ApplyEyeMakeup_g07_c04.avi"),Bp.forEach(e),En=n(Is," and "),ia=i(Is,"CODE",{});var Vp=p(ia);kn=n(Vp,"v_ApplyEyeMakeup_g07_c06.avi"),Vp.forEach(e),Gn=n(Is,", for example."),Is.forEach(e),Tl=h(s),ls=i(s,"P",{});var Wt=p(ls);Wn=n(Wt,"For the validation and evaluation splits, you wouldn\u2019t want to have video clips from the same group / scene to prevent "),Fs=i(Wt,"A",{href:!0,rel:!0});var Rp=p(Fs);Bn=n(Rp,"data leakage"),Rp.forEach(e),Vn=n(Wt,". The subset that you are using in this tutorial takes this information into account."),Wt.forEach(e),bl=h(s),Ve=i(s,"P",{});var Xp=p(Ve);Rn=n(Xp,"Next up, you will derive the set of labels present in the dataset. Also, create two dictionaries that\u2019ll be helpful when initializing the model:"),Xp.forEach(e),Il=h(s),ts=i(s,"UL",{});var Bt=p(ts);Re=i(Bt,"LI",{});var cp=p(Re);pa=i(cp,"CODE",{});var $p=p(pa);Xn=n($p,"label2id"),$p.forEach(e),$n=n(cp,": maps the class names to integers."),cp.forEach(e),Sn=h(Bt),Xe=i(Bt,"LI",{});var hp=p(Xe);ra=i(hp,"CODE",{});var Sp=p(ra);Fn=n(Sp,"id2label"),Sp.forEach(e),xn=n(hp,": maps the integers to class names."),hp.forEach(e),Bt.forEach(e),vl=h(s),d(xs.$$.fragment,s),gl=h(s),$e=i(s,"P",{});var Fp=p($e);Nn=n(Fp,"There are 10 unique classes. For each class, there are 30 videos in the training set."),Fp.forEach(e),Cl=h(s),Y=i(s,"H2",{class:!0});var Vt=p(Y);ns=i(Vt,"A",{id:!0,class:!0,href:!0});var xp=p(ns);ca=i(xp,"SPAN",{});var Np=p(ca);d(Ns.$$.fragment,Np),Np.forEach(e),xp.forEach(e),zn=h(Vt),ha=i(Vt,"SPAN",{});var zp=p(ha);Yn=n(zp,"Load a model to fine-tune"),zp.forEach(e),Vt.forEach(e),_l=h(s),Se=i(s,"P",{});var Yp=p(Se);Qn=n(Yp,"Instantiate a video classification model from a pretrained checkpoint and its associated image processor. The model\u2019s encoder comes with pre-trained parameters, and the classification head is randomly initialized. The image processor will come in handy when writing the preprocessing pipeline for our dataset."),Yp.forEach(e),Zl=h(s),d(zs.$$.fragment,s),Al=h(s),Fe=i(s,"P",{});var Qp=p(Fe);Hn=n(Qp,"While the model is loading, you might notice the following warning:"),Qp.forEach(e),El=h(s),d(Ys.$$.fragment,s),kl=h(s),R=i(s,"P",{});var Ke=p(R);Dn=n(Ke,"The warning is telling us we are throwing away some weights (e.g. the weights and bias of the "),ma=i(Ke,"CODE",{});var Hp=p(ma);qn=n(Hp,"classifier"),Hp.forEach(e),Ln=n(Ke," layer) and randomly initializing some others (the weights and bias of a new "),Ma=i(Ke,"CODE",{});var Dp=p(Ma);Pn=n(Dp,"classifier"),Dp.forEach(e),Kn=n(Ke," layer). This is expected in this case, because we are adding a new head for which we don\u2019t have pretrained weights, so the library warns us we should fine-tune this model before using it for inference, which is exactly what we are going to do."),Ke.forEach(e),Gl=h(s),Z=i(s,"P",{});var L=p(Z);da=i(L,"STRONG",{});var qp=p(da);On=n(qp,"Note"),qp.forEach(e),so=n(L," that "),Qs=i(L,"A",{href:!0,rel:!0});var Lp=p(Qs);eo=n(Lp,"this checkpoint"),Lp.forEach(e),ao=n(L," leads to better performance on this task as the checkpoint was obtained fine-tuning on a similar downstream task having considerable domain overlap. You can check out "),Hs=i(L,"A",{href:!0,rel:!0});var Pp=p(Hs);lo=n(Pp,"this checkpoint"),Pp.forEach(e),to=n(L," which was obtained by fine-tuning "),ya=i(L,"CODE",{});var Kp=p(ya);no=n(Kp,"MCG-NJU/videomae-base-finetuned-kinetics"),Kp.forEach(e),oo=n(L,"."),L.forEach(e),Wl=h(s),Q=i(s,"H2",{class:!0});var Rt=p(Q);os=i(Rt,"A",{id:!0,class:!0,href:!0});var Op=p(os);wa=i(Op,"SPAN",{});var sr=p(wa);d(Ds.$$.fragment,sr),sr.forEach(e),Op.forEach(e),io=h(Rt),fa=i(Rt,"SPAN",{});var er=p(fa);po=n(er,"Prepare the datasets for training"),er.forEach(e),Rt.forEach(e),Bl=h(s),is=i(s,"P",{});var Xt=p(is);ro=n(Xt,"For preprocessing the videos, you will leverage the "),qs=i(Xt,"A",{href:!0,rel:!0});var ar=p(qs);co=n(ar,"PyTorchVideo library"),ar.forEach(e),ho=n(Xt,". Start by importing the dependencies we need."),Xt.forEach(e),Vl=h(s),d(Ls.$$.fragment,s),Rl=h(s),ps=i(s,"P",{});var $t=p(ps);mo=n($t,"For the training dataset transformations, use a combination of uniform temporal subsampling, pixel normalization, random cropping, and random horizontal flipping. For the validation and evaluation dataset transformations, keep the same transformation chain except for random cropping and horizontal flipping. To learn more about the details of these transformations check out the "),Ps=i($t,"A",{href:!0,rel:!0});var lr=p(Ps);Mo=n(lr,"official documentation of PyTorchVideo"),lr.forEach(e),yo=n($t,"."),$t.forEach(e),Xl=h(s),rs=i(s,"P",{});var St=p(rs);wo=n(St,"Use the "),ua=i(St,"CODE",{});var tr=p(ua);fo=n(tr,"image_processor"),tr.forEach(e),uo=n(St," associated with the pre-trained model to obtain the following information:"),St.forEach(e),$l=h(s),cs=i(s,"UL",{});var Ft=p(cs);Ja=i(Ft,"LI",{});var nr=p(Ja);Jo=n(nr,"Image mean and standard deviation with which the video frame pixels will be normalized."),nr.forEach(e),jo=h(Ft),ja=i(Ft,"LI",{});var or=p(ja);Uo=n(or,"Spatial resolution to which the video frames will be resized."),or.forEach(e),Ft.forEach(e),Sl=h(s),xe=i(s,"P",{});var ir=p(xe);To=n(ir,"Start by defining some constants."),ir.forEach(e),Fl=h(s),d(Ks.$$.fragment,s),xl=h(s),Ne=i(s,"P",{});var pr=p(Ne);bo=n(pr,"Now, define the dataset-specific transformations and the datasets respectively. Starting with the training set:"),pr.forEach(e),Nl=h(s),d(Os.$$.fragment,s),zl=h(s),ze=i(s,"P",{});var rr=p(ze);Io=n(rr,"The same sequence of workflow can be applied to the validation and evaluation sets:"),rr.forEach(e),Yl=h(s),d(se.$$.fragment,s),Ql=h(s),j=i(s,"P",{});var U=p(j);Ua=i(U,"STRONG",{});var cr=p(Ua);vo=n(cr,"Note"),cr.forEach(e),go=n(U,": The above dataset pipelines are taken from the "),ee=i(U,"A",{href:!0,rel:!0});var hr=p(ee);Co=n(hr,"official PyTorchVideo example"),hr.forEach(e),_o=n(U,". We\u2019re using the "),ae=i(U,"A",{href:!0,rel:!0});var mr=p(ae);Ta=i(mr,"CODE",{});var Mr=p(Ta);Zo=n(Mr,"pytorchvideo.data.Ucf101()"),Mr.forEach(e),mr.forEach(e),Ao=n(U," function because it\u2019s tailored for the UCF-101 dataset. Under the hood, it returns a "),le=i(U,"A",{href:!0,rel:!0});var dr=p(le);ba=i(dr,"CODE",{});var yr=p(ba);Eo=n(yr,"pytorchvideo.data.labeled_video_dataset.LabeledVideoDataset"),yr.forEach(e),dr.forEach(e),ko=n(U," object. "),Ia=i(U,"CODE",{});var wr=p(Ia);Go=n(wr,"LabeledVideoDataset"),wr.forEach(e),Wo=n(U," class is the base class for all things video in the PyTorchVideo dataset. So, if you want to use a custom dataset not supported off-the-shelf by PyTorchVideo, you can extend the "),va=i(U,"CODE",{});var fr=p(va);Bo=n(fr,"LabeledVideoDataset"),fr.forEach(e),Vo=n(U," class accordingly. Refer to the "),ga=i(U,"CODE",{});var ur=p(ga);Ro=n(ur,"data"),ur.forEach(e),Xo=n(U," API "),te=i(U,"A",{href:!0,rel:!0});var Jr=p(te);$o=n(Jr,"documentation to"),Jr.forEach(e),So=n(U," learn more. Also, if your dataset follows a similar structure (as shown above), then using the "),Ca=i(U,"CODE",{});var jr=p(Ca);Fo=n(jr,"pytorchvideo.data.Ucf101()"),jr.forEach(e),xo=n(U," should work just fine."),U.forEach(e),Hl=h(s),hs=i(s,"P",{});var xt=p(hs);No=n(xt,"You can access the "),_a=i(xt,"CODE",{});var Ur=p(_a);zo=n(Ur,"num_videos"),Ur.forEach(e),Yo=n(xt," argument to know the number of videos in the dataset."),xt.forEach(e),Dl=h(s),d(ne.$$.fragment,s),ql=h(s),H=i(s,"H2",{class:!0});var Nt=p(H);ms=i(Nt,"A",{id:!0,class:!0,href:!0});var Tr=p(ms);Za=i(Tr,"SPAN",{});var br=p(Za);d(oe.$$.fragment,br),br.forEach(e),Tr.forEach(e),Qo=h(Nt),Aa=i(Nt,"SPAN",{});var Ir=p(Aa);Ho=n(Ir,"Visualize the preprocessed video for better debugging"),Ir.forEach(e),Nt.forEach(e),Ll=h(s),d(ie.$$.fragment,s),Pl=h(s),pe=i(s,"DIV",{class:!0});var vr=p(pe);Ye=i(vr,"IMG",{src:!0,alt:!0}),vr.forEach(e),Kl=h(s),D=i(s,"H2",{class:!0});var zt=p(D);Ms=i(zt,"A",{id:!0,class:!0,href:!0});var gr=p(Ms);Ea=i(gr,"SPAN",{});var Cr=p(Ea);d(re.$$.fragment,Cr),Cr.forEach(e),gr.forEach(e),Do=h(zt),ka=i(zt,"SPAN",{});var _r=p(ka);qo=n(_r,"Train the model"),_r.forEach(e),zt.forEach(e),Ol=h(s),k=i(s,"P",{});var vs=p(k);Lo=n(vs,"Leverage "),ce=i(vs,"A",{href:!0,rel:!0});var Zr=p(ce);Ga=i(Zr,"CODE",{});var Ar=p(Ga);Po=n(Ar,"Trainer"),Ar.forEach(e),Zr.forEach(e),Ko=n(vs," from  \u{1F917} Transformers for training the model. To instantiate a "),Wa=i(vs,"CODE",{});var Er=p(Wa);Oo=n(Er,"Trainer"),Er.forEach(e),si=n(vs,", you need to define the training configuration and an evaluation metric. The most important is the "),he=i(vs,"A",{href:!0,rel:!0});var kr=p(he);Ba=i(kr,"CODE",{});var Gr=p(Ba);ei=n(Gr,"TrainingArguments"),Gr.forEach(e),kr.forEach(e),ai=n(vs,", which is a class that contains all the attributes to configure the training. It requires an output folder name, which will be used to save the checkpoints of the model. It also helps sync all the information in the model repository on \u{1F917} Hub."),vs.forEach(e),st=h(s),G=i(s,"P",{});var gs=p(G);li=n(gs,"Most of the training arguments are self-explanatory, but one that is quite important here is "),Va=i(gs,"CODE",{});var Wr=p(Va);ti=n(Wr,"remove_unused_columns=False"),Wr.forEach(e),ni=n(gs,". This one will drop any features not used by the model\u2019s call function. By default it\u2019s "),Ra=i(gs,"CODE",{});var Br=p(Ra);oi=n(Br,"True"),Br.forEach(e),ii=n(gs," because usually it\u2019s ideal to drop unused feature columns, making it easier to unpack inputs into the model\u2019s call function. But, in this case, you need the unused features (\u2018video\u2019 in particular) in order to create "),Xa=i(gs,"CODE",{});var Vr=p(Xa);pi=n(Vr,"pixel_values"),Vr.forEach(e),ri=n(gs," (which is a mandatory key our model expects in its inputs)."),gs.forEach(e),et=h(s),d(me.$$.fragment,s),at=h(s),_=i(s,"P",{});var $=p(_);ci=n($,"The dataset returned by "),$a=i($,"CODE",{});var Rr=p($a);hi=n(Rr,"pytorchvideo.data.Ucf101()"),Rr.forEach(e),mi=n($," doesn\u2019t implement the "),Sa=i($,"CODE",{});var Xr=p(Sa);Mi=n(Xr,"__len__"),Xr.forEach(e),di=n($," method. As such, we must define "),Fa=i($,"CODE",{});var $r=p(Fa);yi=n($r,"max_steps"),$r.forEach(e),wi=n($," when instantiating "),xa=i($,"CODE",{});var Sr=p(xa);fi=n(Sr,"TrainingArguments"),Sr.forEach(e),ui=n($,"."),$.forEach(e),lt=h(s),ds=i(s,"P",{});var Yt=p(ds);Ji=n(Yt,"Next, you need to define a function to compute the metrics from the predictions, which will use the "),Na=i(Yt,"CODE",{});var Fr=p(Na);ji=n(Fr,"metric"),Fr.forEach(e),Ui=n(Yt," you\u2019ll load now. The only preprocessing you have to do is to take the argmax of our predicted logits:"),Yt.forEach(e),tt=h(s),d(Me.$$.fragment,s),nt=h(s),de=i(s,"P",{});var mp=p(de);za=i(mp,"STRONG",{});var xr=p(za);Ti=n(xr,"A note on evaluation"),xr.forEach(e),bi=n(mp,":"),mp.forEach(e),ot=h(s),ys=i(s,"P",{});var Qt=p(ys);Ii=n(Qt,"In the "),ye=i(Qt,"A",{href:!0,rel:!0});var Nr=p(ye);vi=n(Nr,"VideoMAE paper"),Nr.forEach(e),gi=n(Qt,", the authors use the following evaluation strategy. They evaluate the model on several clips from test videos and apply different crops to those clips and report the aggregate score. However, in the interest of simplicity and brevity, we don\u2019t consider that in this tutorial."),Qt.forEach(e),it=h(s),W=i(s,"P",{});var Cs=p(W);Ci=n(Cs,"Also, define a "),Ya=i(Cs,"CODE",{});var zr=p(Ya);_i=n(zr,"collate_fn"),zr.forEach(e),Zi=n(Cs,", which will be used to batch examples together. Each batch consists of 2 keys, namely "),Qa=i(Cs,"CODE",{});var Yr=p(Qa);Ai=n(Yr,"pixel_values"),Yr.forEach(e),Ei=n(Cs," and "),Ha=i(Cs,"CODE",{});var Qr=p(Ha);ki=n(Qr,"labels"),Qr.forEach(e),Gi=n(Cs,"."),Cs.forEach(e),pt=h(s),d(we.$$.fragment,s),rt=h(s),ws=i(s,"P",{});var Ht=p(ws);Wi=n(Ht,"Then you just pass all of this along with the datasets to "),Da=i(Ht,"CODE",{});var Hr=p(Da);Bi=n(Hr,"Trainer"),Hr.forEach(e),Vi=n(Ht,":"),Ht.forEach(e),ct=h(s),d(fe.$$.fragment,s),ht=h(s),fs=i(s,"P",{});var Dt=p(fs);Ri=n(Dt,"You might wonder why you passed along the "),qa=i(Dt,"CODE",{});var Dr=p(qa);Xi=n(Dr,"image_processor"),Dr.forEach(e),$i=n(Dt," as a tokenizer when you preprocessed the data already. This is only to make sure the image processor configuration file (stored as JSON) will also be uploaded to the repo on the Hub."),Dt.forEach(e),mt=h(s),us=i(s,"P",{});var qt=p(us);Si=n(qt,"Now fine-tune our model by calling the "),La=i(qt,"CODE",{});var qr=p(La);Fi=n(qr,"train"),qr.forEach(e),xi=n(qt," method:"),qt.forEach(e),Mt=h(s),d(ue.$$.fragment,s),dt=h(s),Js=i(s,"P",{});var Lt=p(Js);Ni=n(Lt,"Once training is completed, share your model to the Hub with the "),Qe=i(Lt,"A",{href:!0});var Lr=p(Qe);zi=n(Lr,"push_to_hub()"),Lr.forEach(e),Yi=n(Lt," method so everyone can use your model:"),Lt.forEach(e),yt=h(s),d(Je.$$.fragment,s),wt=h(s),q=i(s,"H2",{class:!0});var Pt=p(q);js=i(Pt,"A",{id:!0,class:!0,href:!0});var Pr=p(js);Pa=i(Pr,"SPAN",{});var Kr=p(Pa);d(je.$$.fragment,Kr),Kr.forEach(e),Pr.forEach(e),Qi=h(Pt),Ka=i(Pt,"SPAN",{});var Or=p(Ka);Hi=n(Or,"Inference"),Or.forEach(e),Pt.forEach(e),ft=h(s),He=i(s,"P",{});var sc=p(He);Di=n(sc,"Great, now that you have fine-tuned a model, you can use it for inference!"),sc.forEach(e),ut=h(s),De=i(s,"P",{});var ec=p(De);qi=n(ec,"Load a video for inference:"),ec.forEach(e),Jt=h(s),d(Ue.$$.fragment,s),jt=h(s),Te=i(s,"DIV",{class:!0});var ac=p(Te);qe=i(ac,"IMG",{src:!0,alt:!0}),ac.forEach(e),Ut=h(s),X=i(s,"P",{});var Oe=p(X);Li=n(Oe,"The simplest way to try out your fine-tuned model for inference is to use it in a "),be=i(Oe,"A",{href:!0,rel:!0});var lc=p(be);Oa=i(lc,"CODE",{});var tc=p(Oa);Pi=n(tc,"pipeline"),tc.forEach(e),lc.forEach(e),Ki=n(Oe,". Instantiate a "),sl=i(Oe,"CODE",{});var nc=p(sl);Oi=n(nc,"pipeline"),nc.forEach(e),sp=n(Oe," for video classification with your model, and pass your video to it:"),Oe.forEach(e),Tt=h(s),d(Ie.$$.fragment,s),bt=h(s),Us=i(s,"P",{});var Kt=p(Us);ep=n(Kt,"You can also manually replicate the results of the "),el=i(Kt,"CODE",{});var oc=p(el);ap=n(oc,"pipeline"),oc.forEach(e),lp=n(Kt," if you\u2019d like."),Kt.forEach(e),It=h(s),d(ve.$$.fragment,s),vt=h(s),Ts=i(s,"P",{});var Ot=p(Ts);tp=n(Ot,"Now, pass your input to the model and return the "),al=i(Ot,"CODE",{});var ic=p(al);np=n(ic,"logits"),ic.forEach(e),op=n(Ot,":"),Ot.forEach(e),gt=h(s),d(ge.$$.fragment,s),Ct=h(s),bs=i(s,"P",{});var sn=p(bs);ip=n(sn,"Decoding the "),ll=i(sn,"CODE",{});var pc=p(ll);pp=n(pc,"logits"),pc.forEach(e),rp=n(sn,", we get:"),sn.forEach(e),_t=h(s),d(Ce.$$.fragment,s),this.h()},h(){m(v,"name","hf:doc:metadata"),m(v,"content",JSON.stringify(Jc)),m(A,"id","video-classification"),m(A,"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"),m(A,"href","#video-classification"),m(T,"class","relative group"),m(As,"href","https://huggingface.co/docs/transformers/main/en/model_doc/videomae"),m(As,"rel","nofollow"),m(Es,"href","https://www.crcv.ucf.edu/data/UCF101.php"),m(Es,"rel","nofollow"),m(Gs,"href","https://pytorchvideo.org/"),m(Gs,"rel","nofollow"),m(ss,"id","load-ucf101-dataset"),m(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"),m(ss,"href","#load-ucf101-dataset"),m(z,"class","relative group"),m(Vs,"href","https://www.crcv.ucf.edu/data/UCF101.php"),m(Vs,"rel","nofollow"),m(Fs,"href","https://www.kaggle.com/code/alexisbcook/data-leakage"),m(Fs,"rel","nofollow"),m(ns,"id","load-a-model-to-finetune"),m(ns,"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"),m(ns,"href","#load-a-model-to-finetune"),m(Y,"class","relative group"),m(Qs,"href","https://huggingface.co/MCG-NJU/videomae-base-finetuned-kinetics"),m(Qs,"rel","nofollow"),m(Hs,"href","https://huggingface.co/sayakpaul/videomae-base-finetuned-kinetics-finetuned-ucf101-subset"),m(Hs,"rel","nofollow"),m(os,"id","prepare-the-datasets-for-training"),m(os,"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"),m(os,"href","#prepare-the-datasets-for-training"),m(Q,"class","relative group"),m(qs,"href","https://pytorchvideo.org/"),m(qs,"rel","nofollow"),m(Ps,"href","https://pytorchvideo.org"),m(Ps,"rel","nofollow"),m(ee,"href","https://pytorchvideo.org/docs/tutorial_classification#dataset"),m(ee,"rel","nofollow"),m(ae,"href","https://pytorchvideo.readthedocs.io/en/latest/api/data/data.html#pytorchvideo.data.Ucf101"),m(ae,"rel","nofollow"),m(le,"href","https://pytorchvideo.readthedocs.io/en/latest/api/data/data.html#pytorchvideo.data.LabeledVideoDataset"),m(le,"rel","nofollow"),m(te,"href","https://pytorchvideo.readthedocs.io/en/latest/api/data/data.html"),m(te,"rel","nofollow"),m(ms,"id","visualize-the-preprocessed-video-for-better-debugging"),m(ms,"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"),m(ms,"href","#visualize-the-preprocessed-video-for-better-debugging"),m(H,"class","relative group"),rc(Ye.src,Mp="https://huggingface.co/datasets/huggingface/documentation-images/resolve/main/transformers/tasks/sample_gif.gif")||m(Ye,"src",Mp),m(Ye,"alt","Person playing basketball"),m(pe,"class","flex justify-center"),m(Ms,"id","train-the-model"),m(Ms,"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"),m(Ms,"href","#train-the-model"),m(D,"class","relative group"),m(ce,"href","https://huggingface.co/docs/transformers/main_classes/trainer"),m(ce,"rel","nofollow"),m(he,"href","https://huggingface.co/transformers/main_classes/trainer.html#transformers.TrainingArguments"),m(he,"rel","nofollow"),m(ye,"href","https://arxiv.org/abs/2203.12602"),m(ye,"rel","nofollow"),m(Qe,"href","/docs/transformers/main/en/main_classes/trainer#transformers.Trainer.push_to_hub"),m(js,"id","inference"),m(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"),m(js,"href","#inference"),m(q,"class","relative group"),rc(qe.src,dp="https://huggingface.co/datasets/huggingface/documentation-images/resolve/main/transformers/tasks/sample_gif_two.gif")||m(qe,"src",dp),m(qe,"alt","Teams playing basketball"),m(Te,"class","flex justify-center"),m(be,"href","https://huggingface.co/docs/transformers/main/en/main_classes/pipelines#transformers.VideoClassificationPipeline"),m(be,"rel","nofollow")},m(s,l){a(document.head,v),r(s,I,l),r(s,T,l),a(T,A),a(A,S),y(g,S,null),a(T,_s),a(T,F),a(F,B),r(s,P,l),y(b,s,l),r(s,C,l),r(s,x,l),a(x,Ae),r(s,Zs,l),r(s,Ee,l),a(Ee,en),r(s,nl,l),r(s,K,l),a(K,N),a(N,an),a(N,As),a(As,ln),a(N,tn),a(N,Es),a(Es,nn),a(N,on),a(K,pn),a(K,sa),a(sa,rn),r(s,ol,l),y(O,s,l),r(s,il,l),r(s,ke,l),a(ke,cn),r(s,pl,l),y(ks,s,l),r(s,rl,l),r(s,V,l),a(V,hn),a(V,Gs),a(Gs,mn),a(V,Mn),a(V,ea),a(ea,dn),a(V,yn),r(s,cl,l),r(s,Ge,l),a(Ge,wn),r(s,hl,l),y(Ws,s,l),r(s,ml,l),r(s,z,l),a(z,ss),a(ss,aa),y(Bs,aa,null),a(z,fn),a(z,la),a(la,un),r(s,Ml,l),r(s,es,l),a(es,Jn),a(es,Vs),a(Vs,jn),a(es,Un),r(s,dl,l),y(Rs,s,l),r(s,yl,l),r(s,We,l),a(We,Tn),r(s,wl,l),y(Xs,s,l),r(s,fl,l),r(s,Be,l),a(Be,bn),r(s,ul,l),y($s,s,l),r(s,Jl,l),r(s,as,l),a(as,In),a(as,ta),a(ta,vn),a(as,gn),r(s,jl,l),y(Ss,s,l),r(s,Ul,l),r(s,E,l),a(E,Cn),a(E,na),a(na,_n),a(E,Zn),a(E,oa),a(oa,An),a(E,En),a(E,ia),a(ia,kn),a(E,Gn),r(s,Tl,l),r(s,ls,l),a(ls,Wn),a(ls,Fs),a(Fs,Bn),a(ls,Vn),r(s,bl,l),r(s,Ve,l),a(Ve,Rn),r(s,Il,l),r(s,ts,l),a(ts,Re),a(Re,pa),a(pa,Xn),a(Re,$n),a(ts,Sn),a(ts,Xe),a(Xe,ra),a(ra,Fn),a(Xe,xn),r(s,vl,l),y(xs,s,l),r(s,gl,l),r(s,$e,l),a($e,Nn),r(s,Cl,l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xi),r(s,Mt,l),y(ue,s,l),r(s,dt,l),r(s,Js,l),a(Js,Ni),a(Js,Qe),a(Qe,zi),a(Js,Yi),r(s,yt,l),y(Je,s,l),r(s,wt,l),r(s,q,l),a(q,js),a(js,Pa),y(je,Pa,null),a(q,Qi),a(q,Ka),a(Ka,Hi),r(s,ft,l),r(s,He,l),a(He,Di),r(s,ut,l),r(s,De,l),a(De,qi),r(s,Jt,l),y(Ue,s,l),r(s,jt,l),r(s,Te,l),a(Te,qe),r(s,Ut,l),r(s,X,l),a(X,Li),a(X,be),a(be,Oa),a(Oa,Pi),a(X,Ki),a(X,sl),a(sl,Oi),a(X,sp),r(s,Tt,l),y(Ie,s,l),r(s,bt,l),r(s,Us,l),a(Us,ep),a(Us,el),a(el,ap),a(Us,lp),r(s,It,l),y(ve,s,l),r(s,vt,l),r(s,Ts,l),a(Ts,tp),a(Ts,al),a(al,np),a(Ts,op),r(s,gt,l),y(ge,s,l),r(s,Ct,l),r(s,bs,l),a(bs,ip),a(bs,ll),a(ll,pp),a(bs,rp),r(s,_t,l),y(Ce,s,l),Zt=!0},p(s,[l]){const _e={};l&2&&(_e.$$scope={dirty:l,ctx:s}),O.$set(_e)},i(s){Zt||(w(g.$$.fragment,s),w(b.$$.fragment,s),w(O.$$.fragment,s),w(ks.$$.fragment,s),w(Ws.$$.fragment,s),w(Bs.$$.fragment,s),w(Rs.$$.fragment,s),w(Xs.$$.fragment,s),w($s.$$.fragment,s),w(Ss.$$.fragment,s),w(xs.$$.fragment,s),w(Ns.$$.fragment,s),w(zs.$$.fragment,s),w(Ys.$$.fragment,s),w(Ds.$$.fragment,s),w(Ls.$$.fragment,s),w(Ks.$$.fragment,s),w(Os.$$.fragment,s),w(se.$$.fragment,s),w(ne.$$.fragment,s),w(oe.$$.fragment,s),w(ie.$$.fragment,s),w(re.$$.fragment,s),w(me.$$.fragment,s),w(Me.$$.fragment,s),w(we.$$.fragment,s),w(fe.$$.fragment,s),w(ue.$$.fragment,s),w(Je.$$.fragment,s),w(je.$$.fragment,s),w(Ue.$$.fragment,s),w(Ie.$$.fragment,s),w(ve.$$.fragment,s),w(ge.$$.fragment,s),w(Ce.$$.fragment,s),Zt=!0)},o(s){f(g.$$.fragment,s),f(b.$$.fragment,s),f(O.$$.fragment,s),f(ks.$$.fragment,s),f(Ws.$$.fragment,s),f(Bs.$$.fragment,s),f(Rs.$$.fragment,s),f(Xs.$$.fragment,s),f($s.$$.fragment,s),f(Ss.$$.fragment,s),f(xs.$$.fragment,s),f(Ns.$$.fragment,s),f(zs.$$.fragment,s),f(Ys.$$.fragment,s),f(Ds.$$.fragment,s),f(Ls.$$.fragment,s),f(Ks.$$.fragment,s),f(Os.$$.fragment,s),f(se.$$.fragment,s),f(ne.$$.fragment,s),f(oe.$$.fragment,s),f(ie.$$.fragment,s),f(re.$$.fragment,s),f(me.$$.fragment,s),f(Me.$$.fragment,s),f(we.$$.fragment,s),f(fe.$$.fragment,s),f(ue.$$.fragment,s),f(Je.$$.fragment,s),f(je.$$.fragment,s),f(Ue.$$.fragment,s),f(Ie.$$.fragment,s),f(ve.$$.fragment,s),f(ge.$$.fragment,s),f(Ce.$$.fragment,s),Zt=!1},d(s){e(v),s&&e(I),s&&e(T),u(g),s&&e(P),u(b,s),s&&e(C),s&&e(x),s&&e(Zs),s&&e(Ee),s&&e(nl),s&&e(K),s&&e(ol),u(O,s),s&&e(il),s&&e(ke),s&&e(pl),u(ks,s),s&&e(rl),s&&e(V),s&&e(cl),s&&e(Ge),s&&e(hl),u(Ws,s),s&&e(ml),s&&e(z),u(Bs),s&&e(Ml),s&&e(es),s&&e(dl),u(Rs,s),s&&e(yl),s&&e(We),s&&e(wl),u(Xs,s),s&&e(fl),s&&e(Be),s&&e(ul),u($s,s),s&&e(Jl),s&&e(as),s&&e(jl),u(Ss,s),s&&e(Ul),s&&e(E),s&&e(Tl),s&&e(ls),s&&e(bl),s&&e(Ve),s&&e(Il),s&&e(ts),s&&e(vl),u(xs,s),s&&e(gl),s&&e($e),s&&e(Cl),s&&e(Y),u(Ns),s&&e(_l),s&&e(Se),s&&e(Zl),u(zs,s),s&&e(Al),s&&e(Fe),s&&e(El),u(Ys,s),s&&e(kl),s&&e(R),s&&e(Gl),s&&e(Z),s&&e(Wl),s&&e(Q),u(Ds),s&&e(Bl),s&&e(is),s&&e(Vl),u(Ls,s),s&&e(Rl),s&&e(ps),s&&e(Xl),s&&e(rs),s&&e($l),s&&e(cs),s&&e(Sl),s&&e(xe),s&&e(Fl),u(Ks,s),s&&e(xl),s&&e(Ne),s&&e(Nl),u(Os,s),s&&e(zl),s&&e(ze),s&&e(Yl),u(se,s),s&&e(Ql),s&&e(j),s&&e(Hl),s&&e(hs),s&&e(Dl),u(ne,s),s&&e(ql),s&&e(H),u(oe),s&&e(Ll),u(ie,s),s&&e(Pl),s&&e(pe),s&&e(Kl),s&&e(D),u(re),s&&e(Ol),s&&e(k),s&&e(st),s&&e(G),s&&e(et),u(me,s),s&&e(at),s&&e(_),s&&e(lt),s&&e(ds),s&&e(tt),u(Me,s),s&&e(nt),s&&e(de),s&&e(ot),s&&e(ys),s&&e(it),s&&e(W),s&&e(pt),u(we,s),s&&e(rt),s&&e(ws),s&&e(ct),u(fe,s),s&&e(ht),s&&e(fs),s&&e(mt),s&&e(us),s&&e(Mt),u(ue,s),s&&e(dt),s&&e(Js),s&&e(yt),u(Je,s),s&&e(wt),s&&e(q),u(je),s&&e(ft),s&&e(He),s&&e(ut),s&&e(De),s&&e(Jt),u(Ue,s),s&&e(jt),s&&e(Te),s&&e(Ut),s&&e(X),s&&e(Tt),u(Ie,s),s&&e(bt),s&&e(Us),s&&e(It),u(ve,s),s&&e(vt),s&&e(Ts),s&&e(gt),u(ge,s),s&&e(Ct),s&&e(bs),s&&e(_t),u(Ce,s)}}}const Jc={local:"video-classification",sections:[{local:"load-ucf101-dataset",title:"Load UCF101 dataset"},{local:"load-a-model-to-finetune",title:"Load a model to fine-tune"},{local:"prepare-the-datasets-for-training",title:"Prepare the datasets for training"},{local:"visualize-the-preprocessed-video-for-better-debugging",title:"Visualize the preprocessed video for better debugging "},{local:"train-the-model",title:"Train the model "},{local:"inference",title:"Inference"}],title:"Video classification"};function jc(tl){return dc(()=>{new URLSearchParams(window.location.search).get("fw")}),[]}class gc extends cc{constructor(v){super();hc(this,v,jc,uc,mc,{})}}export{gc as default,Jc as metadata};
