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

`),T=n("p"),w=n("a"),A=l("TimeSformer"),I=l(", "),k=n("a"),Ee=l("VideoMAE"),this.h()},l(E){$=o(E,`The task illustrated in this tutorial is supported by the following model architectures:

`),T=i(E,"P",{});var S=r(T);w=i(S,"A",{href:!0});var xe=r(w);A=o(xe,"TimeSformer"),xe.forEach(s),I=o(S,", "),k=i(S,"A",{href:!0});var V=r(k);Ee=o(V,"VideoMAE"),V.forEach(s),S.forEach(s),this.h()},h(){m(w,"href","../model_doc/timesformer"),m(k,"href","../model_doc/videomae")},m(E,S){p(E,$,S),p(E,T,S),a(T,w),a(w,A),a(T,I),a(T,k),a(k,Ee)},d(E){E&&s($),E&&s(T)}}}function vc(st){let $,T,w,A,I,k,Ee,E,S,xe,V,at,Ts,eo,tt,qs,so,lt,K,O,ao,Te,to,lo,qe,oo,no,io,Qs,ro,ot,W,nt,As,po,it,Ae,rt,M,co,Ce,ho,mo,Xs,fo,uo,pt,Cs,_o,ct,ze,ht,B,Q,Zs,Pe,go,ea,vo,mt,X,bo,Fe,yo,jo,dt,Se,ft,zs,wo,ut,Ve,_t,Ps,$o,gt,Me,vt,Z,ko,sa,Eo,xo,bt,Ue,yt,C,To,aa,qo,Ao,ta,Co,zo,la,Po,Fo,jt,ee,So,De,Vo,Mo,wt,Fs,Uo,$t,se,Ss,oa,Do,No,Io,Vs,na,Oo,Bo,kt,Ne,Et,Ms,Lo,xt,L,ae,ia,Ie,Ro,ra,Go,Tt,Us,Ho,qt,Oe,At,Ds,Yo,Ct,Be,zt,U,Jo,pa,Ko,Wo,ca,Qo,Xo,Pt,q,ha,Zo,en,Le,sn,an,Re,tn,ln,ma,on,nn,Ft,R,te,da,Ge,rn,fa,pn,St,le,cn,He,hn,mn,Vt,Ye,Mt,oe,dn,Je,fn,un,Ut,ne,_n,ua,gn,vn,Dt,ie,_a,bn,yn,ga,jn,Nt,Ns,wn,It,Ke,Ot,Is,$n,Bt,We,Lt,Os,kn,Rt,Qe,Gt,y,va,En,xn,Xe,Tn,qn,Ze,ba,An,Cn,es,ya,zn,Pn,ja,Fn,Sn,wa,Vn,Mn,$a,Un,Dn,ss,Nn,In,ka,On,Bn,Ht,re,Ln,Ea,Rn,Gn,Yt,as,Jt,G,pe,xa,ts,Hn,Ta,Yn,Kt,ls,Wt,os,Bs,dr,Qt,H,ce,qa,ns,Jn,Aa,Kn,Xt,z,Wn,is,Ca,Qn,Xn,za,Zn,ei,rs,Pa,si,ai,Zt,P,ti,Fa,li,oi,Sa,ni,ii,Va,ri,pi,el,ps,sl,x,ci,Ma,hi,mi,Ua,di,fi,Da,ui,_i,Na,gi,vi,al,he,bi,Ia,yi,ji,tl,cs,ll,hs,Oa,wi,$i,ol,me,ki,ms,Ei,xi,nl,F,Ti,Ba,qi,Ai,La,Ci,zi,Ra,Pi,Fi,il,ds,rl,de,Si,Ga,Vi,Mi,pl,fs,cl,fe,Ui,Ha,Di,Ni,hl,ue,Ii,Ya,Oi,Bi,ml,us,dl,_e,Li,Ls,Ri,Gi,fl,_s,ul,Y,ge,Ja,gs,Hi,Ka,Yi,_l,Rs,Ji,gl,Gs,Ki,vl,vs,bl,bs,Hs,fr,yl,D,Wi,ys,Wa,Qi,Xi,Qa,Zi,er,jl,js,wl,ve,sr,Xa,ar,tr,$l,ws,kl,be,lr,Za,or,nr,El,$s,xl,ye,ir,et,rr,pr,Tl,ks,ql;return k=new xs({}),V=new _c({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"}]}}),W=new uc({props:{$$slots:{default:[gc]},$$scope:{ctx:st}}}),Ae=new b({props:{code:"pip install -q pytorchvideo transformers evaluate",highlighted:"pip install -q pytorchvideo transformers evaluate"}}),ze=new b({props:{code:`from huggingface_hub import notebook_login

notebook_login()`,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()`}}),Pe=new xs({}),Se=new b({props:{code:`from huggingface_hub import hf_hub_download

hf_dataset_identifier = "sayakpaul/ucf101-subset"
filename = "UCF101_subset.tar.gz"
file_path = hf_hub_download(repo_id=hf_dataset_identifier, filename=filename, repo_type="dataset")`,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>)`}}),Ve=new b({props:{code:`import tarfile

with tarfile.open(file_path) as t:
     t.extractall(".")`,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>)`}}),Me=new b({props:{code:`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
            ...
        ...
    test/
        BandMarching/
            video_1.mp4
            video_2.mp4
            ...
        Archery
            video_1.mp4
            video_2.mp4
            ...
        ...`,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
            ...
        ...`}}),Ue=new b({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>
...`}}),Ne=new b({props:{code:`class_labels = sorted({str(path).split("/")[2] for path in all_video_file_paths})
label2id = {label: i for i, label in enumerate(class_labels)}
id2label = {i: label for label, i in label2id.items()}

print(f"Unique classes: {list(label2id.keys())}.")
`,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>`}}),Ie=new xs({}),Oe=new b({props:{code:`from transformers import VideoMAEImageProcessor, VideoMAEForVideoClassification

model_ckpt = "MCG-NJU/videomae-base"
image_processor = VideoMAEImageProcessor.from_pretrained(model_ckpt)
model = VideoMAEForVideoClassification.from_pretrained(
    model_ckpt,
    label2id=label2id,
    id2label=id2label,
    ignore_mismatched_sizes=True,  # provide this in case you're planning to fine-tune an already fine-tuned checkpoint
)`,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>)`}}),Be=new b({props:{code:`Some weights of the model checkpoint at MCG-NJU/videomae-base were not used when initializing VideoMAEForVideoClassification: [..., 'decoder.decoder_layers.1.attention.output.dense.bias', 'decoder.decoder_layers.2.attention.attention.key.weight']
- This IS expected if 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 if 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: ['classifier.bias', 'classifier.weight']
You should probably TRAIN this model on a down-stream task to be able to use it for predictions and inference.`,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.`}}),Ge=new xs({}),Ye=new b({props:{code:`import pytorchvideo.data

from pytorchvideo.transforms import (
    ApplyTransformToKey,
    Normalize,
    RandomShortSideScale,
    RemoveKey,
    ShortSideScale,
    UniformTemporalSubsample,
)

from torchvision.transforms import (
    Compose,
    Lambda,
    RandomCrop,
    RandomHorizontalFlip,
    Resize,
)`,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>)`}}),Ke=new b({props:{code:`mean = image_processor.image_mean
std = image_processor.image_std
if "shortest_edge" in image_processor.size:
    height = width = image_processor.size["shortest_edge"]
else:
    height = image_processor.size["height"]
    width = image_processor.size["width"]
resize_to = (height, width)

num_frames_to_sample = model.config.num_frames
sample_rate = 4
fps = 30
clip_duration = num_frames_to_sample * sample_rate / fps`,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="hljs-meta">&gt;&gt;&gt; </span>clip_duration = num_frames_to_sample * sample_rate / fps`}}),We=new b({props:{code:`train_transform = Compose(
    [
        ApplyTransformToKey(
            key="video",
            transform=Compose(
                [
                    UniformTemporalSubsample(num_frames_to_sample),
                    Lambda(lambda x: x / 255.0),
                    Normalize(mean, std),
                    RandomShortSideScale(min_size=256, max_size=320),
                    RandomCrop(resize_to),
                    RandomHorizontalFlip(p=0.5),
                ]
            ),
        ),
    ]
)

train_dataset = pytorchvideo.data.Ucf101(
    data_path=os.path.join(dataset_root_path, "train"),
    clip_sampler=pytorchvideo.data.make_clip_sampler("random", clip_duration),
    decode_audio=False,
    transform=train_transform,
)`,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>)`}}),Qe=new b({props:{code:`val_transform = Compose(
    [
        ApplyTransformToKey(
            key="video",
            transform=Compose(
                [
                    UniformTemporalSubsample(num_frames_to_sample),
                    Lambda(lambda x: x / 255.0),
                    Normalize(mean, std),
                    Resize(resize_to),
                ]
            ),
        ),
    ]
)

val_dataset = pytorchvideo.data.Ucf101(
    data_path=os.path.join(dataset_root_path, "val"),
    clip_sampler=pytorchvideo.data.make_clip_sampler("uniform", clip_duration),
    decode_audio=False,
    transform=val_transform,
)

test_dataset = pytorchvideo.data.Ucf101(
    data_path=os.path.join(dataset_root_path, "test"),
    clip_sampler=pytorchvideo.data.make_clip_sampler("uniform", clip_duration),
    decode_audio=False,
    transform=val_transform,
)`,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>)`}}),as=new b({props:{code:"print(train_dataset.num_videos, val_dataset.num_videos, test_dataset.num_videos)",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>`}}),ts=new xs({}),ls=new b({props:{code:`import imageio
import numpy as np
from IPython.display import Image

def unnormalize_img(img):
    """Un-normalizes the image pixels."""
    img = (img * std) + mean
    img = (img * 255).astype("uint8")
    return img.clip(0, 255)

def create_gif(video_tensor, filename="sample.gif"):
    """Prepares a GIF from a video tensor.
    
    The video tensor is expected to have the following shape:
    (num_frames, num_channels, height, width).
    """
    frames = []
    for video_frame in video_tensor:
        frame_unnormalized = unnormalize_img(video_frame.permute(1, 2, 0).numpy())
        frames.append(frame_unnormalized)
    kargs = {"duration": 0.25}
    imageio.mimsave(filename, frames, "GIF", **kargs)
    return filename

def display_gif(video_tensor, gif_name="sample.gif"):
    """Prepares and displays a GIF from a video tensor."""
    video_tensor = video_tensor.permute(1, 0, 2, 3)
    gif_filename = create_gif(video_tensor, gif_name)
    return Image(filename=gif_filename)

sample_video = next(iter(train_dataset))
video_tensor = sample_video["video"]
display_gif(video_tensor)`,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)`}}),ns=new xs({}),ps=new b({props:{code:`from transformers import TrainingArguments, Trainer

model_name = model_ckpt.split("/")[-1]
new_model_name = f"{model_name}-finetuned-ucf101-subset"
num_epochs = 4

args = TrainingArguments(
    new_model_name,
    remove_unused_columns=False,
    evaluation_strategy="epoch",
    save_strategy="epoch",
    learning_rate=5e-5,
    per_device_train_batch_size=batch_size,
    per_device_eval_batch_size=batch_size,
    warmup_ratio=0.1,
    logging_steps=10,
    load_best_model_at_end=True,
    metric_for_best_model="accuracy",
    push_to_hub=True,
    max_steps=(train_dataset.num_videos // batch_size) * num_epochs,
)`,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>)`}}),cs=new b({props:{code:`import evaluate

metric = evaluate.load("accuracy")


def compute_metrics(eval_pred):
    predictions = np.argmax(eval_pred.predictions, axis=1)
    return metric.compute(predictions=predictions, references=eval_pred.label_ids)`,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)`}}),ds=new b({props:{code:`def collate_fn(examples):
    # permute to (num_frames, num_channels, height, width)
    pixel_values = torch.stack(
        [example["video"].permute(1, 0, 2, 3) for example in examples]
    )
    labels = torch.tensor([example["label"] for example in examples])
    return {"pixel_values": pixel_values, "labels": labels}`,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}`}}),fs=new b({props:{code:`trainer = Trainer(
    model,
    args,
    train_dataset=train_dataset,
    eval_dataset=val_dataset,
    tokenizer=image_processor,
    compute_metrics=compute_metrics,
    data_collator=collate_fn,
)`,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>)`}}),us=new b({props:{code:"train_results = trainer.train()",highlighted:'<span class="hljs-meta">&gt;&gt;&gt; </span>train_results = trainer.train()'}}),_s=new b({props:{code:"trainer.push_to_hub()",highlighted:'<span class="hljs-meta">&gt;&gt;&gt; </span>trainer.push_to_hub()'}}),gs=new xs({}),vs=new b({props:{code:"sample_test_video = next(iter(test_dataset))",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))'}}),js=new b({props:{code:`from transformers import pipeline

video_cls = pipeline(model="my_awesome_video_cls_model")
video_cls("https://huggingface.co/datasets/sayakpaul/ucf101-subset/resolve/main/v_BasketballDunk_g14_c06.avi")`,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>}]`}}),ws=new b({props:{code:`def run_inference(model, video):
    # (num_frames, num_channels, height, width)
    perumuted_sample_test_video = video.permute(1, 0, 2, 3)
    inputs = {
        "pixel_values": perumuted_sample_test_video.unsqueeze(0),
        "labels": torch.tensor(
            [sample_test_video["label"]]
        ),  # this can be skipped if you don't have labels available.
    }

    device = torch.device("cuda" if torch.cuda.is_available() else "cpu")
    inputs = {k: v.to(device) for k, v in inputs.items()}
    model = model.to(device)

    # forward pass
    with torch.no_grad():
        outputs = model(**inputs)
        logits = outputs.logits

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