import{S as It,i as Ct,s as Bt,e as n,k as u,w as T,t as l,M as Wt,c as o,d as a,m as M,a as r,x as j,h as i,b as c,G as s,g as h,y as b,q as _,o as J,B as U,v as Gt,L as za}from"../../chunks/vendor-hf-doc-builder.js";import{T as Zt}from"../../chunks/Tip-hf-doc-builder.js";import{D as rs}from"../../chunks/Docstring-hf-doc-builder.js";import{C as Ra}from"../../chunks/CodeBlock-hf-doc-builder.js";import{I as ze}from"../../chunks/IconCopyLink-hf-doc-builder.js";import{E as Na}from"../../chunks/ExampleCodeBlock-hf-doc-builder.js";function kt(Z){let m,w,g,d,y;return d=new Ra({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"),w=l("Example:"),g=u(),T(d.$$.fragment)},l(t){m=o(t,"P",{});var f=r(m);w=i(f,"Example:"),f.forEach(a),g=M(t),j(d.$$.fragment,t)},m(t,f){h(t,m,f),s(m,w),h(t,g,f),b(d,t,f),y=!0},p:za,i(t){y||(_(d.$$.fragment,t),y=!0)},o(t){J(d.$$.fragment,t),y=!1},d(t){t&&a(m),t&&a(g),U(d,t)}}}function Et(Z){let m,w,g,d,y;return{c(){m=n("p"),w=l("Although the recipe for forward pass needs to be defined within this function, one should call the "),g=n("code"),d=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 f=r(m);w=i(f,"Although the recipe for forward pass needs to be defined within this function, one should call the "),g=o(f,"CODE",{});var B=r(g);d=i(B,"Module"),B.forEach(a),y=i(f,`
instance afterwards instead of this since the former takes care of running the pre and post processing steps while
the latter silently ignores them.`),f.forEach(a)},m(t,f){h(t,m,f),s(m,w),s(m,g),s(g,d),s(m,y)},d(t){t&&a(m)}}}function At(Z){let m,w,g,d,y;return d=new Ra({props:{code:" ",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>    <span class="hljs-string">&#x27;&#x27;&#x27;
<span class="hljs-meta">... </span>    Sample a given number of frame indices from the video.
<span class="hljs-meta">... </span>    Args:
<span class="hljs-meta">... </span>        clip_len (\`int\`): Total number of frames to sample.
<span class="hljs-meta">... </span>        frame_sample_rate (\`int\`): Sample every n-th frame.
<span class="hljs-meta">... </span>        seg_len (\`int\`): Maximum allowed index of sample&#x27;s last frame.
<span class="hljs-meta">... </span>    Returns:
<span class="hljs-meta">... </span>        indices (\`List[int]\`): List of sampled frame indices
<span class="hljs-meta">... </span>    &#x27;&#x27;&#x27;</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"),w=l("Examples:"),g=u(),T(d.$$.fragment)},l(t){m=o(t,"P",{});var f=r(m);w=i(f,"Examples:"),f.forEach(a),g=M(t),j(d.$$.fragment,t)},m(t,f){h(t,m,f),s(m,w),h(t,g,f),b(d,t,f),y=!0},p:za,i(t){y||(_(d.$$.fragment,t),y=!0)},o(t){J(d.$$.fragment,t),y=!1},d(t){t&&a(m),t&&a(g),U(d,t)}}}function Vt(Z){let m,w,g,d,y;return{c(){m=n("p"),w=l("Although the recipe for forward pass needs to be defined within this function, one should call the "),g=n("code"),d=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 f=r(m);w=i(f,"Although the recipe for forward pass needs to be defined within this function, one should call the "),g=o(f,"CODE",{});var B=r(g);d=i(B,"Module"),B.forEach(a),y=i(f,`
instance afterwards instead of this since the former takes care of running the pre and post processing steps while
the latter silently ignores them.`),f.forEach(a)},m(t,f){h(t,m,f),s(m,w),s(m,g),s(g,d),s(m,y)},d(t){t&&a(m)}}}function St(Z){let m,w,g,d,y;return d=new Ra({props:{code:" ",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>    <span class="hljs-string">&#x27;&#x27;&#x27;
<span class="hljs-meta">... </span>    Sample a given number of frame indices from the video.
<span class="hljs-meta">... </span>    Args:
<span class="hljs-meta">... </span>        clip_len (\`int\`): Total number of frames to sample.
<span class="hljs-meta">... </span>        frame_sample_rate (\`int\`): Sample every n-th frame.
<span class="hljs-meta">... </span>        seg_len (\`int\`): Maximum allowed index of sample&#x27;s last frame.
<span class="hljs-meta">... </span>    Returns:
<span class="hljs-meta">... </span>        indices (\`List[int]\`): List of sampled frame indices
<span class="hljs-meta">... </span>    &#x27;&#x27;&#x27;</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"),w=l("Examples:"),g=u(),T(d.$$.fragment)},l(t){m=o(t,"P",{});var f=r(m);w=i(f,"Examples:"),f.forEach(a),g=M(t),j(d.$$.fragment,t)},m(t,f){h(t,m,f),s(m,w),h(t,g,f),b(d,t,f),y=!0},p:za,i(t){y||(_(d.$$.fragment,t),y=!0)},o(t){J(d.$$.fragment,t),y=!1},d(t){t&&a(m),t&&a(g),U(d,t)}}}function $t(Z){let m,w,g,d,y,t,f,B,Ws,ls,E,z,Re,te,Gs,Ye,ks,is,R,Es,ne,As,Vs,cs,Ue,Ss,ms,ve,oe,$s,re,Fs,xs,ps,Ze,Xs,ds,Ie,Ns,hs,k,zs,le,Rs,Ys,ie,Qs,Hs,fs,A,Y,Qe,ce,Ps,He,qs,us,Ce,Pe,Be,Ls,Ms,V,Q,qe,me,Ds,Le,Ks,gs,v,pe,Os,S,ea,We,sa,aa,de,ta,na,oa,$,ra,Ge,la,ia,ke,ca,ma,pa,H,ys,F,P,De,he,da,Ke,ha,ws,W,fe,fa,ue,ua,Me,Ma,ga,ya,I,ge,wa,x,Ta,Ee,ja,ba,Oe,_a,Ja,Ua,q,va,L,Ts,X,D,es,ye,Za,ss,Ia,js,G,we,Ca,Te,Ba,je,Wa,Ga,ka,C,be,Ea,N,Aa,Ae,Va,Sa,as,$a,Fa,xa,K,Xa,O,bs;return t=new ze({}),te=new ze({}),ce=new ze({}),me=new ze({}),pe=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/v4.33.0/src/transformers/models/timesformer/configuration_timesformer.py#L28"}}),H=new Na({props:{anchor:"transformers.TimesformerConfig.example",$$slots:{default:[kt]},$$scope:{ctx:Z}}}),he=new ze({}),fe=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/v4.33.0/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/v4.33.0/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/v4.33.0/src/transformers/models/timesformer/modeling_timesformer.py#L534"}}),ge=new rs({props:{name:"forward",anchor:"transformers.TimesformerModel.forward",parameters:[{name:"pixel_values",val:": FloatTensor"},{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.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/v4.33.0/en/model_doc/auto#transformers.AutoImageProcessor">AutoImageProcessor</a>. See
<a href="/docs/transformers/v4.33.0/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/v4.33.0/en/main_classes/output#transformers.utils.ModelOutput">ModelOutput</a> instead of a plain tuple.`,name:"return_dict"}],source:"https://github.com/huggingface/transformers/blob/v4.33.0/src/transformers/models/timesformer/modeling_timesformer.py#L558",returnDescription:`
<p>A <a
  href="/docs/transformers/v4.33.0/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/v4.33.0/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/v4.33.0/en/main_classes/output#transformers.modeling_outputs.BaseModelOutput"
>transformers.modeling_outputs.BaseModelOutput</a> or <code>tuple(torch.FloatTensor)</code></p>
`}}),q=new Zt({props:{$$slots:{default:[Et]},$$scope:{ctx:Z}}}),L=new Na({props:{anchor:"transformers.TimesformerModel.forward.example",$$slots:{default:[At]},$$scope:{ctx:Z}}}),ye=new ze({}),we=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/v4.33.0/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/v4.33.0/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/v4.33.0/src/transformers/models/timesformer/modeling_timesformer.py#L676"}}),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/v4.33.0/en/model_doc/auto#transformers.AutoImageProcessor">AutoImageProcessor</a>. See
<a href="/docs/transformers/v4.33.0/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/v4.33.0/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/v4.33.0/src/transformers/models/timesformer/modeling_timesformer.py#L689",returnDescription:`
<p>A <a
  href="/docs/transformers/v4.33.0/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/v4.33.0/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/v4.33.0/en/main_classes/output#transformers.modeling_outputs.ImageClassifierOutput"
>transformers.modeling_outputs.ImageClassifierOutput</a> or <code>tuple(torch.FloatTensor)</code></p>
`}}),K=new Zt({props:{$$slots:{default:[Vt]},$$scope:{ctx:Z}}}),O=new Na({props:{anchor:"transformers.TimesformerForVideoClassification.forward.example",$$slots:{default:[St]},$$scope:{ctx:Z}}}),{c(){m=n("meta"),w=u(),g=n("h1"),d=n("a"),y=n("span"),T(t.$$.fragment),f=u(),B=n("span"),Ws=l("TimeSformer"),ls=u(),E=n("h2"),z=n("a"),Re=n("span"),T(te.$$.fragment),Gs=u(),Ye=n("span"),ks=l("Overview"),is=u(),R=n("p"),Es=l("The TimeSformer model was proposed in "),ne=n("a"),As=l("TimeSformer: Is Space-Time Attention All You Need for Video Understanding?"),Vs=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(),Ue=n("p"),Ss=l("The abstract from the paper is the following:"),ms=u(),ve=n("p"),oe=n("em"),$s=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"),xs=l("."),ps=u(),Ze=n("p"),Xs=l("Tips:"),ds=u(),Ie=n("p"),Ns=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."),hs=u(),k=n("p"),zs=l("This model was contributed by "),le=n("a"),Rs=l("fcakyon"),Ys=l(`.
The original code can be found `),ie=n("a"),Qs=l("here"),Hs=l("."),fs=u(),A=n("h2"),Y=n("a"),Qe=n("span"),T(ce.$$.fragment),Ps=u(),He=n("span"),qs=l("Documentation resources"),us=u(),Ce=n("ul"),Pe=n("li"),Be=n("a"),Ls=l("Video classification task guide"),Ms=u(),V=n("h2"),Q=n("a"),qe=n("span"),T(me.$$.fragment),Ds=u(),Le=n("span"),Ks=l("TimesformerConfig"),gs=u(),v=n("div"),T(pe.$$.fragment),Os=u(),S=n("p"),ea=l("This is the configuration class to store the configuration of a "),We=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
`),de=n("a"),ta=l("facebook/timesformer-base-finetuned-k600"),na=l(`
architecture.`),oa=u(),$=n("p"),ra=l("Configuration objects inherit from "),Ge=n("a"),la=l("PretrainedConfig"),ia=l(` and can be used to control the model outputs. Read the
documentation from `),ke=n("a"),ca=l("PretrainedConfig"),ma=l(" for more information."),pa=u(),T(H.$$.fragment),ys=u(),F=n("h2"),P=n("a"),De=n("span"),T(he.$$.fragment),da=u(),Ke=n("span"),ha=l("TimesformerModel"),ws=u(),W=n("div"),T(fe.$$.fragment),fa=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 `),Me=n("a"),Ma=l("torch.nn.Module"),ga=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(),I=n("div"),T(ge.$$.fragment),wa=u(),x=n("p"),Ta=l("The "),Ee=n("a"),ja=l("TimesformerModel"),ba=l(" forward method, overrides the "),Oe=n("code"),_a=l("__call__"),Ja=l(" special method."),Ua=u(),T(q.$$.fragment),va=u(),T(L.$$.fragment),Ts=u(),X=n("h2"),D=n("a"),es=n("span"),T(ye.$$.fragment),Za=u(),ss=n("span"),Ia=l("TimesformerForVideoClassification"),js=u(),G=n("div"),T(we.$$.fragment),Ca=u(),Te=n("p"),Ba=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 `),je=n("a"),Wa=l("torch.nn.Module"),Ga=l(` subclass. Use it
as a regular PyTorch Module and refer to the PyTorch documentation for all matter related to general usage and
behavior.`),ka=u(),C=n("div"),T(be.$$.fragment),Ea=u(),N=n("p"),Aa=l("The "),Ae=n("a"),Va=l("TimesformerForVideoClassification"),Sa=l(" forward method, overrides the "),as=n("code"),$a=l("__call__"),Fa=l(" special method."),xa=u(),T(K.$$.fragment),Xa=u(),T(O.$$.fragment),this.h()},l(e){const p=Wt('[data-svelte="svelte-1phssyn"]',document.head);m=o(p,"META",{name:!0,content:!0}),p.forEach(a),w=M(e),g=o(e,"H1",{class:!0});var _e=r(g);d=o(_e,"A",{id:!0,class:!0,href:!0});var ts=r(d);y=o(ts,"SPAN",{});var ns=r(y);j(t.$$.fragment,ns),ns.forEach(a),ts.forEach(a),f=M(_e),B=o(_e,"SPAN",{});var os=r(B);Ws=i(os,"TimeSformer"),os.forEach(a),_e.forEach(a),ls=M(e),E=o(e,"H2",{class:!0});var Je=r(E);z=o(Je,"A",{id:!0,class:!0,href:!0});var Ya=r(z);Re=o(Ya,"SPAN",{});var Qa=r(Re);j(te.$$.fragment,Qa),Qa.forEach(a),Ya.forEach(a),Gs=M(Je),Ye=o(Je,"SPAN",{});var Ha=r(Ye);ks=i(Ha,"Overview"),Ha.forEach(a),Je.forEach(a),is=M(e),R=o(e,"P",{});var _s=r(R);Es=i(_s,"The TimeSformer model was proposed in "),ne=o(_s,"A",{href:!0,rel:!0});var Pa=r(ne);As=i(Pa,"TimeSformer: Is Space-Time Attention All You Need for Video Understanding?"),Pa.forEach(a),Vs=i(_s,` 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.`),_s.forEach(a),cs=M(e),Ue=o(e,"P",{});var qa=r(Ue);Ss=i(qa,"The abstract from the paper is the following:"),qa.forEach(a),ms=M(e),ve=o(e,"P",{});var La=r(ve);oe=o(La,"EM",{});var Js=r(oe);$s=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),xs=i(Js,"."),Js.forEach(a),La.forEach(a),ps=M(e),Ze=o(e,"P",{});var Ka=r(Ze);Xs=i(Ka,"Tips:"),Ka.forEach(a),ds=M(e),Ie=o(e,"P",{});var Oa=r(Ie);Ns=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),hs=M(e),k=o(e,"P",{});var Ve=r(k);zs=i(Ve,"This model was contributed by "),le=o(Ve,"A",{href:!0,rel:!0});var et=r(le);Rs=i(et,"fcakyon"),et.forEach(a),Ys=i(Ve,`.
The original code can be found `),ie=o(Ve,"A",{href:!0,rel:!0});var st=r(ie);Qs=i(st,"here"),st.forEach(a),Hs=i(Ve,"."),Ve.forEach(a),fs=M(e),A=o(e,"H2",{class:!0});var Us=r(A);Y=o(Us,"A",{id:!0,class:!0,href:!0});var at=r(Y);Qe=o(at,"SPAN",{});var tt=r(Qe);j(ce.$$.fragment,tt),tt.forEach(a),at.forEach(a),Ps=M(Us),He=o(Us,"SPAN",{});var nt=r(He);qs=i(nt,"Documentation resources"),nt.forEach(a),Us.forEach(a),us=M(e),Ce=o(e,"UL",{});var ot=r(Ce);Pe=o(ot,"LI",{});var rt=r(Pe);Be=o(rt,"A",{href:!0});var lt=r(Be);Ls=i(lt,"Video classification task guide"),lt.forEach(a),rt.forEach(a),ot.forEach(a),Ms=M(e),V=o(e,"H2",{class:!0});var vs=r(V);Q=o(vs,"A",{id:!0,class:!0,href:!0});var it=r(Q);qe=o(it,"SPAN",{});var ct=r(qe);j(me.$$.fragment,ct),ct.forEach(a),it.forEach(a),Ds=M(vs),Le=o(vs,"SPAN",{});var mt=r(Le);Ks=i(mt,"TimesformerConfig"),mt.forEach(a),vs.forEach(a),gs=M(e),v=o(e,"DIV",{class:!0});var ee=r(v);j(pe.$$.fragment,ee),Os=M(ee),S=o(ee,"P",{});var Se=r(S);ea=i(Se,"This is the configuration class to store the configuration of a "),We=o(Se,"A",{href:!0});var pt=r(We);sa=i(pt,"TimesformerModel"),pt.forEach(a),aa=i(Se,`. 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
`),de=o(Se,"A",{href:!0,rel:!0});var dt=r(de);ta=i(dt,"facebook/timesformer-base-finetuned-k600"),dt.forEach(a),na=i(Se,`
architecture.`),Se.forEach(a),oa=M(ee),$=o(ee,"P",{});var $e=r($);ra=i($e,"Configuration objects inherit from "),Ge=o($e,"A",{href:!0});var ht=r(Ge);la=i(ht,"PretrainedConfig"),ht.forEach(a),ia=i($e,` and can be used to control the model outputs. Read the
documentation from `),ke=o($e,"A",{href:!0});var ft=r(ke);ca=i(ft,"PretrainedConfig"),ft.forEach(a),ma=i($e," for more information."),$e.forEach(a),pa=M(ee),j(H.$$.fragment,ee),ee.forEach(a),ys=M(e),F=o(e,"H2",{class:!0});var Zs=r(F);P=o(Zs,"A",{id:!0,class:!0,href:!0});var ut=r(P);De=o(ut,"SPAN",{});var Mt=r(De);j(he.$$.fragment,Mt),Mt.forEach(a),ut.forEach(a),da=M(Zs),Ke=o(Zs,"SPAN",{});var gt=r(Ke);ha=i(gt,"TimesformerModel"),gt.forEach(a),Zs.forEach(a),ws=M(e),W=o(e,"DIV",{class:!0});var Fe=r(W);j(fe.$$.fragment,Fe),fa=M(Fe),ue=o(Fe,"P",{});var Is=r(ue);ua=i(Is,`The bare TimeSformer Model transformer outputting raw hidden-states without any specific head on top.
This model is a PyTorch `),Me=o(Is,"A",{href:!0,rel:!0});var yt=r(Me);Ma=i(yt,"torch.nn.Module"),yt.forEach(a),ga=i(Is,` subclass. Use it
as a regular PyTorch Module and refer to the PyTorch documentation for all matter related to general usage and
behavior.`),Is.forEach(a),ya=M(Fe),I=o(Fe,"DIV",{class:!0});var se=r(I);j(ge.$$.fragment,se),wa=M(se),x=o(se,"P",{});var xe=r(x);Ta=i(xe,"The "),Ee=o(xe,"A",{href:!0});var wt=r(Ee);ja=i(wt,"TimesformerModel"),wt.forEach(a),ba=i(xe," forward method, overrides the "),Oe=o(xe,"CODE",{});var Tt=r(Oe);_a=i(Tt,"__call__"),Tt.forEach(a),Ja=i(xe," special method."),xe.forEach(a),Ua=M(se),j(q.$$.fragment,se),va=M(se),j(L.$$.fragment,se),se.forEach(a),Fe.forEach(a),Ts=M(e),X=o(e,"H2",{class:!0});var Cs=r(X);D=o(Cs,"A",{id:!0,class:!0,href:!0});var jt=r(D);es=o(jt,"SPAN",{});var bt=r(es);j(ye.$$.fragment,bt),bt.forEach(a),jt.forEach(a),Za=M(Cs),ss=o(Cs,"SPAN",{});var _t=r(ss);Ia=i(_t,"TimesformerForVideoClassification"),_t.forEach(a),Cs.forEach(a),js=M(e),G=o(e,"DIV",{class:!0});var Xe=r(G);j(we.$$.fragment,Xe),Ca=M(Xe),Te=o(Xe,"P",{});var Bs=r(Te);Ba=i(Bs,`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 `),je=o(Bs,"A",{href:!0,rel:!0});var Jt=r(je);Wa=i(Jt,"torch.nn.Module"),Jt.forEach(a),Ga=i(Bs,` subclass. Use it
as a regular PyTorch Module and refer to the PyTorch documentation for all matter related to general usage and
behavior.`),Bs.forEach(a),ka=M(Xe),C=o(Xe,"DIV",{class:!0});var ae=r(C);j(be.$$.fragment,ae),Ea=M(ae),N=o(ae,"P",{});var Ne=r(N);Aa=i(Ne,"The "),Ae=o(Ne,"A",{href:!0});var Ut=r(Ae);Va=i(Ut,"TimesformerForVideoClassification"),Ut.forEach(a),Sa=i(Ne," forward method, overrides the "),as=o(Ne,"CODE",{});var vt=r(as);$a=i(vt,"__call__"),vt.forEach(a),Fa=i(Ne," special method."),Ne.forEach(a),xa=M(ae),j(K.$$.fragment,ae),Xa=M(ae),j(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(d,"id","timesformer"),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","#timesformer"),c(g,"class","relative group"),c(z,"id","overview"),c(z,"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(z,"href","#overview"),c(E,"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(A,"class","relative group"),c(Be,"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(V,"class","relative group"),c(We,"href","/docs/transformers/v4.33.0/en/model_doc/timesformer#transformers.TimesformerModel"),c(de,"href","https://huggingface.co/facebook/timesformer-base-finetuned-k600"),c(de,"rel","nofollow"),c(Ge,"href","/docs/transformers/v4.33.0/en/main_classes/configuration#transformers.PretrainedConfig"),c(ke,"href","/docs/transformers/v4.33.0/en/main_classes/configuration#transformers.PretrainedConfig"),c(v,"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(Me,"href","https://pytorch.org/docs/stable/nn.html#torch.nn.Module"),c(Me,"rel","nofollow"),c(Ee,"href","/docs/transformers/v4.33.0/en/model_doc/timesformer#transformers.TimesformerModel"),c(I,"class","docstring border-l-2 border-t-2 pl-4 pt-3.5 border-gray-100 rounded-tl-xl mb-6 mt-8"),c(W,"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(je,"href","https://pytorch.org/docs/stable/nn.html#torch.nn.Module"),c(je,"rel","nofollow"),c(Ae,"href","/docs/transformers/v4.33.0/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(G,"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,p){s(document.head,m),h(e,w,p),h(e,g,p),s(g,d),s(d,y),b(t,y,null),s(g,f),s(g,B),s(B,Ws),h(e,ls,p),h(e,E,p),s(E,z),s(z,Re),b(te,Re,null),s(E,Gs),s(E,Ye),s(Ye,ks),h(e,is,p),h(e,R,p),s(R,Es),s(R,ne),s(ne,As),s(R,Vs),h(e,cs,p),h(e,Ue,p),s(Ue,Ss),h(e,ms,p),h(e,ve,p),s(ve,oe),s(oe,$s),s(oe,re),s(re,Fs),s(oe,xs),h(e,ps,p),h(e,Ze,p),s(Ze,Xs),h(e,ds,p),h(e,Ie,p),s(Ie,Ns),h(e,hs,p),h(e,k,p),s(k,zs),s(k,le),s(le,Rs),s(k,Ys),s(k,ie),s(ie,Qs),s(k,Hs),h(e,fs,p),h(e,A,p),s(A,Y),s(Y,Qe),b(ce,Qe,null),s(A,Ps),s(A,He),s(He,qs),h(e,us,p),h(e,Ce,p),s(Ce,Pe),s(Pe,Be),s(Be,Ls),h(e,Ms,p),h(e,V,p),s(V,Q),s(Q,qe),b(me,qe,null),s(V,Ds),s(V,Le),s(Le,Ks),h(e,gs,p),h(e,v,p),b(pe,v,null),s(v,Os),s(v,S),s(S,ea),s(S,We),s(We,sa),s(S,aa),s(S,de),s(de,ta),s(S,na),s(v,oa),s(v,$),s($,ra),s($,Ge),s(Ge,la),s($,ia),s($,ke),s(ke,ca),s($,ma),s(v,pa),b(H,v,null),h(e,ys,p),h(e,F,p),s(F,P),s(P,De),b(he,De,null),s(F,da),s(F,Ke),s(Ke,ha),h(e,ws,p),h(e,W,p),b(fe,W,null),s(W,fa),s(W,ue),s(ue,ua),s(ue,Me),s(Me,Ma),s(ue,ga),s(W,ya),s(W,I),b(ge,I,null),s(I,wa),s(I,x),s(x,Ta),s(x,Ee),s(Ee,ja),s(x,ba),s(x,Oe),s(Oe,_a),s(x,Ja),s(I,Ua),b(q,I,null),s(I,va),b(L,I,null),h(e,Ts,p),h(e,X,p),s(X,D),s(D,es),b(ye,es,null),s(X,Za),s(X,ss),s(ss,Ia),h(e,js,p),h(e,G,p),b(we,G,null),s(G,Ca),s(G,Te),s(Te,Ba),s(Te,je),s(je,Wa),s(Te,Ga),s(G,ka),s(G,C),b(be,C,null),s(C,Ea),s(C,N),s(N,Aa),s(N,Ae),s(Ae,Va),s(N,Sa),s(N,as),s(as,$a),s(N,Fa),s(C,xa),b(K,C,null),s(C,Xa),b(O,C,null),bs=!0},p(e,[p]){const _e={};p&2&&(_e.$$scope={dirty:p,ctx:e}),H.$set(_e);const ts={};p&2&&(ts.$$scope={dirty:p,ctx:e}),q.$set(ts);const ns={};p&2&&(ns.$$scope={dirty:p,ctx:e}),L.$set(ns);const os={};p&2&&(os.$$scope={dirty:p,ctx:e}),K.$set(os);const Je={};p&2&&(Je.$$scope={dirty:p,ctx:e}),O.$set(Je)},i(e){bs||(_(t.$$.fragment,e),_(te.$$.fragment,e),_(ce.$$.fragment,e),_(me.$$.fragment,e),_(pe.$$.fragment,e),_(H.$$.fragment,e),_(he.$$.fragment,e),_(fe.$$.fragment,e),_(ge.$$.fragment,e),_(q.$$.fragment,e),_(L.$$.fragment,e),_(ye.$$.fragment,e),_(we.$$.fragment,e),_(be.$$.fragment,e),_(K.$$.fragment,e),_(O.$$.fragment,e),bs=!0)},o(e){J(t.$$.fragment,e),J(te.$$.fragment,e),J(ce.$$.fragment,e),J(me.$$.fragment,e),J(pe.$$.fragment,e),J(H.$$.fragment,e),J(he.$$.fragment,e),J(fe.$$.fragment,e),J(ge.$$.fragment,e),J(q.$$.fragment,e),J(L.$$.fragment,e),J(ye.$$.fragment,e),J(we.$$.fragment,e),J(be.$$.fragment,e),J(K.$$.fragment,e),J(O.$$.fragment,e),bs=!1},d(e){a(m),e&&a(w),e&&a(g),U(t),e&&a(ls),e&&a(E),U(te),e&&a(is),e&&a(R),e&&a(cs),e&&a(Ue),e&&a(ms),e&&a(ve),e&&a(ps),e&&a(Ze),e&&a(ds),e&&a(Ie),e&&a(hs),e&&a(k),e&&a(fs),e&&a(A),U(ce),e&&a(us),e&&a(Ce),e&&a(Ms),e&&a(V),U(me),e&&a(gs),e&&a(v),U(pe),U(H),e&&a(ys),e&&a(F),U(he),e&&a(ws),e&&a(W),U(fe),U(ge),U(q),U(L),e&&a(Ts),e&&a(X),U(ye),e&&a(js),e&&a(G),U(we),U(be),U(K),U(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 xt(Z){return Gt(()=>{new URLSearchParams(window.location.search).get("fw")}),[]}class Ht extends It{constructor(m){super();Ct(this,m,xt,$t,Bt,{})}}export{Ht as default,Ft as metadata};
