import{S as Zt,i as Ct,s as Wt,e as n,k as u,w,t as l,M as kt,c as o,d as a,m as g,a as r,x as _,h as i,b as c,G as s,g as f,y as b,q as j,o as J,B as v,v as Bt,L as Ra}from"../../chunks/vendor-hf-doc-builder.js";import{T as It}from"../../chunks/Tip-hf-doc-builder.js";import{D as rs}from"../../chunks/Docstring-hf-doc-builder.js";import{C as Sa}from"../../chunks/CodeBlock-hf-doc-builder.js";import{I as Re}from"../../chunks/IconCopyLink-hf-doc-builder.js";import{E as Xa}from"../../chunks/ExampleCodeBlock-hf-doc-builder.js";function Et(I){let m,T,M,p,y;return p=new Sa({props:{code:"ZnJvbSUyMHRyYW5zZm9ybWVycyUyMGltcG9ydCUyMFRpbWVzZm9ybWVyQ29uZmlnJTJDJTIwVGltZXNmb3JtZXJNb2RlbCUwQSUwQSUyMyUyMEluaXRpYWxpemluZyUyMGElMjBUaW1lU2Zvcm1lciUyMHRpbWVzZm9ybWVyLWJhc2UlMjBzdHlsZSUyMGNvbmZpZ3VyYXRpb24lMEFjb25maWd1cmF0aW9uJTIwJTNEJTIwVGltZXNmb3JtZXJDb25maWcoKSUwQSUwQSUyMyUyMEluaXRpYWxpemluZyUyMGElMjBtb2RlbCUyMGZyb20lMjB0aGUlMjBjb25maWd1cmF0aW9uJTBBbW9kZWwlMjAlM0QlMjBUaW1lc2Zvcm1lck1vZGVsKGNvbmZpZ3VyYXRpb24pJTBBJTBBJTIzJTIwQWNjZXNzaW5nJTIwdGhlJTIwbW9kZWwlMjBjb25maWd1cmF0aW9uJTBBY29uZmlndXJhdGlvbiUyMCUzRCUyMG1vZGVsLmNvbmZpZw==",highlighted:`<span class="hljs-meta">&gt;&gt;&gt; </span><span class="hljs-keyword">from</span> transformers <span class="hljs-keyword">import</span> TimesformerConfig, TimesformerModel

<span class="hljs-meta">&gt;&gt;&gt; </span><span class="hljs-comment"># Initializing a TimeSformer timesformer-base style configuration</span>
<span class="hljs-meta">&gt;&gt;&gt; </span>configuration = TimesformerConfig()

<span class="hljs-meta">&gt;&gt;&gt; </span><span class="hljs-comment"># Initializing a model from the configuration</span>
<span class="hljs-meta">&gt;&gt;&gt; </span>model = TimesformerModel(configuration)

<span class="hljs-meta">&gt;&gt;&gt; </span><span class="hljs-comment"># Accessing the model configuration</span>
<span class="hljs-meta">&gt;&gt;&gt; </span>configuration = model.config`}}),{c(){m=n("p"),T=l("Example:"),M=u(),w(p.$$.fragment)},l(t){m=o(t,"P",{});var h=r(m);T=i(h,"Example:"),h.forEach(a),M=g(t),_(p.$$.fragment,t)},m(t,h){f(t,m,h),s(m,T),f(t,M,h),b(p,t,h),y=!0},p:Ra,i(t){y||(j(p.$$.fragment,t),y=!0)},o(t){J(p.$$.fragment,t),y=!1},d(t){t&&a(m),t&&a(M),v(p,t)}}}function Vt(I){let m,T,M,p,y;return{c(){m=n("p"),T=l("Although the recipe for forward pass needs to be defined within this function, one should call the "),M=n("code"),p=l("Module"),y=l(`
instance afterwards instead of this since the former takes care of running the pre and post processing steps while
the latter silently ignores them.`)},l(t){m=o(t,"P",{});var h=r(m);T=i(h,"Although the recipe for forward pass needs to be defined within this function, one should call the "),M=o(h,"CODE",{});var W=r(M);p=i(W,"Module"),W.forEach(a),y=i(h,`
instance afterwards instead of this since the former takes care of running the pre and post processing steps while
the latter silently ignores them.`),h.forEach(a)},m(t,h){f(t,m,h),s(m,T),s(m,M),s(M,p),s(m,y)},d(t){t&&a(m)}}}function Gt(I){let m,T,M,p,y;return p=new Sa({props:{code:"aW1wb3J0JTIwYXYlMEFpbXBvcnQlMjBudW1weSUyMGFzJTIwbnAlMEElMEFmcm9tJTIwdHJhbnNmb3JtZXJzJTIwaW1wb3J0JTIwQXV0b0ltYWdlUHJvY2Vzc29yJTJDJTIwVGltZXNmb3JtZXJNb2RlbCUwQWZyb20lMjBodWdnaW5nZmFjZV9odWIlMjBpbXBvcnQlMjBoZl9odWJfZG93bmxvYWQlMEElMEFucC5yYW5kb20uc2VlZCgwKSUwQSUwQSUwQWRlZiUyMHJ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QWlucHV0cyUyMCUzRCUyMGltYWdlX3Byb2Nlc3NvcihsaXN0KHZpZGVvKSUyQyUyMHJldHVybl90ZW5zb3JzJTNEJTIycHQlMjIpJTBBJTBBJTIzJTIwZm9yd2FyZCUyMHBhc3MlMEFvdXRwdXRzJTIwJTNEJTIwbW9kZWwoKippbnB1dHMpJTBBbGFzdF9oaWRkZW5fc3RhdGVzJTIwJTNEJTIwb3V0cHV0cy5sYXN0X2hpZGRlbl9zdGF0ZSUwQWxpc3QobGFzdF9oaWRkZW5fc3RhdGVzLnNoYXBlKQ==",highlighted:`<span class="hljs-meta">&gt;&gt;&gt; </span><span class="hljs-keyword">import</span> av
<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> transformers <span class="hljs-keyword">import</span> AutoImageProcessor, TimesformerModel
<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>np.random.seed(<span class="hljs-number">0</span>)


<span class="hljs-meta">&gt;&gt;&gt; </span><span class="hljs-keyword">def</span> <span class="hljs-title function_">read_video_pyav</span>(<span class="hljs-params">container, indices</span>):
<span class="hljs-meta">... </span>    <span class="hljs-string">&#x27;&#x27;&#x27;
<span class="hljs-meta">... </span>    Decode the video with PyAV decoder.
<span class="hljs-meta">... </span>    Args:
<span class="hljs-meta">... </span>        container (\`av.container.input.InputContainer\`): PyAV container.
<span class="hljs-meta">... </span>        indices (\`List[int]\`): List of frame indices to decode.
<span class="hljs-meta">... </span>    Returns:
<span class="hljs-meta">... </span>        result (np.ndarray): np array of decoded frames of shape (num_frames, height, width, 3).
<span class="hljs-meta">... </span>    &#x27;&#x27;&#x27;</span>
<span class="hljs-meta">... </span>    frames = []
<span class="hljs-meta">... </span>    container.seek(<span class="hljs-number">0</span>)
<span class="hljs-meta">... </span>    start_index = indices[<span class="hljs-number">0</span>]
<span class="hljs-meta">... </span>    end_index = indices[-<span class="hljs-number">1</span>]
<span class="hljs-meta">... </span>    <span class="hljs-keyword">for</span> i, frame <span class="hljs-keyword">in</span> <span class="hljs-built_in">enumerate</span>(container.decode(video=<span class="hljs-number">0</span>)):
<span class="hljs-meta">... </span>        <span class="hljs-keyword">if</span> i &gt; end_index:
<span class="hljs-meta">... </span>            <span class="hljs-keyword">break</span>
<span class="hljs-meta">... </span>        <span class="hljs-keyword">if</span> i &gt;= start_index <span class="hljs-keyword">and</span> i <span class="hljs-keyword">in</span> indices:
<span class="hljs-meta">... </span>            frames.append(frame)
<span class="hljs-meta">... </span>    <span class="hljs-keyword">return</span> np.stack([x.to_ndarray(<span class="hljs-built_in">format</span>=<span class="hljs-string">&quot;rgb24&quot;</span>) <span class="hljs-keyword">for</span> x <span class="hljs-keyword">in</span> frames])


<span class="hljs-meta">&gt;&gt;&gt; </span><span class="hljs-keyword">def</span> <span class="hljs-title function_">sample_frame_indices</span>(<span class="hljs-params">clip_len, frame_sample_rate, seg_len</span>):
<span class="hljs-meta">... </span>    converted_len = <span class="hljs-built_in">int</span>(clip_len * frame_sample_rate)
<span class="hljs-meta">... </span>    end_idx = np.random.randint(converted_len, seg_len)
<span class="hljs-meta">... </span>    start_idx = end_idx - converted_len
<span class="hljs-meta">... </span>    indices = np.linspace(start_idx, end_idx, num=clip_len)
<span class="hljs-meta">... </span>    indices = np.clip(indices, start_idx, end_idx - <span class="hljs-number">1</span>).astype(np.int64)
<span class="hljs-meta">... </span>    <span class="hljs-keyword">return</span> indices


<span class="hljs-meta">&gt;&gt;&gt; </span><span class="hljs-comment"># video clip consists of 300 frames (10 seconds at 30 FPS)</span>
<span class="hljs-meta">&gt;&gt;&gt; </span>file_path = hf_hub_download(
<span class="hljs-meta">... </span>    repo_id=<span class="hljs-string">&quot;nielsr/video-demo&quot;</span>, filename=<span class="hljs-string">&quot;eating_spaghetti.mp4&quot;</span>, repo_type=<span class="hljs-string">&quot;dataset&quot;</span>
<span class="hljs-meta">... </span>)
<span class="hljs-meta">&gt;&gt;&gt; </span>container = av.<span class="hljs-built_in">open</span>(file_path)

<span class="hljs-meta">&gt;&gt;&gt; </span><span class="hljs-comment"># sample 8 frames</span>
<span class="hljs-meta">&gt;&gt;&gt; </span>indices = sample_frame_indices(clip_len=<span class="hljs-number">8</span>, frame_sample_rate=<span class="hljs-number">4</span>, seg_len=container.streams.video[<span class="hljs-number">0</span>].frames)
<span class="hljs-meta">&gt;&gt;&gt; </span>video = read_video_pyav(container, indices)

<span class="hljs-meta">&gt;&gt;&gt; </span>image_processor = AutoImageProcessor.from_pretrained(<span class="hljs-string">&quot;MCG-NJU/videomae-base&quot;</span>)
<span class="hljs-meta">&gt;&gt;&gt; </span>model = TimesformerModel.from_pretrained(<span class="hljs-string">&quot;facebook/timesformer-base-finetuned-k400&quot;</span>)

<span class="hljs-meta">&gt;&gt;&gt; </span><span class="hljs-comment"># prepare video for the model</span>
<span class="hljs-meta">&gt;&gt;&gt; </span>inputs = image_processor(<span class="hljs-built_in">list</span>(video), return_tensors=<span class="hljs-string">&quot;pt&quot;</span>)

<span class="hljs-meta">&gt;&gt;&gt; </span><span class="hljs-comment"># forward pass</span>
<span class="hljs-meta">&gt;&gt;&gt; </span>outputs = model(**inputs)
<span class="hljs-meta">&gt;&gt;&gt; </span>last_hidden_states = outputs.last_hidden_state
<span class="hljs-meta">&gt;&gt;&gt; </span><span class="hljs-built_in">list</span>(last_hidden_states.shape)
[<span class="hljs-number">1</span>, <span class="hljs-number">1569</span>, <span class="hljs-number">768</span>]`}}),{c(){m=n("p"),T=l("Examples:"),M=u(),w(p.$$.fragment)},l(t){m=o(t,"P",{});var h=r(m);T=i(h,"Examples:"),h.forEach(a),M=g(t),_(p.$$.fragment,t)},m(t,h){f(t,m,h),s(m,T),f(t,M,h),b(p,t,h),y=!0},p:Ra,i(t){y||(j(p.$$.fragment,t),y=!0)},o(t){J(p.$$.fragment,t),y=!1},d(t){t&&a(m),t&&a(M),v(p,t)}}}function $t(I){let m,T,M,p,y;return{c(){m=n("p"),T=l("Although the recipe for forward pass needs to be defined within this function, one should call the "),M=n("code"),p=l("Module"),y=l(`
instance afterwards instead of this since the former takes care of running the pre and post processing steps while
the latter silently ignores them.`)},l(t){m=o(t,"P",{});var h=r(m);T=i(h,"Although the recipe for forward pass needs to be defined within this function, one should call the "),M=o(h,"CODE",{});var W=r(M);p=i(W,"Module"),W.forEach(a),y=i(h,`
instance afterwards instead of this since the former takes care of running the pre and post processing steps while
the latter silently ignores them.`),h.forEach(a)},m(t,h){f(t,m,h),s(m,T),s(m,M),s(M,p),s(m,y)},d(t){t&&a(m)}}}function At(I){let m,T,M,p,y;return p=new Sa({props:{code:"aW1wb3J0JTIwYXYlMEFpbXBvcnQlMjB0b3JjaCUwQWltcG9ydCUyMG51bXB5JTIwYXMlMjBucCUwQSUwQWZyb20lMjB0cmFuc2Zvcm1lcnMlMjBpbXBvcnQlMjBBdXRvSW1hZ2VQcm9jZXNzb3IlMkMlMjBUaW1lc2Zvcm1lckZvclZpZGVvQ2xhc3NpZmljYXRpb24lMEFmcm9tJTIwaHVnZ2luZ2ZhY2VfaHViJTIwaW1wb3J0JTIwaGZfaHViX2Rvd25sb2FkJTBBJTBBbnAucmFuZG9tLnNlZWQoMCklMEElMEElMEFkZWYlMjByZWFkX3ZpZGVvX3B5YXYoY29udGFpbmVyJTJDJTIwaW5kaWNlcyklM0ElMEElMjAlMjAlMjAlMjAnJyclMEElMjAlMjAlMjAlMjBEZWNvZGUlMjB0aGUlMjB2aWRlbyUyMHdpdGglMjBQeUFWJTIwZGVjb2Rlci4lMEElMjAlMjAlMjAlMjBBcmdzJTNBJTBBJTIwJTIwJTIwJTIwJTIwJTIwJTIwJTIwY29udGFpbmVyJTIwKCU2MGF2LmNvbnRhaW5lci5pbnB1dC5JbnB1dENvbnRhaW5lciU2MCklM0ElMjBQeUFWJTIwY29udGFpbmVy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9uZSUyMG9mJTIwdGhlJTIwNDAwJTIwS2luZXRpY3MtNDAwJTIwY2xhc3NlcyUwQXByZWRpY3RlZF9sYWJlbCUyMCUzRCUyMGxvZ2l0cy5hcmdtYXgoLTEpLml0ZW0oKSUwQXByaW50KG1vZGVsLmNvbmZpZy5pZDJsYWJlbCU1QnByZWRpY3RlZF9sYWJlbCU1RCk=",highlighted:`<span class="hljs-meta">&gt;&gt;&gt; </span><span class="hljs-keyword">import</span> av
<span class="hljs-meta">&gt;&gt;&gt; </span><span class="hljs-keyword">import</span> torch
<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> transformers <span class="hljs-keyword">import</span> AutoImageProcessor, TimesformerForVideoClassification
<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>np.random.seed(<span class="hljs-number">0</span>)


<span class="hljs-meta">&gt;&gt;&gt; </span><span class="hljs-keyword">def</span> <span class="hljs-title function_">read_video_pyav</span>(<span class="hljs-params">container, indices</span>):
<span class="hljs-meta">... </span>    <span class="hljs-string">&#x27;&#x27;&#x27;
<span class="hljs-meta">... </span>    Decode the video with PyAV decoder.
<span class="hljs-meta">... </span>    Args:
<span class="hljs-meta">... </span>        container (\`av.container.input.InputContainer\`): PyAV container.
<span class="hljs-meta">... </span>        indices (\`List[int]\`): List of frame indices to decode.
<span class="hljs-meta">... </span>    Returns:
<span class="hljs-meta">... </span>        result (np.ndarray): np array of decoded frames of shape (num_frames, height, width, 3).
<span class="hljs-meta">... </span>    &#x27;&#x27;&#x27;</span>
<span class="hljs-meta">... </span>    frames = []
<span class="hljs-meta">... </span>    container.seek(<span class="hljs-number">0</span>)
<span class="hljs-meta">... </span>    start_index = indices[<span class="hljs-number">0</span>]
<span class="hljs-meta">... </span>    end_index = indices[-<span class="hljs-number">1</span>]
<span class="hljs-meta">... </span>    <span class="hljs-keyword">for</span> i, frame <span class="hljs-keyword">in</span> <span class="hljs-built_in">enumerate</span>(container.decode(video=<span class="hljs-number">0</span>)):
<span class="hljs-meta">... </span>        <span class="hljs-keyword">if</span> i &gt; end_index:
<span class="hljs-meta">... </span>            <span class="hljs-keyword">break</span>
<span class="hljs-meta">... </span>        <span class="hljs-keyword">if</span> i &gt;= start_index <span class="hljs-keyword">and</span> i <span class="hljs-keyword">in</span> indices:
<span class="hljs-meta">... </span>            frames.append(frame)
<span class="hljs-meta">... </span>    <span class="hljs-keyword">return</span> np.stack([x.to_ndarray(<span class="hljs-built_in">format</span>=<span class="hljs-string">&quot;rgb24&quot;</span>) <span class="hljs-keyword">for</span> x <span class="hljs-keyword">in</span> frames])


<span class="hljs-meta">&gt;&gt;&gt; </span><span class="hljs-keyword">def</span> <span class="hljs-title function_">sample_frame_indices</span>(<span class="hljs-params">clip_len, frame_sample_rate, seg_len</span>):
<span class="hljs-meta">... </span>    converted_len = <span class="hljs-built_in">int</span>(clip_len * frame_sample_rate)
<span class="hljs-meta">... </span>    end_idx = np.random.randint(converted_len, seg_len)
<span class="hljs-meta">... </span>    start_idx = end_idx - converted_len
<span class="hljs-meta">... </span>    indices = np.linspace(start_idx, end_idx, num=clip_len)
<span class="hljs-meta">... </span>    indices = np.clip(indices, start_idx, end_idx - <span class="hljs-number">1</span>).astype(np.int64)
<span class="hljs-meta">... </span>    <span class="hljs-keyword">return</span> indices


<span class="hljs-meta">&gt;&gt;&gt; </span><span class="hljs-comment"># video clip consists of 300 frames (10 seconds at 30 FPS)</span>
<span class="hljs-meta">&gt;&gt;&gt; </span>file_path = hf_hub_download(
<span class="hljs-meta">... </span>    repo_id=<span class="hljs-string">&quot;nielsr/video-demo&quot;</span>, filename=<span class="hljs-string">&quot;eating_spaghetti.mp4&quot;</span>, repo_type=<span class="hljs-string">&quot;dataset&quot;</span>
<span class="hljs-meta">... </span>)
<span class="hljs-meta">&gt;&gt;&gt; </span>container = av.<span class="hljs-built_in">open</span>(file_path)

<span class="hljs-meta">&gt;&gt;&gt; </span><span class="hljs-comment"># sample 8 frames</span>
<span class="hljs-meta">&gt;&gt;&gt; </span>indices = sample_frame_indices(clip_len=<span class="hljs-number">8</span>, frame_sample_rate=<span class="hljs-number">1</span>, seg_len=container.streams.video[<span class="hljs-number">0</span>].frames)
<span class="hljs-meta">&gt;&gt;&gt; </span>video = read_video_pyav(container, indices)

<span class="hljs-meta">&gt;&gt;&gt; </span>image_processor = AutoImageProcessor.from_pretrained(<span class="hljs-string">&quot;MCG-NJU/videomae-base-finetuned-kinetics&quot;</span>)
<span class="hljs-meta">&gt;&gt;&gt; </span>model = TimesformerForVideoClassification.from_pretrained(<span class="hljs-string">&quot;facebook/timesformer-base-finetuned-k400&quot;</span>)

<span class="hljs-meta">&gt;&gt;&gt; </span>inputs = image_processor(<span class="hljs-built_in">list</span>(video), return_tensors=<span class="hljs-string">&quot;pt&quot;</span>)

<span class="hljs-meta">&gt;&gt;&gt; </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">&gt;&gt;&gt; </span><span class="hljs-comment"># model predicts one of the 400 Kinetics-400 classes</span>
<span class="hljs-meta">&gt;&gt;&gt; </span>predicted_label = logits.argmax(-<span class="hljs-number">1</span>).item()
<span class="hljs-meta">&gt;&gt;&gt; </span><span class="hljs-built_in">print</span>(model.config.id2label[predicted_label])
eating spaghetti`}}),{c(){m=n("p"),T=l("Examples:"),M=u(),w(p.$$.fragment)},l(t){m=o(t,"P",{});var h=r(m);T=i(h,"Examples:"),h.forEach(a),M=g(t),_(p.$$.fragment,t)},m(t,h){f(t,m,h),s(m,T),f(t,M,h),b(p,t,h),y=!0},p:Ra,i(t){y||(j(p.$$.fragment,t),y=!0)},o(t){J(p.$$.fragment,t),y=!1},d(t){t&&a(m),t&&a(M),v(p,t)}}}function Nt(I){let m,T,M,p,y,t,h,W,ks,ls,V,R,Se,te,Bs,Ye,Es,is,S,Vs,ne,Gs,$s,cs,ve,As,ms,Ue,oe,Ns,re,Fs,zs,ds,Ie,xs,ps,Ze,Xs,fs,E,Rs,le,Ss,Ys,ie,Qs,Hs,hs,G,Y,Qe,ce,Ps,He,qs,us,Ce,Pe,We,Ls,gs,$,Q,qe,me,Ds,Le,Ks,Ms,U,de,Os,A,ea,ke,sa,aa,pe,ta,na,oa,N,ra,Be,la,ia,Ee,ca,ma,da,H,ys,F,P,De,fe,pa,Ke,fa,Ts,k,he,ha,ue,ua,ge,ga,Ma,ya,Z,Me,Ta,z,wa,Ve,_a,ba,Oe,ja,Ja,va,q,Ua,L,ws,x,D,es,ye,Ia,ss,Za,_s,B,Te,Ca,we,Wa,_e,ka,Ba,Ea,C,be,Va,X,Ga,Ge,$a,Aa,as,Na,Fa,za,K,xa,O,bs;return t=new Re({}),te=new Re({}),ce=new Re({}),me=new Re({}),de=new rs({props:{name:"class transformers.TimesformerConfig",anchor:"transformers.TimesformerConfig",parameters:[{name:"image_size",val:" = 224"},{name:"patch_size",val:" = 16"},{name:"num_channels",val:" = 3"},{name:"num_frames",val:" = 8"},{name:"hidden_size",val:" = 768"},{name:"num_hidden_layers",val:" = 12"},{name:"num_attention_heads",val:" = 12"},{name:"intermediate_size",val:" = 3072"},{name:"hidden_act",val:" = 'gelu'"},{name:"hidden_dropout_prob",val:" = 0.0"},{name:"attention_probs_dropout_prob",val:" = 0.0"},{name:"initializer_range",val:" = 0.02"},{name:"layer_norm_eps",val:" = 1e-06"},{name:"qkv_bias",val:" = True"},{name:"attention_type",val:" = 'divided_space_time'"},{name:"drop_path_rate",val:" = 0"},{name:"**kwargs",val:""}],parametersDescription:[{anchor:"transformers.TimesformerConfig.image_size",description:`<strong>image_size</strong> (<code>int</code>, <em>optional</em>, defaults to 224) &#x2014;
The size (resolution) of each image.`,name:"image_size"},{anchor:"transformers.TimesformerConfig.patch_size",description:`<strong>patch_size</strong> (<code>int</code>, <em>optional</em>, defaults to 16) &#x2014;
The size (resolution) of each patch.`,name:"patch_size"},{anchor:"transformers.TimesformerConfig.num_channels",description:`<strong>num_channels</strong> (<code>int</code>, <em>optional</em>, defaults to 3) &#x2014;
The number of input channels.`,name:"num_channels"},{anchor:"transformers.TimesformerConfig.num_frames",description:`<strong>num_frames</strong> (<code>int</code>, <em>optional</em>, defaults to 8) &#x2014;
The number of frames in each video.`,name:"num_frames"},{anchor:"transformers.TimesformerConfig.hidden_size",description:`<strong>hidden_size</strong> (<code>int</code>, <em>optional</em>, defaults to 768) &#x2014;
Dimensionality of the encoder layers and the pooler layer.`,name:"hidden_size"},{anchor:"transformers.TimesformerConfig.num_hidden_layers",description:`<strong>num_hidden_layers</strong> (<code>int</code>, <em>optional</em>, defaults to 12) &#x2014;
Number of hidden layers in the Transformer encoder.`,name:"num_hidden_layers"},{anchor:"transformers.TimesformerConfig.num_attention_heads",description:`<strong>num_attention_heads</strong> (<code>int</code>, <em>optional</em>, defaults to 12) &#x2014;
Number of attention heads for each attention layer in the Transformer encoder.`,name:"num_attention_heads"},{anchor:"transformers.TimesformerConfig.intermediate_size",description:`<strong>intermediate_size</strong> (<code>int</code>, <em>optional</em>, defaults to 3072) &#x2014;
Dimensionality of the &#x201C;intermediate&#x201D; (i.e., feed-forward) layer in the Transformer encoder.`,name:"intermediate_size"},{anchor:"transformers.TimesformerConfig.hidden_act",description:`<strong>hidden_act</strong> (<code>str</code> or <code>function</code>, <em>optional</em>, defaults to <code>&quot;gelu&quot;</code>) &#x2014;
The non-linear activation function (function or string) in the encoder and pooler. If string, <code>&quot;gelu&quot;</code>,
<code>&quot;relu&quot;</code>, <code>&quot;selu&quot;</code> and <code>&quot;gelu_new&quot;</code> are supported.`,name:"hidden_act"},{anchor:"transformers.TimesformerConfig.hidden_dropout_prob",description:`<strong>hidden_dropout_prob</strong> (<code>float</code>, <em>optional</em>, defaults to 0.0) &#x2014;
The dropout probabilitiy for all fully connected layers in the embeddings, encoder, and pooler.`,name:"hidden_dropout_prob"},{anchor:"transformers.TimesformerConfig.attention_probs_dropout_prob",description:`<strong>attention_probs_dropout_prob</strong> (<code>float</code>, <em>optional</em>, defaults to 0.0) &#x2014;
The dropout ratio for the attention probabilities.`,name:"attention_probs_dropout_prob"},{anchor:"transformers.TimesformerConfig.initializer_range",description:`<strong>initializer_range</strong> (<code>float</code>, <em>optional</em>, defaults to 0.02) &#x2014;
The standard deviation of the truncated_normal_initializer for initializing all weight matrices.`,name:"initializer_range"},{anchor:"transformers.TimesformerConfig.layer_norm_eps",description:`<strong>layer_norm_eps</strong> (<code>float</code>, <em>optional</em>, defaults to 1e-6) &#x2014;
The epsilon used by the layer normalization layers.`,name:"layer_norm_eps"},{anchor:"transformers.TimesformerConfig.qkv_bias",description:`<strong>qkv_bias</strong> (<code>bool</code>, <em>optional</em>, defaults to <code>True</code>) &#x2014;
Whether to add a bias to the queries, keys and values.`,name:"qkv_bias"},{anchor:"transformers.TimesformerConfig.attention_type",description:`<strong>attention_type</strong> (<code>str</code>, <em>optional</em>, defaults to <code>&quot;divided_space_time&quot;</code>) &#x2014;
The attention type to use. Must be one of <code>&quot;divided_space_time&quot;</code>, <code>&quot;space_only&quot;</code>, <code>&quot;joint_space_time&quot;</code>.`,name:"attention_type"},{anchor:"transformers.TimesformerConfig.drop_path_rate",description:`<strong>drop_path_rate</strong> (<code>float</code>, <em>optional</em>, defaults to 0) &#x2014;
The dropout ratio for stochastic depth.`,name:"drop_path_rate"}],source:"https://github.com/huggingface/transformers/blob/main/src/transformers/models/timesformer/configuration_timesformer.py#L28"}}),H=new Xa({props:{anchor:"transformers.TimesformerConfig.example",$$slots:{default:[Et]},$$scope:{ctx:I}}}),fe=new Re({}),he=new rs({props:{name:"class transformers.TimesformerModel",anchor:"transformers.TimesformerModel",parameters:[{name:"config",val:""}],parametersDescription:[{anchor:"transformers.TimesformerModel.config",description:`<strong>config</strong> (<a href="/docs/transformers/main/en/model_doc/timesformer#transformers.TimesformerConfig">TimesformerConfig</a>) &#x2014; Model configuration class with all the parameters of the model.
Initializing with a config file does not load the weights associated with the model, only the
configuration. Check out the <a href="/docs/transformers/main/en/main_classes/model#transformers.PreTrainedModel.from_pretrained">from_pretrained()</a> method to load the model weights.`,name:"config"}],source:"https://github.com/huggingface/transformers/blob/main/src/transformers/models/timesformer/modeling_timesformer.py#L534"}}),Me=new rs({props:{name:"forward",anchor:"transformers.TimesformerModel.forward",parameters:[{name:"pixel_values",val:""},{name:"output_attentions",val:" = None"},{name:"output_hidden_states",val:" = None"},{name:"return_dict",val:" = None"}],parametersDescription:[{anchor:"transformers.TimesformerModel.forward.pixel_values",description:`<strong>pixel_values</strong> (<code>torch.FloatTensor</code> of shape <code>(batch_size, num_frames, num_channels, height, width)</code>) &#x2014;
Pixel values. Pixel values can be obtained using <a href="/docs/transformers/main/en/model_doc/auto#transformers.AutoImageProcessor">AutoImageProcessor</a>. See
<a href="/docs/transformers/main/en/model_doc/videomae#transformers.VideoMAEImageProcessor.preprocess">VideoMAEImageProcessor.preprocess()</a> for details.`,name:"pixel_values"},{anchor:"transformers.TimesformerModel.forward.output_attentions",description:`<strong>output_attentions</strong> (<code>bool</code>, <em>optional</em>) &#x2014;
Whether or not to return the attentions tensors of all attention layers. See <code>attentions</code> under returned
tensors for more detail.`,name:"output_attentions"},{anchor:"transformers.TimesformerModel.forward.output_hidden_states",description:`<strong>output_hidden_states</strong> (<code>bool</code>, <em>optional</em>) &#x2014;
Whether or not to return the hidden states of all layers. See <code>hidden_states</code> under returned tensors for
more detail.`,name:"output_hidden_states"},{anchor:"transformers.TimesformerModel.forward.return_dict",description:`<strong>return_dict</strong> (<code>bool</code>, <em>optional</em>) &#x2014;
Whether or not to return a <a href="/docs/transformers/main/en/main_classes/output#transformers.utils.ModelOutput">ModelOutput</a> instead of a plain tuple.`,name:"return_dict"}],source:"https://github.com/huggingface/transformers/blob/main/src/transformers/models/timesformer/modeling_timesformer.py#L558",returnDescription:`
<p>A <a
  href="/docs/transformers/main/en/main_classes/output#transformers.modeling_outputs.BaseModelOutput"
>transformers.modeling_outputs.BaseModelOutput</a> or a tuple of
<code>torch.FloatTensor</code> (if <code>return_dict=False</code> is passed or when <code>config.return_dict=False</code>) comprising various
elements depending on the configuration (<a
  href="/docs/transformers/main/en/model_doc/timesformer#transformers.TimesformerConfig"
>TimesformerConfig</a>) and inputs.</p>
<ul>
<li>
<p><strong>last_hidden_state</strong> (<code>torch.FloatTensor</code> of shape <code>(batch_size, sequence_length, hidden_size)</code>) \u2014 Sequence of hidden-states at the output of the last layer of the model.</p>
</li>
<li>
<p><strong>hidden_states</strong> (<code>tuple(torch.FloatTensor)</code>, <em>optional</em>, returned when <code>output_hidden_states=True</code> is passed or when <code>config.output_hidden_states=True</code>) \u2014 Tuple of <code>torch.FloatTensor</code> (one for the output of the embeddings, if the model has an embedding layer, +
one for the output of each layer) of shape <code>(batch_size, sequence_length, hidden_size)</code>.</p>
<p>Hidden-states of the model at the output of each layer plus the optional initial embedding outputs.</p>
</li>
<li>
<p><strong>attentions</strong> (<code>tuple(torch.FloatTensor)</code>, <em>optional</em>, returned when <code>output_attentions=True</code> is passed or when <code>config.output_attentions=True</code>) \u2014 Tuple of <code>torch.FloatTensor</code> (one for each layer) of shape <code>(batch_size, num_heads, sequence_length, sequence_length)</code>.</p>
<p>Attentions weights after the attention softmax, used to compute the weighted average in the self-attention
heads.</p>
</li>
</ul>
`,returnType:`
<p><a
  href="/docs/transformers/main/en/main_classes/output#transformers.modeling_outputs.BaseModelOutput"
>transformers.modeling_outputs.BaseModelOutput</a> or <code>tuple(torch.FloatTensor)</code></p>
`}}),q=new It({props:{$$slots:{default:[Vt]},$$scope:{ctx:I}}}),L=new Xa({props:{anchor:"transformers.TimesformerModel.forward.example",$$slots:{default:[Gt]},$$scope:{ctx:I}}}),ye=new Re({}),Te=new rs({props:{name:"class transformers.TimesformerForVideoClassification",anchor:"transformers.TimesformerForVideoClassification",parameters:[{name:"config",val:""}],parametersDescription:[{anchor:"transformers.TimesformerForVideoClassification.config",description:`<strong>config</strong> (<a href="/docs/transformers/main/en/model_doc/timesformer#transformers.TimesformerConfig">TimesformerConfig</a>) &#x2014; Model configuration class with all the parameters of the model.
Initializing with a config file does not load the weights associated with the model, only the
configuration. Check out the <a href="/docs/transformers/main/en/main_classes/model#transformers.PreTrainedModel.from_pretrained">from_pretrained()</a> method to load the model weights.`,name:"config"}],source:"https://github.com/huggingface/transformers/blob/main/src/transformers/models/timesformer/modeling_timesformer.py#L667"}}),be=new rs({props:{name:"forward",anchor:"transformers.TimesformerForVideoClassification.forward",parameters:[{name:"pixel_values",val:": typing.Optional[torch.Tensor] = None"},{name:"labels",val:": typing.Optional[torch.Tensor] = None"},{name:"output_attentions",val:": typing.Optional[bool] = None"},{name:"output_hidden_states",val:": typing.Optional[bool] = None"},{name:"return_dict",val:": typing.Optional[bool] = None"}],parametersDescription:[{anchor:"transformers.TimesformerForVideoClassification.forward.pixel_values",description:`<strong>pixel_values</strong> (<code>torch.FloatTensor</code> of shape <code>(batch_size, num_frames, num_channels, height, width)</code>) &#x2014;
Pixel values. Pixel values can be obtained using <a href="/docs/transformers/main/en/model_doc/auto#transformers.AutoImageProcessor">AutoImageProcessor</a>. See
<a href="/docs/transformers/main/en/model_doc/videomae#transformers.VideoMAEImageProcessor.preprocess">VideoMAEImageProcessor.preprocess()</a> for details.`,name:"pixel_values"},{anchor:"transformers.TimesformerForVideoClassification.forward.output_attentions",description:`<strong>output_attentions</strong> (<code>bool</code>, <em>optional</em>) &#x2014;
Whether or not to return the attentions tensors of all attention layers. See <code>attentions</code> under returned
tensors for more detail.`,name:"output_attentions"},{anchor:"transformers.TimesformerForVideoClassification.forward.output_hidden_states",description:`<strong>output_hidden_states</strong> (<code>bool</code>, <em>optional</em>) &#x2014;
Whether or not to return the hidden states of all layers. See <code>hidden_states</code> under returned tensors for
more detail.`,name:"output_hidden_states"},{anchor:"transformers.TimesformerForVideoClassification.forward.return_dict",description:`<strong>return_dict</strong> (<code>bool</code>, <em>optional</em>) &#x2014;
Whether or not to return a <a href="/docs/transformers/main/en/main_classes/output#transformers.utils.ModelOutput">ModelOutput</a> instead of a plain tuple.`,name:"return_dict"},{anchor:"transformers.TimesformerForVideoClassification.forward.labels",description:`<strong>labels</strong> (<code>torch.LongTensor</code> of shape <code>(batch_size,)</code>, <em>optional</em>) &#x2014;
Labels for computing the image classification/regression loss. Indices should be in <code>[0, ..., config.num_labels - 1]</code>. If <code>config.num_labels == 1</code> a regression loss is computed (Mean-Square loss), If
<code>config.num_labels &gt; 1</code> a classification loss is computed (Cross-Entropy).`,name:"labels"}],source:"https://github.com/huggingface/transformers/blob/main/src/transformers/models/timesformer/modeling_timesformer.py#L680",returnDescription:`
<p>A <a
  href="/docs/transformers/main/en/main_classes/output#transformers.modeling_outputs.ImageClassifierOutput"
>transformers.modeling_outputs.ImageClassifierOutput</a> or a tuple of
<code>torch.FloatTensor</code> (if <code>return_dict=False</code> is passed or when <code>config.return_dict=False</code>) comprising various
elements depending on the configuration (<a
  href="/docs/transformers/main/en/model_doc/timesformer#transformers.TimesformerConfig"
>TimesformerConfig</a>) and inputs.</p>
<ul>
<li>
<p><strong>loss</strong> (<code>torch.FloatTensor</code> of shape <code>(1,)</code>, <em>optional</em>, returned when <code>labels</code> is provided) \u2014 Classification (or regression if config.num_labels==1) loss.</p>
</li>
<li>
<p><strong>logits</strong> (<code>torch.FloatTensor</code> of shape <code>(batch_size, config.num_labels)</code>) \u2014 Classification (or regression if config.num_labels==1) scores (before SoftMax).</p>
</li>
<li>
<p><strong>hidden_states</strong> (<code>tuple(torch.FloatTensor)</code>, <em>optional</em>, returned when <code>output_hidden_states=True</code> is passed or when <code>config.output_hidden_states=True</code>) \u2014 Tuple of <code>torch.FloatTensor</code> (one for the output of the embeddings, if the model has an embedding layer, +
one for the output of each stage) of shape <code>(batch_size, sequence_length, hidden_size)</code>. Hidden-states
(also called feature maps) of the model at the output of each stage.</p>
</li>
<li>
<p><strong>attentions</strong> (<code>tuple(torch.FloatTensor)</code>, <em>optional</em>, returned when <code>output_attentions=True</code> is passed or when <code>config.output_attentions=True</code>) \u2014 Tuple of <code>torch.FloatTensor</code> (one for each layer) of shape <code>(batch_size, num_heads, patch_size, sequence_length)</code>.</p>
<p>Attentions weights after the attention softmax, used to compute the weighted average in the self-attention
heads.</p>
</li>
</ul>
`,returnType:`
<p><a
  href="/docs/transformers/main/en/main_classes/output#transformers.modeling_outputs.ImageClassifierOutput"
>transformers.modeling_outputs.ImageClassifierOutput</a> or <code>tuple(torch.FloatTensor)</code></p>
`}}),K=new It({props:{$$slots:{default:[$t]},$$scope:{ctx:I}}}),O=new Xa({props:{anchor:"transformers.TimesformerForVideoClassification.forward.example",$$slots:{default:[At]},$$scope:{ctx:I}}}),{c(){m=n("meta"),T=u(),M=n("h1"),p=n("a"),y=n("span"),w(t.$$.fragment),h=u(),W=n("span"),ks=l("TimeSformer"),ls=u(),V=n("h2"),R=n("a"),Se=n("span"),w(te.$$.fragment),Bs=u(),Ye=n("span"),Es=l("Overview"),is=u(),S=n("p"),Vs=l("The TimeSformer model was proposed in "),ne=n("a"),Gs=l("TimeSformer: Is Space-Time Attention All You Need for Video Understanding?"),$s=l(` by Facebook Research.
This work is a milestone in action-recognition field being the first video transformer. It inspired many transformer based video understanding and classification papers.`),cs=u(),ve=n("p"),As=l("The abstract from the paper is the following:"),ms=u(),Ue=n("p"),oe=n("em"),Ns=l("We present a convolution-free approach to video classification built exclusively on self-attention over space and time. Our method, named \u201CTimeSformer,\u201D adapts the standard Transformer architecture to video by enabling spatiotemporal feature learning directly from a sequence of frame-level patches. Our experimental study compares different self-attention schemes and suggests that \u201Cdivided attention,\u201D where temporal attention and spatial attention are separately applied within each block, leads to the best video classification accuracy among the design choices considered. Despite the radically new design, TimeSformer achieves state-of-the-art results on several action recognition benchmarks, including the best reported accuracy on Kinetics-400 and Kinetics-600. Finally, compared to 3D convolutional networks, our model is faster to train, it can achieve dramatically higher test efficiency (at a small drop in accuracy), and it can also be applied to much longer video clips (over one minute long). Code and models are available at: "),re=n("a"),Fs=l("this https URL"),zs=l("."),ds=u(),Ie=n("p"),xs=l("Tips:"),ps=u(),Ze=n("p"),Xs=l("There are many pretrained variants. Select your pretrained model based on the dataset it is trained on. Moreover, the number of input frames per clip changes based on the model size so you should consider this parameter while selecting your pretrained model."),fs=u(),E=n("p"),Rs=l("This model was contributed by "),le=n("a"),Ss=l("fcakyon"),Ys=l(`.
The original code can be found `),ie=n("a"),Qs=l("here"),Hs=l("."),hs=u(),G=n("h2"),Y=n("a"),Qe=n("span"),w(ce.$$.fragment),Ps=u(),He=n("span"),qs=l("Documentation resources"),us=u(),Ce=n("ul"),Pe=n("li"),We=n("a"),Ls=l("Video classification task guide"),gs=u(),$=n("h2"),Q=n("a"),qe=n("span"),w(me.$$.fragment),Ds=u(),Le=n("span"),Ks=l("TimesformerConfig"),Ms=u(),U=n("div"),w(de.$$.fragment),Os=u(),A=n("p"),ea=l("This is the configuration class to store the configuration of a "),ke=n("a"),sa=l("TimesformerModel"),aa=l(`. It is used to instantiate a
TimeSformer model according to the specified arguments, defining the model architecture. Instantiating a
configuration with the defaults will yield a similar configuration to that of the TimeSformer
`),pe=n("a"),ta=l("facebook/timesformer-base-finetuned-k600"),na=l(`
architecture.`),oa=u(),N=n("p"),ra=l("Configuration objects inherit from "),Be=n("a"),la=l("PretrainedConfig"),ia=l(` and can be used to control the model outputs. Read the
documentation from `),Ee=n("a"),ca=l("PretrainedConfig"),ma=l(" for more information."),da=u(),w(H.$$.fragment),ys=u(),F=n("h2"),P=n("a"),De=n("span"),w(fe.$$.fragment),pa=u(),Ke=n("span"),fa=l("TimesformerModel"),Ts=u(),k=n("div"),w(he.$$.fragment),ha=u(),ue=n("p"),ua=l(`The bare TimeSformer Model transformer outputting raw hidden-states without any specific head on top.
This model is a PyTorch `),ge=n("a"),ga=l("torch.nn.Module"),Ma=l(` subclass. Use it
as a regular PyTorch Module and refer to the PyTorch documentation for all matter related to general usage and
behavior.`),ya=u(),Z=n("div"),w(Me.$$.fragment),Ta=u(),z=n("p"),wa=l("The "),Ve=n("a"),_a=l("TimesformerModel"),ba=l(" forward method, overrides the "),Oe=n("code"),ja=l("__call__"),Ja=l(" special method."),va=u(),w(q.$$.fragment),Ua=u(),w(L.$$.fragment),ws=u(),x=n("h2"),D=n("a"),es=n("span"),w(ye.$$.fragment),Ia=u(),ss=n("span"),Za=l("TimesformerForVideoClassification"),_s=u(),B=n("div"),w(Te.$$.fragment),Ca=u(),we=n("p"),Wa=l(`TimeSformer Model transformer with a video classification head on top (a linear layer on top of the final hidden state
of the [CLS] token) e.g. for ImageNet.
This model is a PyTorch `),_e=n("a"),ka=l("torch.nn.Module"),Ba=l(` subclass. Use it
as a regular PyTorch Module and refer to the PyTorch documentation for all matter related to general usage and
behavior.`),Ea=u(),C=n("div"),w(be.$$.fragment),Va=u(),X=n("p"),Ga=l("The "),Ge=n("a"),$a=l("TimesformerForVideoClassification"),Aa=l(" forward method, overrides the "),as=n("code"),Na=l("__call__"),Fa=l(" special method."),za=u(),w(K.$$.fragment),xa=u(),w(O.$$.fragment),this.h()},l(e){const d=kt('[data-svelte="svelte-1phssyn"]',document.head);m=o(d,"META",{name:!0,content:!0}),d.forEach(a),T=g(e),M=o(e,"H1",{class:!0});var je=r(M);p=o(je,"A",{id:!0,class:!0,href:!0});var ts=r(p);y=o(ts,"SPAN",{});var ns=r(y);_(t.$$.fragment,ns),ns.forEach(a),ts.forEach(a),h=g(je),W=o(je,"SPAN",{});var os=r(W);ks=i(os,"TimeSformer"),os.forEach(a),je.forEach(a),ls=g(e),V=o(e,"H2",{class:!0});var Je=r(V);R=o(Je,"A",{id:!0,class:!0,href:!0});var Ya=r(R);Se=o(Ya,"SPAN",{});var Qa=r(Se);_(te.$$.fragment,Qa),Qa.forEach(a),Ya.forEach(a),Bs=g(Je),Ye=o(Je,"SPAN",{});var Ha=r(Ye);Es=i(Ha,"Overview"),Ha.forEach(a),Je.forEach(a),is=g(e),S=o(e,"P",{});var js=r(S);Vs=i(js,"The TimeSformer model was proposed in "),ne=o(js,"A",{href:!0,rel:!0});var Pa=r(ne);Gs=i(Pa,"TimeSformer: Is Space-Time Attention All You Need for Video Understanding?"),Pa.forEach(a),$s=i(js,` by Facebook Research.
This work is a milestone in action-recognition field being the first video transformer. It inspired many transformer based video understanding and classification papers.`),js.forEach(a),cs=g(e),ve=o(e,"P",{});var qa=r(ve);As=i(qa,"The abstract from the paper is the following:"),qa.forEach(a),ms=g(e),Ue=o(e,"P",{});var La=r(Ue);oe=o(La,"EM",{});var Js=r(oe);Ns=i(Js,"We present a convolution-free approach to video classification built exclusively on self-attention over space and time. Our method, named \u201CTimeSformer,\u201D adapts the standard Transformer architecture to video by enabling spatiotemporal feature learning directly from a sequence of frame-level patches. Our experimental study compares different self-attention schemes and suggests that \u201Cdivided attention,\u201D where temporal attention and spatial attention are separately applied within each block, leads to the best video classification accuracy among the design choices considered. Despite the radically new design, TimeSformer achieves state-of-the-art results on several action recognition benchmarks, including the best reported accuracy on Kinetics-400 and Kinetics-600. Finally, compared to 3D convolutional networks, our model is faster to train, it can achieve dramatically higher test efficiency (at a small drop in accuracy), and it can also be applied to much longer video clips (over one minute long). Code and models are available at: "),re=o(Js,"A",{href:!0,rel:!0});var Da=r(re);Fs=i(Da,"this https URL"),Da.forEach(a),zs=i(Js,"."),Js.forEach(a),La.forEach(a),ds=g(e),Ie=o(e,"P",{});var Ka=r(Ie);xs=i(Ka,"Tips:"),Ka.forEach(a),ps=g(e),Ze=o(e,"P",{});var Oa=r(Ze);Xs=i(Oa,"There are many pretrained variants. Select your pretrained model based on the dataset it is trained on. Moreover, the number of input frames per clip changes based on the model size so you should consider this parameter while selecting your pretrained model."),Oa.forEach(a),fs=g(e),E=o(e,"P",{});var $e=r(E);Rs=i($e,"This model was contributed by "),le=o($e,"A",{href:!0,rel:!0});var et=r(le);Ss=i(et,"fcakyon"),et.forEach(a),Ys=i($e,`.
The original code can be found `),ie=o($e,"A",{href:!0,rel:!0});var st=r(ie);Qs=i(st,"here"),st.forEach(a),Hs=i($e,"."),$e.forEach(a),hs=g(e),G=o(e,"H2",{class:!0});var vs=r(G);Y=o(vs,"A",{id:!0,class:!0,href:!0});var at=r(Y);Qe=o(at,"SPAN",{});var tt=r(Qe);_(ce.$$.fragment,tt),tt.forEach(a),at.forEach(a),Ps=g(vs),He=o(vs,"SPAN",{});var nt=r(He);qs=i(nt,"Documentation resources"),nt.forEach(a),vs.forEach(a),us=g(e),Ce=o(e,"UL",{});var ot=r(Ce);Pe=o(ot,"LI",{});var rt=r(Pe);We=o(rt,"A",{href:!0});var lt=r(We);Ls=i(lt,"Video classification task guide"),lt.forEach(a),rt.forEach(a),ot.forEach(a),gs=g(e),$=o(e,"H2",{class:!0});var Us=r($);Q=o(Us,"A",{id:!0,class:!0,href:!0});var it=r(Q);qe=o(it,"SPAN",{});var ct=r(qe);_(me.$$.fragment,ct),ct.forEach(a),it.forEach(a),Ds=g(Us),Le=o(Us,"SPAN",{});var mt=r(Le);Ks=i(mt,"TimesformerConfig"),mt.forEach(a),Us.forEach(a),Ms=g(e),U=o(e,"DIV",{class:!0});var ee=r(U);_(de.$$.fragment,ee),Os=g(ee),A=o(ee,"P",{});var Ae=r(A);ea=i(Ae,"This is the configuration class to store the configuration of a "),ke=o(Ae,"A",{href:!0});var dt=r(ke);sa=i(dt,"TimesformerModel"),dt.forEach(a),aa=i(Ae,`. It is used to instantiate a
TimeSformer model according to the specified arguments, defining the model architecture. Instantiating a
configuration with the defaults will yield a similar configuration to that of the TimeSformer
`),pe=o(Ae,"A",{href:!0,rel:!0});var pt=r(pe);ta=i(pt,"facebook/timesformer-base-finetuned-k600"),pt.forEach(a),na=i(Ae,`
architecture.`),Ae.forEach(a),oa=g(ee),N=o(ee,"P",{});var Ne=r(N);ra=i(Ne,"Configuration objects inherit from "),Be=o(Ne,"A",{href:!0});var ft=r(Be);la=i(ft,"PretrainedConfig"),ft.forEach(a),ia=i(Ne,` and can be used to control the model outputs. Read the
documentation from `),Ee=o(Ne,"A",{href:!0});var ht=r(Ee);ca=i(ht,"PretrainedConfig"),ht.forEach(a),ma=i(Ne," for more information."),Ne.forEach(a),da=g(ee),_(H.$$.fragment,ee),ee.forEach(a),ys=g(e),F=o(e,"H2",{class:!0});var Is=r(F);P=o(Is,"A",{id:!0,class:!0,href:!0});var ut=r(P);De=o(ut,"SPAN",{});var gt=r(De);_(fe.$$.fragment,gt),gt.forEach(a),ut.forEach(a),pa=g(Is),Ke=o(Is,"SPAN",{});var Mt=r(Ke);fa=i(Mt,"TimesformerModel"),Mt.forEach(a),Is.forEach(a),Ts=g(e),k=o(e,"DIV",{class:!0});var Fe=r(k);_(he.$$.fragment,Fe),ha=g(Fe),ue=o(Fe,"P",{});var Zs=r(ue);ua=i(Zs,`The bare TimeSformer Model transformer outputting raw hidden-states without any specific head on top.
This model is a PyTorch `),ge=o(Zs,"A",{href:!0,rel:!0});var yt=r(ge);ga=i(yt,"torch.nn.Module"),yt.forEach(a),Ma=i(Zs,` subclass. Use it
as a regular PyTorch Module and refer to the PyTorch documentation for all matter related to general usage and
behavior.`),Zs.forEach(a),ya=g(Fe),Z=o(Fe,"DIV",{class:!0});var se=r(Z);_(Me.$$.fragment,se),Ta=g(se),z=o(se,"P",{});var ze=r(z);wa=i(ze,"The "),Ve=o(ze,"A",{href:!0});var Tt=r(Ve);_a=i(Tt,"TimesformerModel"),Tt.forEach(a),ba=i(ze," forward method, overrides the "),Oe=o(ze,"CODE",{});var wt=r(Oe);ja=i(wt,"__call__"),wt.forEach(a),Ja=i(ze," special method."),ze.forEach(a),va=g(se),_(q.$$.fragment,se),Ua=g(se),_(L.$$.fragment,se),se.forEach(a),Fe.forEach(a),ws=g(e),x=o(e,"H2",{class:!0});var Cs=r(x);D=o(Cs,"A",{id:!0,class:!0,href:!0});var _t=r(D);es=o(_t,"SPAN",{});var bt=r(es);_(ye.$$.fragment,bt),bt.forEach(a),_t.forEach(a),Ia=g(Cs),ss=o(Cs,"SPAN",{});var jt=r(ss);Za=i(jt,"TimesformerForVideoClassification"),jt.forEach(a),Cs.forEach(a),_s=g(e),B=o(e,"DIV",{class:!0});var xe=r(B);_(Te.$$.fragment,xe),Ca=g(xe),we=o(xe,"P",{});var Ws=r(we);Wa=i(Ws,`TimeSformer Model transformer with a video classification head on top (a linear layer on top of the final hidden state
of the [CLS] token) e.g. for ImageNet.
This model is a PyTorch `),_e=o(Ws,"A",{href:!0,rel:!0});var Jt=r(_e);ka=i(Jt,"torch.nn.Module"),Jt.forEach(a),Ba=i(Ws,` subclass. Use it
as a regular PyTorch Module and refer to the PyTorch documentation for all matter related to general usage and
behavior.`),Ws.forEach(a),Ea=g(xe),C=o(xe,"DIV",{class:!0});var ae=r(C);_(be.$$.fragment,ae),Va=g(ae),X=o(ae,"P",{});var Xe=r(X);Ga=i(Xe,"The "),Ge=o(Xe,"A",{href:!0});var vt=r(Ge);$a=i(vt,"TimesformerForVideoClassification"),vt.forEach(a),Aa=i(Xe," forward method, overrides the "),as=o(Xe,"CODE",{});var Ut=r(as);Na=i(Ut,"__call__"),Ut.forEach(a),Fa=i(Xe," special method."),Xe.forEach(a),za=g(ae),_(K.$$.fragment,ae),xa=g(ae),_(O.$$.fragment,ae),ae.forEach(a),xe.forEach(a),this.h()},h(){c(m,"name","hf:doc:metadata"),c(m,"content",JSON.stringify(Ft)),c(p,"id","timesformer"),c(p,"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"),c(p,"href","#timesformer"),c(M,"class","relative group"),c(R,"id","overview"),c(R,"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"),c(R,"href","#overview"),c(V,"class","relative group"),c(ne,"href","https://arxiv.org/abs/2102.05095"),c(ne,"rel","nofollow"),c(re,"href","https://github.com/facebookresearch/TimeSformer"),c(re,"rel","nofollow"),c(le,"href","https://huggingface.co/fcakyon"),c(le,"rel","nofollow"),c(ie,"href","https://github.com/facebookresearch/TimeSformer"),c(ie,"rel","nofollow"),c(Y,"id","documentation-resources"),c(Y,"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"),c(Y,"href","#documentation-resources"),c(G,"class","relative group"),c(We,"href","../tasks/video_classification"),c(Q,"id","transformers.TimesformerConfig"),c(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"),c(Q,"href","#transformers.TimesformerConfig"),c($,"class","relative group"),c(ke,"href","/docs/transformers/main/en/model_doc/timesformer#transformers.TimesformerModel"),c(pe,"href","https://huggingface.co/facebook/timesformer-base-finetuned-k600"),c(pe,"rel","nofollow"),c(Be,"href","/docs/transformers/main/en/main_classes/configuration#transformers.PretrainedConfig"),c(Ee,"href","/docs/transformers/main/en/main_classes/configuration#transformers.PretrainedConfig"),c(U,"class","docstring border-l-2 border-t-2 pl-4 pt-3.5 border-gray-100 rounded-tl-xl mb-6 mt-8"),c(P,"id","transformers.TimesformerModel"),c(P,"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"),c(P,"href","#transformers.TimesformerModel"),c(F,"class","relative group"),c(ge,"href","https://pytorch.org/docs/stable/nn.html#torch.nn.Module"),c(ge,"rel","nofollow"),c(Ve,"href","/docs/transformers/main/en/model_doc/timesformer#transformers.TimesformerModel"),c(Z,"class","docstring border-l-2 border-t-2 pl-4 pt-3.5 border-gray-100 rounded-tl-xl mb-6 mt-8"),c(k,"class","docstring border-l-2 border-t-2 pl-4 pt-3.5 border-gray-100 rounded-tl-xl mb-6 mt-8"),c(D,"id","transformers.TimesformerForVideoClassification"),c(D,"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"),c(D,"href","#transformers.TimesformerForVideoClassification"),c(x,"class","relative group"),c(_e,"href","https://pytorch.org/docs/stable/nn.html#torch.nn.Module"),c(_e,"rel","nofollow"),c(Ge,"href","/docs/transformers/main/en/model_doc/timesformer#transformers.TimesformerForVideoClassification"),c(C,"class","docstring border-l-2 border-t-2 pl-4 pt-3.5 border-gray-100 rounded-tl-xl mb-6 mt-8"),c(B,"class","docstring border-l-2 border-t-2 pl-4 pt-3.5 border-gray-100 rounded-tl-xl mb-6 mt-8")},m(e,d){s(document.head,m),f(e,T,d),f(e,M,d),s(M,p),s(p,y),b(t,y,null),s(M,h),s(M,W),s(W,ks),f(e,ls,d),f(e,V,d),s(V,R),s(R,Se),b(te,Se,null),s(V,Bs),s(V,Ye),s(Ye,Es),f(e,is,d),f(e,S,d),s(S,Vs),s(S,ne),s(ne,Gs),s(S,$s),f(e,cs,d),f(e,ve,d),s(ve,As),f(e,ms,d),f(e,Ue,d),s(Ue,oe),s(oe,Ns),s(oe,re),s(re,Fs),s(oe,zs),f(e,ds,d),f(e,Ie,d),s(Ie,xs),f(e,ps,d),f(e,Ze,d),s(Ze,Xs),f(e,fs,d),f(e,E,d),s(E,Rs),s(E,le),s(le,Ss),s(E,Ys),s(E,ie),s(ie,Qs),s(E,Hs),f(e,hs,d),f(e,G,d),s(G,Y),s(Y,Qe),b(ce,Qe,null),s(G,Ps),s(G,He),s(He,qs),f(e,us,d),f(e,Ce,d),s(Ce,Pe),s(Pe,We),s(We,Ls),f(e,gs,d),f(e,$,d),s($,Q),s(Q,qe),b(me,qe,null),s($,Ds),s($,Le),s(Le,Ks),f(e,Ms,d),f(e,U,d),b(de,U,null),s(U,Os),s(U,A),s(A,ea),s(A,ke),s(ke,sa),s(A,aa),s(A,pe),s(pe,ta),s(A,na),s(U,oa),s(U,N),s(N,ra),s(N,Be),s(Be,la),s(N,ia),s(N,Ee),s(Ee,ca),s(N,ma),s(U,da),b(H,U,null),f(e,ys,d),f(e,F,d),s(F,P),s(P,De),b(fe,De,null),s(F,pa),s(F,Ke),s(Ke,fa),f(e,Ts,d),f(e,k,d),b(he,k,null),s(k,ha),s(k,ue),s(ue,ua),s(ue,ge),s(ge,ga),s(ue,Ma),s(k,ya),s(k,Z),b(Me,Z,null),s(Z,Ta),s(Z,z),s(z,wa),s(z,Ve),s(Ve,_a),s(z,ba),s(z,Oe),s(Oe,ja),s(z,Ja),s(Z,va),b(q,Z,null),s(Z,Ua),b(L,Z,null),f(e,ws,d),f(e,x,d),s(x,D),s(D,es),b(ye,es,null),s(x,Ia),s(x,ss),s(ss,Za),f(e,_s,d),f(e,B,d),b(Te,B,null),s(B,Ca),s(B,we),s(we,Wa),s(we,_e),s(_e,ka),s(we,Ba),s(B,Ea),s(B,C),b(be,C,null),s(C,Va),s(C,X),s(X,Ga),s(X,Ge),s(Ge,$a),s(X,Aa),s(X,as),s(as,Na),s(X,Fa),s(C,za),b(K,C,null),s(C,xa),b(O,C,null),bs=!0},p(e,[d]){const je={};d&2&&(je.$$scope={dirty:d,ctx:e}),H.$set(je);const ts={};d&2&&(ts.$$scope={dirty:d,ctx:e}),q.$set(ts);const ns={};d&2&&(ns.$$scope={dirty:d,ctx:e}),L.$set(ns);const os={};d&2&&(os.$$scope={dirty:d,ctx:e}),K.$set(os);const Je={};d&2&&(Je.$$scope={dirty:d,ctx:e}),O.$set(Je)},i(e){bs||(j(t.$$.fragment,e),j(te.$$.fragment,e),j(ce.$$.fragment,e),j(me.$$.fragment,e),j(de.$$.fragment,e),j(H.$$.fragment,e),j(fe.$$.fragment,e),j(he.$$.fragment,e),j(Me.$$.fragment,e),j(q.$$.fragment,e),j(L.$$.fragment,e),j(ye.$$.fragment,e),j(Te.$$.fragment,e),j(be.$$.fragment,e),j(K.$$.fragment,e),j(O.$$.fragment,e),bs=!0)},o(e){J(t.$$.fragment,e),J(te.$$.fragment,e),J(ce.$$.fragment,e),J(me.$$.fragment,e),J(de.$$.fragment,e),J(H.$$.fragment,e),J(fe.$$.fragment,e),J(he.$$.fragment,e),J(Me.$$.fragment,e),J(q.$$.fragment,e),J(L.$$.fragment,e),J(ye.$$.fragment,e),J(Te.$$.fragment,e),J(be.$$.fragment,e),J(K.$$.fragment,e),J(O.$$.fragment,e),bs=!1},d(e){a(m),e&&a(T),e&&a(M),v(t),e&&a(ls),e&&a(V),v(te),e&&a(is),e&&a(S),e&&a(cs),e&&a(ve),e&&a(ms),e&&a(Ue),e&&a(ds),e&&a(Ie),e&&a(ps),e&&a(Ze),e&&a(fs),e&&a(E),e&&a(hs),e&&a(G),v(ce),e&&a(us),e&&a(Ce),e&&a(gs),e&&a($),v(me),e&&a(Ms),e&&a(U),v(de),v(H),e&&a(ys),e&&a(F),v(fe),e&&a(Ts),e&&a(k),v(he),v(Me),v(q),v(L),e&&a(ws),e&&a(x),v(ye),e&&a(_s),e&&a(B),v(Te),v(be),v(K),v(O)}}}const Ft={local:"timesformer",sections:[{local:"overview",title:"Overview"},{local:"documentation-resources",title:"Documentation resources"},{local:"transformers.TimesformerConfig",title:"TimesformerConfig"},{local:"transformers.TimesformerModel",title:"TimesformerModel"},{local:"transformers.TimesformerForVideoClassification",title:"TimesformerForVideoClassification"}],title:"TimeSformer"};function zt(I){return Bt(()=>{new URLSearchParams(window.location.search).get("fw")}),[]}class Ht extends Zt{constructor(m){super();Ct(this,m,zt,Nt,Wt,{})}}export{Ht as default,Ft as metadata};
