import{S as jo,i as Io,s as Uo,e as a,k as h,w as _,t as i,M as Vo,c as n,d as t,m as f,a as r,x as w,h as l,b as c,G as s,g as v,y as T,q as b,o as J,B as j,v as Co,L as Xt}from"../../chunks/vendor-hf-doc-builder.js";import{T as Jo}from"../../chunks/Tip-hf-doc-builder.js";import{D as Ue}from"../../chunks/Docstring-hf-doc-builder.js";import{C as St}from"../../chunks/CodeBlock-hf-doc-builder.js";import{I as Se}from"../../chunks/IconCopyLink-hf-doc-builder.js";import{E as Rt}from"../../chunks/ExampleCodeBlock-hf-doc-builder.js";function Zo(U){let d,M,g,m,y;return m=new St({props:{code:"ZnJvbSUyMHRyYW5zZm9ybWVycyUyMGltcG9ydCUyMFZpdml0Q29uZmlnJTJDJTIwVml2aXRNb2RlbCUwQSUwQSUyMyUyMEluaXRpYWxpemluZyUyMGElMjBWaVZpVCUyMGdvb2dsZSUyRnZpdml0LWItMTZ4Mi1raW5ldGljczQwMCUyMHN0eWxlJTIwY29uZmlndXJhdGlvbiUwQWNvbmZpZ3VyYXRpb24lMjAlM0QlMjBWaXZpdENvbmZpZygpJTBBJTBBJTIzJTIwSW5pdGlhbGl6aW5nJTIwYSUyMG1vZGVsJTIwKHdpdGglMjByYW5kb20lMjB3ZWlnaHRzKSUyMGZyb20lMjB0aGUlMjBnb29nbGUlMkZ2aXZpdC1iLTE2eDIta2luZXRpY3M0MDAlMjBzdHlsZSUyMGNvbmZpZ3VyYXRpb24lMEFtb2RlbCUyMCUzRCUyMFZpdml0TW9kZWwoY29uZmlndXJhdGlvbiklMEElMEElMjMlMjBBY2Nlc3NpbmclMjB0aGUlMjBtb2RlbCUyMGNvbmZpZ3VyYXRpb24lMEFjb25maWd1cmF0aW9uJTIwJTNEJTIwbW9kZWwuY29uZmln",highlighted:`<span class="hljs-meta">&gt;&gt;&gt; </span><span class="hljs-keyword">from</span> transformers <span class="hljs-keyword">import</span> VivitConfig, VivitModel

<span class="hljs-meta">&gt;&gt;&gt; </span><span class="hljs-comment"># Initializing a ViViT google/vivit-b-16x2-kinetics400 style configuration</span>
<span class="hljs-meta">&gt;&gt;&gt; </span>configuration = VivitConfig()

<span class="hljs-meta">&gt;&gt;&gt; </span><span class="hljs-comment"># Initializing a model (with random weights) from the google/vivit-b-16x2-kinetics400 style configuration</span>
<span class="hljs-meta">&gt;&gt;&gt; </span>model = VivitModel(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(){d=a("p"),M=i("Example:"),g=h(),_(m.$$.fragment)},l(o){d=n(o,"P",{});var u=r(d);M=l(u,"Example:"),u.forEach(t),g=f(o),w(m.$$.fragment,o)},m(o,u){v(o,d,u),s(d,M),v(o,g,u),T(m,o,u),y=!0},p:Xt,i(o){y||(b(m.$$.fragment,o),y=!0)},o(o){J(m.$$.fragment,o),y=!1},d(o){o&&t(d),o&&t(g),j(m,o)}}}function ko(U){let d,M,g,m,y;return{c(){d=a("p"),M=i("Although the recipe for forward pass needs to be defined within this function, one should call the "),g=a("code"),m=i("Module"),y=i(`
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(o){d=n(o,"P",{});var u=r(d);M=l(u,"Although the recipe for forward pass needs to be defined within this function, one should call the "),g=n(u,"CODE",{});var Z=r(g);m=l(Z,"Module"),Z.forEach(t),y=l(u,`
instance afterwards instead of this since the former takes care of running the pre and post processing steps while
the latter silently ignores them.`),u.forEach(t)},m(o,u){v(o,d,u),s(d,M),s(d,g),s(g,m),s(d,y)},d(o){o&&t(d)}}}function Wo(U){let d,M,g,m,y;return m=new St({props:{code:"aW1wb3J0JTIwYXYlMEFpbXBvcnQlMjBudW1weSUyMGFzJTIwbnAlMEElMEFmcm9tJTIwdHJhbnNmb3JtZXJzJTIwaW1wb3J0JTIwVml2aXRJbWFnZVByb2Nlc3NvciUyQyUyMFZpdml0TW9kZWwlMEFmcm9tJTIwaHVnZ2luZ2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MTZ4Mi1raW5ldGljczQwMCUyMiklMEElMEElMjMlMjBwcmVwYXJlJTIwdmlkZW8lMjBmb3IlMjB0aGUlMjBtb2RlbCUwQWlucHV0cyUyMCUzRCUyMGltYWdlX3Byb2Nlc3NvcihsaXN0KHZpZGVvKSUyQyUyMHJldHVybl90ZW5zb3JzJTNEJTIycHQlMjIpJTBBJTBBJTIzJTIwZm9yd2FyZCUyMHBhc3MlMEFvdXRwdXRzJTIwJTNEJTIwbW9kZWwoKippbnB1dHMpJTBBbGFzdF9oaWRkZW5fc3RhdGVzJTIwJTNEJTIwb3V0cHV0cy5sYXN0X2hpZGRlbl9zdGF0ZSUwQWxpc3QobGFzdF9oaWRkZW5fc3RhdGVzLnNoYXBlKQ==",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> VivitImageProcessor, VivitModel
<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 32 frames</span>
<span class="hljs-meta">&gt;&gt;&gt; </span>indices = sample_frame_indices(clip_len=<span class="hljs-number">32</span>, frame_sample_rate=<span class="hljs-number">1</span>, seg_len=<span class="hljs-built_in">len</span>(videoreader))
<span class="hljs-meta">&gt;&gt;&gt; </span>video = videoreader.get_batch(indices).asnumpy()

<span class="hljs-meta">&gt;&gt;&gt; </span>image_processor = VivitImageProcessor.from_pretrained(<span class="hljs-string">&quot;google/vivit-b-16x2-kinetics400&quot;</span>)
<span class="hljs-meta">&gt;&gt;&gt; </span>model = VivitModel.from_pretrained(<span class="hljs-string">&quot;google/vivit-b-16x2-kinetics400&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">3137</span>, <span class="hljs-number">768</span>]`}}),{c(){d=a("p"),M=i("Examples:"),g=h(),_(m.$$.fragment)},l(o){d=n(o,"P",{});var u=r(d);M=l(u,"Examples:"),u.forEach(t),g=f(o),w(m.$$.fragment,o)},m(o,u){v(o,d,u),s(d,M),v(o,g,u),T(m,o,u),y=!0},p:Xt,i(o){y||(b(m.$$.fragment,o),y=!0)},o(o){J(m.$$.fragment,o),y=!1},d(o){o&&t(d),o&&t(g),j(m,o)}}}function Eo(U){let d,M,g,m,y;return{c(){d=a("p"),M=i("Although the recipe for forward pass needs to be defined within this function, one should call the "),g=a("code"),m=i("Module"),y=i(`
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(o){d=n(o,"P",{});var u=r(d);M=l(u,"Although the recipe for forward pass needs to be defined within this function, one should call the "),g=n(u,"CODE",{});var Z=r(g);m=l(Z,"Module"),Z.forEach(t),y=l(u,`
instance afterwards instead of this since the former takes care of running the pre and post processing steps while
the latter silently ignores them.`),u.forEach(t)},m(o,u){v(o,d,u),s(d,M),s(d,g),s(g,m),s(d,y)},d(o){o&&t(d)}}}function Bo(U){let d,M,g,m,y;return m=new St({props:{code:"aW1wb3J0JTIwYXYlMEFpbXBvcnQlMjBudW1weSUyMGFzJTIwbnAlMEElMEFmcm9tJTIwdHJhbnNmb3JtZXJzJTIwaW1wb3J0JTIwVml2aXRJbWFnZVByb2Nlc3NvciUyQyUyMFZpdml0TW9kZWwlMEFmcm9tJTIwaHVnZ2luZ2ZhY2VfaHViJTIwaW1wb3J0JTIwaGZfaHViX2Rvd25sb2FkJTBBJTBBbnAucmFuZG9tLnNlZWQoMCklMEElMEElMEFkZWYlMjByZWFkX3ZpZGVvX3B5YXYoY29udGFpbmVyJTJDJTIwaW5kaWNlcyklM0ElMEElMjAlMjAlMjAlMjAnJyclMEElMjAlMjAlMjAlMjBEZWNvZGUlMjB0aGUlMjB2aWRlbyUyMHdpdGglMjBQeUFWJTIwZGVjb2Rlci4lMEElMjAlMjAlMjAlMjBBcmdzJTNBJTBBJTIwJTIwJTIwJTIwJTIwJTIwJTIwJTIwY29udGFpbmVyJTIwKCU2MGF2LmNvbnRhaW5lci5pbnB1dC5JbnB1dENv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ZiUyMHRoZSUyMDQwMCUyMEtpbmV0aWNzLTQwMCUyMGNsYXNzZXMlMEFwcmVkaWN0ZWRfbGFiZWwlMjAlM0QlMjBsb2dpdHMuYXJnbWF4KC0xKS5pdGVtKCklMEFwcmludChtb2RlbC5jb25maWcuaWQybGFiZWwlNUJwcmVkaWN0ZWRfbGFiZWwlNUQp",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> VivitImageProcessor, VivitModel
<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 32 frames</span>
<span class="hljs-meta">&gt;&gt;&gt; </span>indices = sample_frame_indices(clip_len=<span class="hljs-number">32</span>, frame_sample_rate=<span class="hljs-number">1</span>, seg_len=<span class="hljs-built_in">len</span>(videoreader))
<span class="hljs-meta">&gt;&gt;&gt; </span>video = videoreader.get_batch(indices).asnumpy()

<span class="hljs-meta">&gt;&gt;&gt; </span>image_processor = VivitImageProcessor.from_pretrained(<span class="hljs-string">&quot;google/vivit-b-16x2-kinetics400&quot;</span>)
<span class="hljs-meta">&gt;&gt;&gt; </span>model = VivitForVideoClassification.from_pretrained(<span class="hljs-string">&quot;google/vivit-b-16x2-kinetics400&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(){d=a("p"),M=i("Examples:"),g=h(),_(m.$$.fragment)},l(o){d=n(o,"P",{});var u=r(d);M=l(u,"Examples:"),u.forEach(t),g=f(o),w(m.$$.fragment,o)},m(o,u){v(o,d,u),s(d,M),v(o,g,u),T(m,o,u),y=!0},p:Xt,i(o){y||(b(m.$$.fragment,o),y=!0)},o(o){J(m.$$.fragment,o),y=!1},d(o){o&&t(d),o&&t(g),j(m,o)}}}function zo(U){let d,M,g,m,y,o,u,Z,Zs,ls,z,A,Ae,ne,ks,Qe,Ws,cs,Q,Es,re,Bs,zs,ds,Ve,Gs,ps,Ce,Pe,$s,ms,B,Fs,ie,Ns,xs,le,Rs,Xs,hs,G,P,Ye,ce,Ss,He,As,fs,I,de,Qs,$,Ps,Ze,Ys,Hs,pe,Ls,Ds,qs,F,Ks,ke,Os,et,We,st,tt,ot,Y,us,N,H,Le,me,at,De,nt,gs,k,he,rt,qe,it,lt,L,fe,ct,Ke,dt,vs,x,D,Oe,ue,pt,es,mt,ys,W,ge,ht,ve,ft,ye,ut,gt,vt,V,Me,yt,R,Mt,Ee,_t,wt,ss,Tt,bt,Jt,q,jt,K,Ms,X,O,ts,_e,It,os,Ut,_s,E,we,Vt,Te,Ct,be,Zt,kt,Wt,C,Je,Et,S,Bt,Be,zt,Gt,as,$t,Ft,Nt,ee,xt,se,ws;return o=new Se({}),ne=new Se({}),ce=new Se({}),de=new Ue({props:{name:"class transformers.VivitConfig",anchor:"transformers.VivitConfig",parameters:[{name:"image_size",val:" = 224"},{name:"num_frames",val:" = 32"},{name:"tubelet_size",val:" = [2, 16, 16]"},{name:"num_channels",val:" = 3"},{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_fast'"},{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:"**kwargs",val:""}],parametersDescription:[{anchor:"transformers.VivitConfig.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.VivitConfig.num_frames",description:`<strong>num_frames</strong> (<code>int</code>, <em>optional</em>, defaults to 32) &#x2014;
The number of frames in each video.`,name:"num_frames"},{anchor:"transformers.VivitConfig.tubelet_size",description:`<strong>tubelet_size</strong> (<code>List[int]</code>, <em>optional</em>, defaults to <code>[2, 16, 16]</code>) &#x2014;
The size (resolution) of each tubelet.`,name:"tubelet_size"},{anchor:"transformers.VivitConfig.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.VivitConfig.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.VivitConfig.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.VivitConfig.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.VivitConfig.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.VivitConfig.hidden_act",description:`<strong>hidden_act</strong> (<code>str</code> or <code>function</code>, <em>optional</em>, defaults to <code>&quot;gelu_fast&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>, <code>&quot;gelu_fast&quot;</code> and <code>&quot;gelu_new&quot;</code> are supported.`,name:"hidden_act"},{anchor:"transformers.VivitConfig.hidden_dropout_prob",description:`<strong>hidden_dropout_prob</strong> (<code>float</code>, <em>optional</em>, defaults to 0.0) &#x2014;
The dropout probability for all fully connected layers in the embeddings, encoder, and pooler.`,name:"hidden_dropout_prob"},{anchor:"transformers.VivitConfig.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.VivitConfig.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.VivitConfig.layer_norm_eps",description:`<strong>layer_norm_eps</strong> (<code>float</code>, <em>optional</em>, defaults to 1e-06) &#x2014;
The epsilon used by the layer normalization layers.`,name:"layer_norm_eps"},{anchor:"transformers.VivitConfig.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"}],source:"https://github.com/huggingface/transformers/blob/v4.31.0/src/transformers/models/vivit/configuration_vivit.py#L31"}}),Y=new Rt({props:{anchor:"transformers.VivitConfig.example",$$slots:{default:[Zo]},$$scope:{ctx:U}}}),me=new Se({}),he=new Ue({props:{name:"class transformers.VivitImageProcessor",anchor:"transformers.VivitImageProcessor",parameters:[{name:"do_resize",val:": bool = True"},{name:"size",val:": typing.Dict[str, int] = None"},{name:"resample",val:": Resampling = <Resampling.BILINEAR: 2>"},{name:"do_center_crop",val:": bool = True"},{name:"crop_size",val:": typing.Dict[str, int] = None"},{name:"do_rescale",val:": bool = True"},{name:"rescale_factor",val:": typing.Union[int, float] = 0.00392156862745098"},{name:"offset",val:": bool = True"},{name:"do_normalize",val:": bool = True"},{name:"image_mean",val:": typing.Union[float, typing.List[float], NoneType] = None"},{name:"image_std",val:": typing.Union[float, typing.List[float], NoneType] = None"},{name:"**kwargs",val:""}],parametersDescription:[{anchor:"transformers.VivitImageProcessor.do_resize",description:`<strong>do_resize</strong> (<code>bool</code>, <em>optional</em>, defaults to <code>True</code>) &#x2014;
Whether to resize the image&#x2019;s (height, width) dimensions to the specified <code>size</code>. Can be overridden by the
<code>do_resize</code> parameter in the <code>preprocess</code> method.`,name:"do_resize"},{anchor:"transformers.VivitImageProcessor.size",description:`<strong>size</strong> (<code>Dict[str, int]</code> <em>optional</em>, defaults to <code>{&quot;shortest_edge&quot; -- 256}</code>):
Size of the output image after resizing. The shortest edge of the image will be resized to
<code>size[&quot;shortest_edge&quot;]</code> while maintaining the aspect ratio of the original image. Can be overriden by
<code>size</code> in the <code>preprocess</code> method.`,name:"size"},{anchor:"transformers.VivitImageProcessor.resample",description:`<strong>resample</strong> (<code>PILImageResampling</code>, <em>optional</em>, defaults to <code>PILImageResampling.BILINEAR</code>) &#x2014;
Resampling filter to use if resizing the image. Can be overridden by the <code>resample</code> parameter in the
<code>preprocess</code> method.`,name:"resample"},{anchor:"transformers.VivitImageProcessor.do_center_crop",description:`<strong>do_center_crop</strong> (<code>bool</code>, <em>optional</em>, defaults to <code>True</code>) &#x2014;
Whether to center crop the image to the specified <code>crop_size</code>. Can be overridden by the <code>do_center_crop</code>
parameter in the <code>preprocess</code> method.`,name:"do_center_crop"},{anchor:"transformers.VivitImageProcessor.crop_size",description:`<strong>crop_size</strong> (<code>Dict[str, int]</code>, <em>optional</em>, defaults to <code>{&quot;height&quot; -- 224, &quot;width&quot;: 224}</code>):
Size of the image after applying the center crop. Can be overridden by the <code>crop_size</code> parameter in the
<code>preprocess</code> method.`,name:"crop_size"},{anchor:"transformers.VivitImageProcessor.do_rescale",description:`<strong>do_rescale</strong> (<code>bool</code>, <em>optional</em>, defaults to <code>True</code>) &#x2014;
Whether to rescale the image by the specified scale <code>rescale_factor</code>. Can be overridden by the <code>do_rescale</code>
parameter in the <code>preprocess</code> method.`,name:"do_rescale"},{anchor:"transformers.VivitImageProcessor.rescale_factor",description:`<strong>rescale_factor</strong> (<code>int</code> or <code>float</code>, <em>optional</em>, defaults to <code>1/255</code>) &#x2014;
Defines the scale factor to use if rescaling the image. Can be overridden by the <code>rescale_factor</code> parameter
in the <code>preprocess</code> method.`,name:"rescale_factor"},{anchor:"transformers.VivitImageProcessor.offset",description:`<strong>offset</strong> (<code>bool</code>, <em>optional</em>, defaults to <code>True</code>) &#x2014;
Whether to scale the image in both negative and positive directions. Can be overriden by the <code>offset</code> in
the <code>preprocess</code> method.`,name:"offset"},{anchor:"transformers.VivitImageProcessor.do_normalize",description:`<strong>do_normalize</strong> (<code>bool</code>, <em>optional</em>, defaults to <code>True</code>) &#x2014;
Whether to normalize the image. Can be overridden by the <code>do_normalize</code> parameter in the <code>preprocess</code>
method.`,name:"do_normalize"},{anchor:"transformers.VivitImageProcessor.image_mean",description:`<strong>image_mean</strong> (<code>float</code> or <code>List[float]</code>, <em>optional</em>, defaults to <code>IMAGENET_STANDARD_MEAN</code>) &#x2014;
Mean to use if normalizing the image. This is a float or list of floats the length of the number of
channels in the image. Can be overridden by the <code>image_mean</code> parameter in the <code>preprocess</code> method.`,name:"image_mean"},{anchor:"transformers.VivitImageProcessor.image_std",description:`<strong>image_std</strong> (<code>float</code> or <code>List[float]</code>, <em>optional</em>, defaults to <code>IMAGENET_STANDARD_STD</code>) &#x2014;
Standard deviation to use if normalizing the image. This is a float or list of floats the length of the
number of channels in the image. Can be overridden by the <code>image_std</code> parameter in the <code>preprocess</code> method.`,name:"image_std"}],source:"https://github.com/huggingface/transformers/blob/v4.31.0/src/transformers/models/vivit/image_processing_vivit.py#L64"}}),fe=new Ue({props:{name:"preprocess",anchor:"transformers.VivitImageProcessor.preprocess",parameters:[{name:"videos",val:": typing.Union[ForwardRef('PIL.Image.Image'), numpy.ndarray, ForwardRef('torch.Tensor'), typing.List[ForwardRef('PIL.Image.Image')], typing.List[numpy.ndarray], typing.List[ForwardRef('torch.Tensor')]]"},{name:"do_resize",val:": bool = None"},{name:"size",val:": typing.Dict[str, int] = None"},{name:"resample",val:": Resampling = None"},{name:"do_center_crop",val:": bool = None"},{name:"crop_size",val:": typing.Dict[str, int] = None"},{name:"do_rescale",val:": bool = None"},{name:"rescale_factor",val:": float = None"},{name:"offset",val:": bool = None"},{name:"do_normalize",val:": bool = None"},{name:"image_mean",val:": typing.Union[float, typing.List[float], NoneType] = None"},{name:"image_std",val:": typing.Union[float, typing.List[float], NoneType] = None"},{name:"return_tensors",val:": typing.Union[str, transformers.utils.generic.TensorType, NoneType] = None"},{name:"data_format",val:": ChannelDimension = <ChannelDimension.FIRST: 'channels_first'>"},{name:"**kwargs",val:""}],parametersDescription:[{anchor:"transformers.VivitImageProcessor.preprocess.videos",description:`<strong>videos</strong> (<code>ImageInput</code>) &#x2014;
Video frames to preprocess.`,name:"videos"},{anchor:"transformers.VivitImageProcessor.preprocess.do_resize",description:`<strong>do_resize</strong> (<code>bool</code>, <em>optional</em>, defaults to <code>self.do_resize</code>) &#x2014;
Whether to resize the image.`,name:"do_resize"},{anchor:"transformers.VivitImageProcessor.preprocess.size",description:`<strong>size</strong> (<code>Dict[str, int]</code>, <em>optional</em>, defaults to <code>self.size</code>) &#x2014;
Size of the image after applying resize.`,name:"size"},{anchor:"transformers.VivitImageProcessor.preprocess.resample",description:`<strong>resample</strong> (<code>PILImageResampling</code>, <em>optional</em>, defaults to <code>self.resample</code>) &#x2014;
Resampling filter to use if resizing the image. This can be one of the enum <code>PILImageResampling</code>, Only
has an effect if <code>do_resize</code> is set to <code>True</code>.`,name:"resample"},{anchor:"transformers.VivitImageProcessor.preprocess.do_center_crop",description:`<strong>do_center_crop</strong> (<code>bool</code>, <em>optional</em>, defaults to <code>self.do_centre_crop</code>) &#x2014;
Whether to centre crop the image.`,name:"do_center_crop"},{anchor:"transformers.VivitImageProcessor.preprocess.crop_size",description:`<strong>crop_size</strong> (<code>Dict[str, int]</code>, <em>optional</em>, defaults to <code>self.crop_size</code>) &#x2014;
Size of the image after applying the centre crop.`,name:"crop_size"},{anchor:"transformers.VivitImageProcessor.preprocess.do_rescale",description:`<strong>do_rescale</strong> (<code>bool</code>, <em>optional</em>, defaults to <code>self.do_rescale</code>) &#x2014;
Whether to rescale the image values between <code>[-1 - 1]</code> if <code>offset</code> is <code>True</code>, <code>[0, 1]</code> otherwise.`,name:"do_rescale"},{anchor:"transformers.VivitImageProcessor.preprocess.rescale_factor",description:`<strong>rescale_factor</strong> (<code>float</code>, <em>optional</em>, defaults to <code>self.rescale_factor</code>) &#x2014;
Rescale factor to rescale the image by if <code>do_rescale</code> is set to <code>True</code>.`,name:"rescale_factor"},{anchor:"transformers.VivitImageProcessor.preprocess.offset",description:`<strong>offset</strong> (<code>bool</code>, <em>optional</em>, defaults to <code>self.offset</code>) &#x2014;
Whether to scale the image in both negative and positive directions.`,name:"offset"},{anchor:"transformers.VivitImageProcessor.preprocess.do_normalize",description:`<strong>do_normalize</strong> (<code>bool</code>, <em>optional</em>, defaults to <code>self.do_normalize</code>) &#x2014;
Whether to normalize the image.`,name:"do_normalize"},{anchor:"transformers.VivitImageProcessor.preprocess.image_mean",description:`<strong>image_mean</strong> (<code>float</code> or <code>List[float]</code>, <em>optional</em>, defaults to <code>self.image_mean</code>) &#x2014;
Image mean.`,name:"image_mean"},{anchor:"transformers.VivitImageProcessor.preprocess.image_std",description:`<strong>image_std</strong> (<code>float</code> or <code>List[float]</code>, <em>optional</em>, defaults to <code>self.image_std</code>) &#x2014;
Image standard deviation.`,name:"image_std"},{anchor:"transformers.VivitImageProcessor.preprocess.return_tensors",description:`<strong>return_tensors</strong> (<code>str</code> or <code>TensorType</code>, <em>optional</em>) &#x2014;
The type of tensors to return. Can be one of:<ul>
<li>Unset: Return a list of <code>np.ndarray</code>.</li>
<li><code>TensorType.TENSORFLOW</code> or <code>&apos;tf&apos;</code>: Return a batch of type <code>tf.Tensor</code>.</li>
<li><code>TensorType.PYTORCH</code> or <code>&apos;pt&apos;</code>: Return a batch of type <code>torch.Tensor</code>.</li>
<li><code>TensorType.NUMPY</code> or <code>&apos;np&apos;</code>: Return a batch of type <code>np.ndarray</code>.</li>
<li><code>TensorType.JAX</code> or <code>&apos;jax&apos;</code>: Return a batch of type <code>jax.numpy.ndarray</code>.</li>
</ul>`,name:"return_tensors"},{anchor:"transformers.VivitImageProcessor.preprocess.data_format",description:`<strong>data_format</strong> (<code>ChannelDimension</code> or <code>str</code>, <em>optional</em>, defaults to <code>ChannelDimension.FIRST</code>) &#x2014;
The channel dimension format for the output image. Can be one of:<ul>
<li><code>ChannelDimension.FIRST</code>: image in (num_channels, height, width) format.</li>
<li><code>ChannelDimension.LAST</code>: image in (height, width, num_channels) format.</li>
<li>Unset: Use the inferred channel dimension format of the input image.</li>
</ul>`,name:"data_format"}],source:"https://github.com/huggingface/transformers/blob/v4.31.0/src/transformers/models/vivit/image_processing_vivit.py#L298"}}),ue=new Se({}),ge=new Ue({props:{name:"class transformers.VivitModel",anchor:"transformers.VivitModel",parameters:[{name:"config",val:""},{name:"add_pooling_layer",val:" = True"}],parametersDescription:[{anchor:"transformers.VivitModel.config",description:`<strong>config</strong> (<a href="/docs/transformers/v4.31.0/en/model_doc/vivit#transformers.VivitConfig">VivitConfig</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.31.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.31.0/src/transformers/models/vivit/modeling_vivit.py#L460"}}),Me=new Ue({props:{name:"forward",anchor:"transformers.VivitModel.forward",parameters:[{name:"pixel_values",val:" = None"},{name:"head_mask",val:" = None"},{name:"output_attentions",val:" = None"},{name:"output_hidden_states",val:" = None"},{name:"return_dict",val:" = None"}],parametersDescription:[{anchor:"transformers.VivitModel.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.31.0/en/model_doc/vivit#transformers.VivitImageProcessor">VivitImageProcessor</a>. See
<a href="/docs/transformers/v4.31.0/en/model_doc/vivit#transformers.VivitImageProcessor.preprocess">VivitImageProcessor.preprocess()</a> for details.`,name:"pixel_values"},{anchor:"transformers.VivitModel.forward.head_mask",description:`<strong>head_mask</strong> (<code>torch.FloatTensor</code> of shape <code>(num_heads,)</code> or <code>(num_layers, num_heads)</code>, <em>optional</em>) &#x2014;
Mask to nullify selected heads of the self-attention modules. Mask values selected in <code>[0, 1]</code>:</p>
<ul>
<li>1 indicates the head is <strong>not masked</strong>,</li>
<li>0 indicates the head is <strong>masked</strong>.</li>
</ul>`,name:"head_mask"},{anchor:"transformers.VivitModel.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.VivitModel.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.VivitModel.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.31.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.31.0/src/transformers/models/vivit/modeling_vivit.py#L488",returnDescription:`
<p>A <a
  href="/docs/transformers/v4.31.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.31.0/en/model_doc/vivit#transformers.VivitConfig"
>VivitConfig</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.31.0/en/main_classes/output#transformers.modeling_outputs.BaseModelOutput"
>transformers.modeling_outputs.BaseModelOutput</a> or <code>tuple(torch.FloatTensor)</code></p>
`}}),q=new Jo({props:{$$slots:{default:[ko]},$$scope:{ctx:U}}}),K=new Rt({props:{anchor:"transformers.VivitModel.forward.example",$$slots:{default:[Wo]},$$scope:{ctx:U}}}),_e=new Se({}),we=new Ue({props:{name:"class transformers.VivitForVideoClassification",anchor:"transformers.VivitForVideoClassification",parameters:[{name:"config",val:""}],parametersDescription:[{anchor:"transformers.VivitForVideoClassification.config",description:`<strong>config</strong> (<a href="/docs/transformers/v4.31.0/en/model_doc/vivit#transformers.VivitConfig">VivitConfig</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.31.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.31.0/src/transformers/models/vivit/modeling_vivit.py#L605"}}),Je=new Ue({props:{name:"forward",anchor:"transformers.VivitForVideoClassification.forward",parameters:[{name:"pixel_values",val:" = None"},{name:"head_mask",val:" = None"},{name:"labels",val:" = None"},{name:"output_attentions",val:" = None"},{name:"output_hidden_states",val:" = None"},{name:"return_dict",val:" = None"}],parametersDescription:[{anchor:"transformers.VivitForVideoClassification.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.31.0/en/model_doc/vivit#transformers.VivitImageProcessor">VivitImageProcessor</a>. See
<a href="/docs/transformers/v4.31.0/en/model_doc/vivit#transformers.VivitImageProcessor.preprocess">VivitImageProcessor.preprocess()</a> for details.`,name:"pixel_values"},{anchor:"transformers.VivitForVideoClassification.forward.head_mask",description:`<strong>head_mask</strong> (<code>torch.FloatTensor</code> of shape <code>(num_heads,)</code> or <code>(num_layers, num_heads)</code>, <em>optional</em>) &#x2014;
Mask to nullify selected heads of the self-attention modules. Mask values selected in <code>[0, 1]</code>:</p>
<ul>
<li>1 indicates the head is <strong>not masked</strong>,</li>
<li>0 indicates the head is <strong>masked</strong>.</li>
</ul>`,name:"head_mask"},{anchor:"transformers.VivitForVideoClassification.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.VivitForVideoClassification.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.VivitForVideoClassification.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.31.0/en/main_classes/output#transformers.utils.ModelOutput">ModelOutput</a> instead of a plain tuple.`,name:"return_dict"},{anchor:"transformers.VivitForVideoClassification.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.31.0/src/transformers/models/vivit/modeling_vivit.py#L618",returnDescription:`
<p>A <a
  href="/docs/transformers/v4.31.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.31.0/en/model_doc/vivit#transformers.VivitConfig"
>VivitConfig</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.31.0/en/main_classes/output#transformers.modeling_outputs.ImageClassifierOutput"
>transformers.modeling_outputs.ImageClassifierOutput</a> or <code>tuple(torch.FloatTensor)</code></p>
`}}),ee=new Jo({props:{$$slots:{default:[Eo]},$$scope:{ctx:U}}}),se=new Rt({props:{anchor:"transformers.VivitForVideoClassification.forward.example",$$slots:{default:[Bo]},$$scope:{ctx:U}}}),{c(){d=a("meta"),M=h(),g=a("h1"),m=a("a"),y=a("span"),_(o.$$.fragment),u=h(),Z=a("span"),Zs=i("Video Vision Transformer (ViViT)"),ls=h(),z=a("h2"),A=a("a"),Ae=a("span"),_(ne.$$.fragment),ks=h(),Qe=a("span"),Ws=i("Overview"),cs=h(),Q=a("p"),Es=i("The Vivit model was proposed in "),re=a("a"),Bs=i("ViViT: A Video Vision Transformer"),zs=i(` by Anurag Arnab, Mostafa Dehghani, Georg Heigold, Chen Sun, Mario Lu\u010Di\u0107, Cordelia Schmid.
The paper proposes one of the first successful pure-transformer based set of models for video understanding.`),ds=h(),Ve=a("p"),Gs=i("The abstract from the paper is the following:"),ps=h(),Ce=a("p"),Pe=a("em"),$s=i("We present pure-transformer based models for video classification, drawing upon the recent success of such models in image classification. Our model extracts spatio-temporal tokens from the input video, which are then encoded by a series of transformer layers. In order to handle the long sequences of tokens encountered in video, we propose several, efficient variants of our model which factorise the spatial- and temporal-dimensions of the input. Although transformer-based models are known to only be effective when large training datasets are available, we show how we can effectively regularise the model during training and leverage pretrained image models to be able to train on comparatively small datasets. We conduct thorough ablation studies, and achieve state-of-the-art results on multiple video classification benchmarks including Kinetics 400 and 600, Epic Kitchens, Something-Something v2 and Moments in Time, outperforming prior methods based on deep 3D convolutional networks."),ms=h(),B=a("p"),Fs=i("This model was contributed by "),ie=a("a"),Ns=i("jegormeister"),xs=i(". The original code (written in JAX) can be found "),le=a("a"),Rs=i("here"),Xs=i("."),hs=h(),G=a("h2"),P=a("a"),Ye=a("span"),_(ce.$$.fragment),Ss=h(),He=a("span"),As=i("VivitConfig"),fs=h(),I=a("div"),_(de.$$.fragment),Qs=h(),$=a("p"),Ps=i("This is the configuration class to store the configuration of a "),Ze=a("a"),Ys=i("VivitModel"),Hs=i(`. It is used to instantiate a ViViT
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 ViViT
`),pe=a("a"),Ls=i("google/vivit-b-16x2-kinetics400"),Ds=i(" architecture."),qs=h(),F=a("p"),Ks=i("Configuration objects inherit from "),ke=a("a"),Os=i("PretrainedConfig"),et=i(` and can be used to control the model outputs. Read the
documentation from `),We=a("a"),st=i("PretrainedConfig"),tt=i(" for more information."),ot=h(),_(Y.$$.fragment),us=h(),N=a("h2"),H=a("a"),Le=a("span"),_(me.$$.fragment),at=h(),De=a("span"),nt=i("VivitImageProcessor"),gs=h(),k=a("div"),_(he.$$.fragment),rt=h(),qe=a("p"),it=i("Constructs a Vivit image processor."),lt=h(),L=a("div"),_(fe.$$.fragment),ct=h(),Ke=a("p"),dt=i("Preprocess an image or batch of images."),vs=h(),x=a("h2"),D=a("a"),Oe=a("span"),_(ue.$$.fragment),pt=h(),es=a("span"),mt=i("VivitModel"),ys=h(),W=a("div"),_(ge.$$.fragment),ht=h(),ve=a("p"),ft=i(`The bare ViViT Transformer model outputting raw hidden-states without any specific head on top.
This model is a PyTorch `),ye=a("a"),ut=i("torch.nn.Module"),gt=i(` subclass. Use it
as a regular PyTorch Module and refer to the PyTorch documentation for all matter related to general usage and
behavior.`),vt=h(),V=a("div"),_(Me.$$.fragment),yt=h(),R=a("p"),Mt=i("The "),Ee=a("a"),_t=i("VivitModel"),wt=i(" forward method, overrides the "),ss=a("code"),Tt=i("__call__"),bt=i(" special method."),Jt=h(),_(q.$$.fragment),jt=h(),_(K.$$.fragment),Ms=h(),X=a("h2"),O=a("a"),ts=a("span"),_(_e.$$.fragment),It=h(),os=a("span"),Ut=i("VivitForVideoClassification"),_s=h(),E=a("div"),_(we.$$.fragment),Vt=h(),Te=a("p"),Ct=i(`ViViT Transformer model with a video classification head on top (a linear layer on top of the final hidden state of the
[CLS] token) e.g. for Kinetics-400.
This model is a PyTorch `),be=a("a"),Zt=i("torch.nn.Module"),kt=i(` subclass. Use it
as a regular PyTorch Module and refer to the PyTorch documentation for all matter related to general usage and
behavior.`),Wt=h(),C=a("div"),_(Je.$$.fragment),Et=h(),S=a("p"),Bt=i("The "),Be=a("a"),zt=i("VivitForVideoClassification"),Gt=i(" forward method, overrides the "),as=a("code"),$t=i("__call__"),Ft=i(" special method."),Nt=h(),_(ee.$$.fragment),xt=h(),_(se.$$.fragment),this.h()},l(e){const p=Vo('[data-svelte="svelte-1phssyn"]',document.head);d=n(p,"META",{name:!0,content:!0}),p.forEach(t),M=f(e),g=n(e,"H1",{class:!0});var je=r(g);m=n(je,"A",{id:!0,class:!0,href:!0});var ns=r(m);y=n(ns,"SPAN",{});var rs=r(y);w(o.$$.fragment,rs),rs.forEach(t),ns.forEach(t),u=f(je),Z=n(je,"SPAN",{});var is=r(Z);Zs=l(is,"Video Vision Transformer (ViViT)"),is.forEach(t),je.forEach(t),ls=f(e),z=n(e,"H2",{class:!0});var Ie=r(z);A=n(Ie,"A",{id:!0,class:!0,href:!0});var At=r(A);Ae=n(At,"SPAN",{});var Qt=r(Ae);w(ne.$$.fragment,Qt),Qt.forEach(t),At.forEach(t),ks=f(Ie),Qe=n(Ie,"SPAN",{});var Pt=r(Qe);Ws=l(Pt,"Overview"),Pt.forEach(t),Ie.forEach(t),cs=f(e),Q=n(e,"P",{});var Ts=r(Q);Es=l(Ts,"The Vivit model was proposed in "),re=n(Ts,"A",{href:!0,rel:!0});var Yt=r(re);Bs=l(Yt,"ViViT: A Video Vision Transformer"),Yt.forEach(t),zs=l(Ts,` by Anurag Arnab, Mostafa Dehghani, Georg Heigold, Chen Sun, Mario Lu\u010Di\u0107, Cordelia Schmid.
The paper proposes one of the first successful pure-transformer based set of models for video understanding.`),Ts.forEach(t),ds=f(e),Ve=n(e,"P",{});var Ht=r(Ve);Gs=l(Ht,"The abstract from the paper is the following:"),Ht.forEach(t),ps=f(e),Ce=n(e,"P",{});var Lt=r(Ce);Pe=n(Lt,"EM",{});var Dt=r(Pe);$s=l(Dt,"We present pure-transformer based models for video classification, drawing upon the recent success of such models in image classification. Our model extracts spatio-temporal tokens from the input video, which are then encoded by a series of transformer layers. In order to handle the long sequences of tokens encountered in video, we propose several, efficient variants of our model which factorise the spatial- and temporal-dimensions of the input. Although transformer-based models are known to only be effective when large training datasets are available, we show how we can effectively regularise the model during training and leverage pretrained image models to be able to train on comparatively small datasets. We conduct thorough ablation studies, and achieve state-of-the-art results on multiple video classification benchmarks including Kinetics 400 and 600, Epic Kitchens, Something-Something v2 and Moments in Time, outperforming prior methods based on deep 3D convolutional networks."),Dt.forEach(t),Lt.forEach(t),ms=f(e),B=n(e,"P",{});var ze=r(B);Fs=l(ze,"This model was contributed by "),ie=n(ze,"A",{href:!0,rel:!0});var qt=r(ie);Ns=l(qt,"jegormeister"),qt.forEach(t),xs=l(ze,". The original code (written in JAX) can be found "),le=n(ze,"A",{href:!0,rel:!0});var Kt=r(le);Rs=l(Kt,"here"),Kt.forEach(t),Xs=l(ze,"."),ze.forEach(t),hs=f(e),G=n(e,"H2",{class:!0});var bs=r(G);P=n(bs,"A",{id:!0,class:!0,href:!0});var Ot=r(P);Ye=n(Ot,"SPAN",{});var eo=r(Ye);w(ce.$$.fragment,eo),eo.forEach(t),Ot.forEach(t),Ss=f(bs),He=n(bs,"SPAN",{});var so=r(He);As=l(so,"VivitConfig"),so.forEach(t),bs.forEach(t),fs=f(e),I=n(e,"DIV",{class:!0});var te=r(I);w(de.$$.fragment,te),Qs=f(te),$=n(te,"P",{});var Ge=r($);Ps=l(Ge,"This is the configuration class to store the configuration of a "),Ze=n(Ge,"A",{href:!0});var to=r(Ze);Ys=l(to,"VivitModel"),to.forEach(t),Hs=l(Ge,`. It is used to instantiate a ViViT
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 ViViT
`),pe=n(Ge,"A",{href:!0,rel:!0});var oo=r(pe);Ls=l(oo,"google/vivit-b-16x2-kinetics400"),oo.forEach(t),Ds=l(Ge," architecture."),Ge.forEach(t),qs=f(te),F=n(te,"P",{});var $e=r(F);Ks=l($e,"Configuration objects inherit from "),ke=n($e,"A",{href:!0});var ao=r(ke);Os=l(ao,"PretrainedConfig"),ao.forEach(t),et=l($e,` and can be used to control the model outputs. Read the
documentation from `),We=n($e,"A",{href:!0});var no=r(We);st=l(no,"PretrainedConfig"),no.forEach(t),tt=l($e," for more information."),$e.forEach(t),ot=f(te),w(Y.$$.fragment,te),te.forEach(t),us=f(e),N=n(e,"H2",{class:!0});var Js=r(N);H=n(Js,"A",{id:!0,class:!0,href:!0});var ro=r(H);Le=n(ro,"SPAN",{});var io=r(Le);w(me.$$.fragment,io),io.forEach(t),ro.forEach(t),at=f(Js),De=n(Js,"SPAN",{});var lo=r(De);nt=l(lo,"VivitImageProcessor"),lo.forEach(t),Js.forEach(t),gs=f(e),k=n(e,"DIV",{class:!0});var Fe=r(k);w(he.$$.fragment,Fe),rt=f(Fe),qe=n(Fe,"P",{});var co=r(qe);it=l(co,"Constructs a Vivit image processor."),co.forEach(t),lt=f(Fe),L=n(Fe,"DIV",{class:!0});var js=r(L);w(fe.$$.fragment,js),ct=f(js),Ke=n(js,"P",{});var po=r(Ke);dt=l(po,"Preprocess an image or batch of images."),po.forEach(t),js.forEach(t),Fe.forEach(t),vs=f(e),x=n(e,"H2",{class:!0});var Is=r(x);D=n(Is,"A",{id:!0,class:!0,href:!0});var mo=r(D);Oe=n(mo,"SPAN",{});var ho=r(Oe);w(ue.$$.fragment,ho),ho.forEach(t),mo.forEach(t),pt=f(Is),es=n(Is,"SPAN",{});var fo=r(es);mt=l(fo,"VivitModel"),fo.forEach(t),Is.forEach(t),ys=f(e),W=n(e,"DIV",{class:!0});var Ne=r(W);w(ge.$$.fragment,Ne),ht=f(Ne),ve=n(Ne,"P",{});var Us=r(ve);ft=l(Us,`The bare ViViT Transformer model outputting raw hidden-states without any specific head on top.
This model is a PyTorch `),ye=n(Us,"A",{href:!0,rel:!0});var uo=r(ye);ut=l(uo,"torch.nn.Module"),uo.forEach(t),gt=l(Us,` subclass. Use it
as a regular PyTorch Module and refer to the PyTorch documentation for all matter related to general usage and
behavior.`),Us.forEach(t),vt=f(Ne),V=n(Ne,"DIV",{class:!0});var oe=r(V);w(Me.$$.fragment,oe),yt=f(oe),R=n(oe,"P",{});var xe=r(R);Mt=l(xe,"The "),Ee=n(xe,"A",{href:!0});var go=r(Ee);_t=l(go,"VivitModel"),go.forEach(t),wt=l(xe," forward method, overrides the "),ss=n(xe,"CODE",{});var vo=r(ss);Tt=l(vo,"__call__"),vo.forEach(t),bt=l(xe," special method."),xe.forEach(t),Jt=f(oe),w(q.$$.fragment,oe),jt=f(oe),w(K.$$.fragment,oe),oe.forEach(t),Ne.forEach(t),Ms=f(e),X=n(e,"H2",{class:!0});var Vs=r(X);O=n(Vs,"A",{id:!0,class:!0,href:!0});var yo=r(O);ts=n(yo,"SPAN",{});var Mo=r(ts);w(_e.$$.fragment,Mo),Mo.forEach(t),yo.forEach(t),It=f(Vs),os=n(Vs,"SPAN",{});var _o=r(os);Ut=l(_o,"VivitForVideoClassification"),_o.forEach(t),Vs.forEach(t),_s=f(e),E=n(e,"DIV",{class:!0});var Re=r(E);w(we.$$.fragment,Re),Vt=f(Re),Te=n(Re,"P",{});var Cs=r(Te);Ct=l(Cs,`ViViT Transformer model with a video classification head on top (a linear layer on top of the final hidden state of the
[CLS] token) e.g. for Kinetics-400.
This model is a PyTorch `),be=n(Cs,"A",{href:!0,rel:!0});var wo=r(be);Zt=l(wo,"torch.nn.Module"),wo.forEach(t),kt=l(Cs,` subclass. Use it
as a regular PyTorch Module and refer to the PyTorch documentation for all matter related to general usage and
behavior.`),Cs.forEach(t),Wt=f(Re),C=n(Re,"DIV",{class:!0});var ae=r(C);w(Je.$$.fragment,ae),Et=f(ae),S=n(ae,"P",{});var Xe=r(S);Bt=l(Xe,"The "),Be=n(Xe,"A",{href:!0});var To=r(Be);zt=l(To,"VivitForVideoClassification"),To.forEach(t),Gt=l(Xe," forward method, overrides the "),as=n(Xe,"CODE",{});var bo=r(as);$t=l(bo,"__call__"),bo.forEach(t),Ft=l(Xe," special method."),Xe.forEach(t),Nt=f(ae),w(ee.$$.fragment,ae),xt=f(ae),w(se.$$.fragment,ae),ae.forEach(t),Re.forEach(t),this.h()},h(){c(d,"name","hf:doc:metadata"),c(d,"content",JSON.stringify(Go)),c(m,"id","video-vision-transformer-vivit"),c(m,"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(m,"href","#video-vision-transformer-vivit"),c(g,"class","relative group"),c(A,"id","overview"),c(A,"class","header-link block pr-1.5 text-lg no-hover:hidden with-hover:absolute with-hover:p-1.5 with-hover:opacity-0 with-hover:group-hover:opacity-100 with-hover:right-full"),c(A,"href","#overview"),c(z,"class","relative group"),c(re,"href","https://arxiv.org/abs/2103.15691"),c(re,"rel","nofollow"),c(ie,"href","https://huggingface.co/jegormeister"),c(ie,"rel","nofollow"),c(le,"href","https://github.com/google-research/scenic/tree/main/scenic/projects/vivit"),c(le,"rel","nofollow"),c(P,"id","transformers.VivitConfig"),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.VivitConfig"),c(G,"class","relative group"),c(Ze,"href","/docs/transformers/v4.31.0/en/model_doc/vivit#transformers.VivitModel"),c(pe,"href","https://huggingface.co/google/vivit-b-16x2-kinetics400"),c(pe,"rel","nofollow"),c(ke,"href","/docs/transformers/v4.31.0/en/main_classes/configuration#transformers.PretrainedConfig"),c(We,"href","/docs/transformers/v4.31.0/en/main_classes/configuration#transformers.PretrainedConfig"),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(H,"id","transformers.VivitImageProcessor"),c(H,"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(H,"href","#transformers.VivitImageProcessor"),c(N,"class","relative group"),c(L,"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.VivitModel"),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.VivitModel"),c(x,"class","relative group"),c(ye,"href","https://pytorch.org/docs/stable/nn.html#torch.nn.Module"),c(ye,"rel","nofollow"),c(Ee,"href","/docs/transformers/v4.31.0/en/model_doc/vivit#transformers.VivitModel"),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(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(O,"id","transformers.VivitForVideoClassification"),c(O,"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(O,"href","#transformers.VivitForVideoClassification"),c(X,"class","relative group"),c(be,"href","https://pytorch.org/docs/stable/nn.html#torch.nn.Module"),c(be,"rel","nofollow"),c(Be,"href","/docs/transformers/v4.31.0/en/model_doc/vivit#transformers.VivitForVideoClassification"),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(E,"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,d),v(e,M,p),v(e,g,p),s(g,m),s(m,y),T(o,y,null),s(g,u),s(g,Z),s(Z,Zs),v(e,ls,p),v(e,z,p),s(z,A),s(A,Ae),T(ne,Ae,null),s(z,ks),s(z,Qe),s(Qe,Ws),v(e,cs,p),v(e,Q,p),s(Q,Es),s(Q,re),s(re,Bs),s(Q,zs),v(e,ds,p),v(e,Ve,p),s(Ve,Gs),v(e,ps,p),v(e,Ce,p),s(Ce,Pe),s(Pe,$s),v(e,ms,p),v(e,B,p),s(B,Fs),s(B,ie),s(ie,Ns),s(B,xs),s(B,le),s(le,Rs),s(B,Xs),v(e,hs,p),v(e,G,p),s(G,P),s(P,Ye),T(ce,Ye,null),s(G,Ss),s(G,He),s(He,As),v(e,fs,p),v(e,I,p),T(de,I,null),s(I,Qs),s(I,$),s($,Ps),s($,Ze),s(Ze,Ys),s($,Hs),s($,pe),s(pe,Ls),s($,Ds),s(I,qs),s(I,F),s(F,Ks),s(F,ke),s(ke,Os),s(F,et),s(F,We),s(We,st),s(F,tt),s(I,ot),T(Y,I,null),v(e,us,p),v(e,N,p),s(N,H),s(H,Le),T(me,Le,null),s(N,at),s(N,De),s(De,nt),v(e,gs,p),v(e,k,p),T(he,k,null),s(k,rt),s(k,qe),s(qe,it),s(k,lt),s(k,L),T(fe,L,null),s(L,ct),s(L,Ke),s(Ke,dt),v(e,vs,p),v(e,x,p),s(x,D),s(D,Oe),T(ue,Oe,null),s(x,pt),s(x,es),s(es,mt),v(e,ys,p),v(e,W,p),T(ge,W,null),s(W,ht),s(W,ve),s(ve,ft),s(ve,ye),s(ye,ut),s(ve,gt),s(W,vt),s(W,V),T(Me,V,null),s(V,yt),s(V,R),s(R,Mt),s(R,Ee),s(Ee,_t),s(R,wt),s(R,ss),s(ss,Tt),s(R,bt),s(V,Jt),T(q,V,null),s(V,jt),T(K,V,null),v(e,Ms,p),v(e,X,p),s(X,O),s(O,ts),T(_e,ts,null),s(X,It),s(X,os),s(os,Ut),v(e,_s,p),v(e,E,p),T(we,E,null),s(E,Vt),s(E,Te),s(Te,Ct),s(Te,be),s(be,Zt),s(Te,kt),s(E,Wt),s(E,C),T(Je,C,null),s(C,Et),s(C,S),s(S,Bt),s(S,Be),s(Be,zt),s(S,Gt),s(S,as),s(as,$t),s(S,Ft),s(C,Nt),T(ee,C,null),s(C,xt),T(se,C,null),ws=!0},p(e,[p]){const je={};p&2&&(je.$$scope={dirty:p,ctx:e}),Y.$set(je);const ns={};p&2&&(ns.$$scope={dirty:p,ctx:e}),q.$set(ns);const rs={};p&2&&(rs.$$scope={dirty:p,ctx:e}),K.$set(rs);const is={};p&2&&(is.$$scope={dirty:p,ctx:e}),ee.$set(is);const Ie={};p&2&&(Ie.$$scope={dirty:p,ctx:e}),se.$set(Ie)},i(e){ws||(b(o.$$.fragment,e),b(ne.$$.fragment,e),b(ce.$$.fragment,e),b(de.$$.fragment,e),b(Y.$$.fragment,e),b(me.$$.fragment,e),b(he.$$.fragment,e),b(fe.$$.fragment,e),b(ue.$$.fragment,e),b(ge.$$.fragment,e),b(Me.$$.fragment,e),b(q.$$.fragment,e),b(K.$$.fragment,e),b(_e.$$.fragment,e),b(we.$$.fragment,e),b(Je.$$.fragment,e),b(ee.$$.fragment,e),b(se.$$.fragment,e),ws=!0)},o(e){J(o.$$.fragment,e),J(ne.$$.fragment,e),J(ce.$$.fragment,e),J(de.$$.fragment,e),J(Y.$$.fragment,e),J(me.$$.fragment,e),J(he.$$.fragment,e),J(fe.$$.fragment,e),J(ue.$$.fragment,e),J(ge.$$.fragment,e),J(Me.$$.fragment,e),J(q.$$.fragment,e),J(K.$$.fragment,e),J(_e.$$.fragment,e),J(we.$$.fragment,e),J(Je.$$.fragment,e),J(ee.$$.fragment,e),J(se.$$.fragment,e),ws=!1},d(e){t(d),e&&t(M),e&&t(g),j(o),e&&t(ls),e&&t(z),j(ne),e&&t(cs),e&&t(Q),e&&t(ds),e&&t(Ve),e&&t(ps),e&&t(Ce),e&&t(ms),e&&t(B),e&&t(hs),e&&t(G),j(ce),e&&t(fs),e&&t(I),j(de),j(Y),e&&t(us),e&&t(N),j(me),e&&t(gs),e&&t(k),j(he),j(fe),e&&t(vs),e&&t(x),j(ue),e&&t(ys),e&&t(W),j(ge),j(Me),j(q),j(K),e&&t(Ms),e&&t(X),j(_e),e&&t(_s),e&&t(E),j(we),j(Je),j(ee),j(se)}}}const Go={local:"video-vision-transformer-vivit",sections:[{local:"overview",title:"Overview"},{local:"transformers.VivitConfig",title:"VivitConfig"},{local:"transformers.VivitImageProcessor",title:"VivitImageProcessor"},{local:"transformers.VivitModel",title:"VivitModel"},{local:"transformers.VivitForVideoClassification",title:"VivitForVideoClassification"}],title:"Video Vision Transformer (ViViT)"};function $o(U){return Co(()=>{new URLSearchParams(window.location.search).get("fw")}),[]}class Ao extends jo{constructor(d){super();Io(this,d,$o,zo,Uo,{})}}export{Ao as default,Go as metadata};
