import{s as Me,n as me,o as de}from"../chunks/scheduler.8c3d61f6.js";import{S as ce,i as re,g as n,s as a,r as d,A as Je,h as o,f as t,c as i,j as pe,u as c,x as v,k as P,y as ye,a as s,v as r,d as J,t as y,w}from"../chunks/index.da70eac4.js";import{C as O}from"../chunks/CodeBlock.a9c4becf.js";import{H as K,E as we}from"../chunks/index.ef90fe87.js";function he(ee){let p,k,W,C,h,x,u,le="CogVideoX is a text-to-video generation model focused on creating more coherent videos aligned with a prompt. It achieves this using several methods.",H,T,te="<li><p>a 3D variational autoencoder that compresses videos spatially and temporally, improving compression rate and video accuracy.</p></li> <li><p>an expert transformer block to help align text and video, and a 3D full attention module for capturing and creating spatially and temporally accurate videos.</p></li>",R,b,E,U,se='Model weights may be stored in separate subfolders on the Hub or locally, in which case, you should use the <a href="/docs/diffusers/main/en/api/pipelines/overview#diffusers.DiffusionPipeline.from_pretrained">from_pretrained()</a> method.',Y,g,_,f,$,Z,ae="For text-to-video, pass a text prompt. By default, CogVideoX generates a 720x480 video for the best results.",S,j,N,M,ie='<img src="https://huggingface.co/datasets/huggingface/documentation-images/resolve/main/diffusers/cogvideox/cogvideox_out.gif" alt="generated image of an astronaut in a jungle"/>',F,I,Q,G,ne='You’ll use the <a href="https://huggingface.co/THUDM/CogVideoX-5b-I2V" rel="nofollow">THUDM/CogVideoX-5b-I2V</a>  checkpoint for this guide.',z,B,D,m,oe='<div><img class="rounded-xl" src="https://huggingface.co/datasets/huggingface/documentation-images/resolve/main/diffusers/cogvideox/cogvideox_rocket.png"/> <figcaption class="mt-2 text-center text-sm text-gray-500">initial image</figcaption></div> <div><img class="rounded-xl" src="https://huggingface.co/datasets/huggingface/documentation-images/resolve/main/diffusers/cogvideox/cogvideox_outrocket.gif"/> <figcaption class="mt-2 text-center text-sm text-gray-500">generated video</figcaption></div>',A,V,L,X,q;return h=new K({props:{title:"CogVideoX",local:"cogvideox",headingTag:"h1"}}),b=new K({props:{title:"Load model checkpoints",local:"load-model-checkpoints",headingTag:"h2"}}),g=new O({props:{code:"ZnJvbSUyMGRpZmZ1c2VycyUyMGltcG9ydCUyMENvZ1ZpZGVvWFBpcGVsaW5lJTJDJTIwQ29nVmlkZW9YSW1hZ2VUb1ZpZGVvUGlwZWxpbmUlMEFwaXBlJTIwJTNEJTIwQ29nVmlkZW9YUGlwZWxpbmUuZnJvbV9wcmV0cmFpbmVkKCUwQSUyMCUyMCUyMCUyMCUyMlRIVURNJTJGQ29nVmlkZW9YLTJiJTIyJTJDJTBBJTIwJTIwJTIwJTIwdG9yY2hfZHR5cGUlM0R0b3JjaC5mbG9hdDE2JTBBKSUwQSUwQXBpcGUlMjAlM0QlMjBDb2dWaWRlb1hJbWFnZVRvVmlkZW9QaXBlbGluZS5mcm9tX3ByZXRyYWluZWQoJTBBJTIwJTIwJTIwJTIwJTIyVEhVRE0lMkZDb2dWaWRlb1gtNWItSTJWJTIyJTJDJTBBJTIwJTIwJTIwJTIwdG9yY2hfZHR5cGUlM0R0b3JjaC5iZmxvYXQxNiUwQSklMEE=",highlighted:`<span class="hljs-keyword">from</span> diffusers <span class="hljs-keyword">import</span> CogVideoXPipeline, CogVideoXImageToVideoPipeline
pipe = CogVideoXPipeline.from_pretrained(
    <span class="hljs-string">&quot;THUDM/CogVideoX-2b&quot;</span>,
    torch_dtype=torch.float16
)

pipe = CogVideoXImageToVideoPipeline.from_pretrained(
    <span class="hljs-string">&quot;THUDM/CogVideoX-5b-I2V&quot;</span>,
    torch_dtype=torch.bfloat16
)
`,wrap:!1}}),f=new K({props:{title:"Text-to-Video",local:"text-to-video",headingTag:"h2"}}),j=new O({props:{code:"aW1wb3J0JTIwdG9yY2glMEFmcm9tJTIwZGlmZnVzZXJzJTIwaW1wb3J0JTIwQ29nVmlkZW9YUGlwZWxpbmUlMEFmcm9tJTIwZGlmZnVzZXJzLnV0aWxzJTIwaW1wb3J0JTIwZXhwb3J0X3RvX3ZpZGVvJTBBJTBBcHJvbXB0JTIwJTNEJTIwJTIyQW4lMjBlbGRl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UyMiUwQSUwQXBpcGUlMjAlM0QlMjBDb2dWaWRlb1hQaXBlbGluZS5mcm9tX3ByZXRyYWluZWQoJTBBJTIwJTIwJTIwJTIwJTIyVEhVRE0lMkZDb2dWaWRlb1gtNWIlMjIlMkMlMEElMjAlMjAlMjAlMjB0b3JjaF9kdHlwZSUzRHRvcmNoLmJmbG9hdDE2JTBBKSUwQSUwQXBpcGUuZW5hYmxlX21vZGVsX2NwdV9vZmZsb2FkKCklMEFwaXBlLnZhZS5lbmFibGVfdGlsaW5nKCklMEElMEF2aWRlbyUyMCUzRCUyMHBpcGUoJTBBJTIwJTIwJTIwJTIwcHJvbXB0JTNEcHJvbXB0JTJDJTBBJTIwJTIwJTIwJTIwbnVtX3ZpZGVvc19wZXJfcHJvbXB0JTNEMSUyQyUwQSUyMCUyMCUyMCUyMG51bV9pbmZlcmVuY2Vfc3RlcHMlM0Q1MCUyQyUwQSUyMCUyMCUyMCUyMG51bV9mcmFtZXMlM0Q0OSUyQyUwQSUyMCUyMCUyMCUyMGd1aWRhbmNlX3NjYWxlJTNENiUyQyUwQSUyMCUyMCUyMCUyMGdlbmVyYXRvciUzRHRvcmNoLkdlbmVyYXRvcihkZXZpY2UlM0QlMjJjdWRhJTIyKS5tYW51YWxfc2VlZCg0MiklMkMlMEEpLmZyYW1lcyU1QjAlNUQlMEElMEFleHBvcnRfdG9fdmlkZW8odmlkZW8lMkMlMjAlMjJvdXRwdXQubXA0JTIyJTJDJTIwZnBzJTNEOCklMEE=",highlighted:`<span class="hljs-keyword">import</span> torch
<span class="hljs-keyword">from</span> diffusers <span class="hljs-keyword">import</span> CogVideoXPipeline
<span class="hljs-keyword">from</span> diffusers.utils <span class="hljs-keyword">import</span> export_to_video

prompt = <span class="hljs-string">&quot;An elderly gentleman, with a serene expression, sits at the water&#x27;s edge, a steaming cup of tea by his side. He is engrossed in his artwork, brush in hand, as he renders an oil painting on a canvas that&#x27;s propped up against a small, weathered table. The sea breeze whispers through his silver hair, gently billowing his loose-fitting white shirt, while the salty air adds an intangible element to his masterpiece in progress. The scene is one of tranquility and inspiration, with the artist&#x27;s canvas capturing the vibrant hues of the setting sun reflecting off the tranquil sea.&quot;</span>

pipe = CogVideoXPipeline.from_pretrained(
    <span class="hljs-string">&quot;THUDM/CogVideoX-5b&quot;</span>,
    torch_dtype=torch.bfloat16
)

pipe.enable_model_cpu_offload()
pipe.vae.enable_tiling()

video = pipe(
    prompt=prompt,
    num_videos_per_prompt=<span class="hljs-number">1</span>,
    num_inference_steps=<span class="hljs-number">50</span>,
    num_frames=<span class="hljs-number">49</span>,
    guidance_scale=<span class="hljs-number">6</span>,
    generator=torch.Generator(device=<span class="hljs-string">&quot;cuda&quot;</span>).manual_seed(<span class="hljs-number">42</span>),
).frames[<span class="hljs-number">0</span>]

export_to_video(video, <span class="hljs-string">&quot;output.mp4&quot;</span>, fps=<span class="hljs-number">8</span>)
`,wrap:!1}}),I=new K({props:{title:"Image-to-Video",local:"image-to-video",headingTag:"h2"}}),B=new O({props:{code:"aW1wb3J0JTIwdG9yY2glMEFmcm9tJTIwZGlmZnVzZXJzJTIwaW1wb3J0JTIwQ29nVmlkZW9YSW1hZ2VUb1ZpZGVvUGlwZWxpbmUlMEFmcm9tJTIwZGlmZnVzZXJzLnV0aWxzJTIwaW1wb3J0JTIwZXhwb3J0X3RvX3ZpZGVvJTJDJTIwbG9hZF9pbWFnZSUwQSUwQXByb21wdCUyMCUzRCUyMCUyMkElMjB2YXN0JTJDJTIwc2hpbW1lcmluZyUyMG9jZWFuJTIwZmxvd3MlMjBncmFjZWZ1bGx5JTIwdW5kZXIlMjBhJTIwdHdpbGlnaHQlMjBza3klMkMlMjBpdHMlMjB3YXZlcyUyMHVuZHVsYXRpbmclMjBpbiUyMGElMjBtZXNtZXJpemluZyUyMGRhbmNlJTIwb2YlMjBibHVlcyUyMGFuZCUyMGdyZWVucy4lMjBUaGUlMjBzdXJmYWNlJTIwZ2xpbnRzJTIwd2l0aCUyMHRoZSUyMGxhc3Ql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aWRlbyUyMCUzRCUyMHBpcGUoJTBBJTIwJTIwJTIwJTIwcHJvbXB0JTNEcHJvbXB0JTJDJTBBJTIwJTIwJTIwJTIwaW1hZ2UlM0RpbWFnZSUyQyUwQSUyMCUyMCUyMCUyMG51bV92aWRlb3NfcGVyX3Byb21wdCUzRDElMkMlMEElMjAlMjAlMjAlMjBudW1faW5mZXJlbmNlX3N0ZXBzJTNENTAlMkMlMEElMjAlMjAlMjAlMjBudW1fZnJhbWVzJTNENDklMkMlMEElMjAlMjAlMjAlMjBndWlkYW5jZV9zY2FsZSUzRDYlMkMlMEElMjAlMjAlMjAlMjBnZW5lcmF0b3IlM0R0b3JjaC5HZW5lcmF0b3IoZGV2aWNlJTNEJTIyY3VkYSUyMikubWFudWFsX3NlZWQoNDIpJTJDJTBBKS5mcmFtZXMlNUIwJTVEJTBBJTBBZXhwb3J0X3RvX3ZpZGVvKHZpZGVvJTJDJTIwJTIyb3V0cHV0Lm1wNCUyMiUyQyUyMGZwcyUzRDgp",highlighted:`<span class="hljs-keyword">import</span> torch
<span class="hljs-keyword">from</span> diffusers <span class="hljs-keyword">import</span> CogVideoXImageToVideoPipeline
<span class="hljs-keyword">from</span> diffusers.utils <span class="hljs-keyword">import</span> export_to_video, load_image

prompt = <span class="hljs-string">&quot;A vast, shimmering ocean flows gracefully under a twilight sky, its waves undulating in a mesmerizing dance of blues and greens. The surface glints with the last rays of the setting sun, casting golden highlights that ripple across the water. Seagulls soar above, their cries blending with the gentle roar of the waves. The horizon stretches infinitely, where the ocean meets the sky in a seamless blend of hues. Close-ups reveal the intricate patterns of the waves, capturing the fluidity and dynamic beauty of the sea in motion.&quot;</span>
image = load_image(image=<span class="hljs-string">&quot;cogvideox_rocket.png&quot;</span>)
pipe = CogVideoXImageToVideoPipeline.from_pretrained(
    <span class="hljs-string">&quot;THUDM/CogVideoX-5b-I2V&quot;</span>,
    torch_dtype=torch.bfloat16
)
 
pipe.vae.enable_tiling()
pipe.vae.enable_slicing()

video = pipe(
    prompt=prompt,
    image=image,
    num_videos_per_prompt=<span class="hljs-number">1</span>,
    num_inference_steps=<span class="hljs-number">50</span>,
    num_frames=<span class="hljs-number">49</span>,
    guidance_scale=<span class="hljs-number">6</span>,
    generator=torch.Generator(device=<span class="hljs-string">&quot;cuda&quot;</span>).manual_seed(<span class="hljs-number">42</span>),
).frames[<span class="hljs-number">0</span>]

export_to_video(video, <span class="hljs-string">&quot;output.mp4&quot;</span>, fps=<span class="hljs-number">8</span>)`,wrap:!1}}),V=new we({props:{source:"https://github.com/huggingface/diffusers/blob/main/docs/source/en/using-diffusers/cogvideox.md"}}),{c(){p=n("meta"),k=a(),W=n("p"),C=a(),d(h.$$.fragment),x=a(),u=n("p"),u.textContent=le,H=a(),T=n("ul"),T.innerHTML=te,R=a(),d(b.$$.fragment),E=a(),U=n("p"),U.innerHTML=se,Y=a(),d(g.$$.fragment),_=a(),d(f.$$.fragment),$=a(),Z=n("p"),Z.textContent=ae,S=a(),d(j.$$.fragment),N=a(),M=n("div"),M.innerHTML=ie,F=a(),d(I.$$.fragment),Q=a(),G=n("p"),G.innerHTML=ne,z=a(),d(B.$$.fragment),D=a(),m=n("div"),m.innerHTML=oe,A=a(),d(V.$$.fragment),L=a(),X=n("p"),this.h()},l(e){const l=Je("svelte-u9bgzb",document.head);p=o(l,"META",{name:!0,content:!0}),l.forEach(t),k=i(e),W=o(e,"P",{}),pe(W).forEach(t),C=i(e),c(h.$$.fragment,e),x=i(e),u=o(e,"P",{"data-svelte-h":!0}),v(u)!=="svelte-18y6jrj"&&(u.textContent=le),H=i(e),T=o(e,"UL",{"data-svelte-h":!0}),v(T)!=="svelte-pybda1"&&(T.innerHTML=te),R=i(e),c(b.$$.fragment,e),E=i(e),U=o(e,"P",{"data-svelte-h":!0}),v(U)!=="svelte-1ia8sef"&&(U.innerHTML=se),Y=i(e),c(g.$$.fragment,e),_=i(e),c(f.$$.fragment,e),$=i(e),Z=o(e,"P",{"data-svelte-h":!0}),v(Z)!=="svelte-58kgp8"&&(Z.textContent=ae),S=i(e),c(j.$$.fragment,e),N=i(e),M=o(e,"DIV",{class:!0,"data-svelte-h":!0}),v(M)!=="svelte-ofbxl8"&&(M.innerHTML=ie),F=i(e),c(I.$$.fragment,e),Q=i(e),G=o(e,"P",{"data-svelte-h":!0}),v(G)!=="svelte-1wo8va"&&(G.innerHTML=ne),z=i(e),c(B.$$.fragment,e),D=i(e),m=o(e,"DIV",{class:!0,"data-svelte-h":!0}),v(m)!=="svelte-1u9aiw3"&&(m.innerHTML=oe),A=i(e),c(V.$$.fragment,e),L=i(e),X=o(e,"P",{}),pe(X).forEach(t),this.h()},h(){P(p,"name","hf:doc:metadata"),P(p,"content",ue),P(M,"class","flex justify-center"),P(m,"class","flex gap-4")},m(e,l){ye(document.head,p),s(e,k,l),s(e,W,l),s(e,C,l),r(h,e,l),s(e,x,l),s(e,u,l),s(e,H,l),s(e,T,l),s(e,R,l),r(b,e,l),s(e,E,l),s(e,U,l),s(e,Y,l),r(g,e,l),s(e,_,l),r(f,e,l),s(e,$,l),s(e,Z,l),s(e,S,l),r(j,e,l),s(e,N,l),s(e,M,l),s(e,F,l),r(I,e,l),s(e,Q,l),s(e,G,l),s(e,z,l),r(B,e,l),s(e,D,l),s(e,m,l),s(e,A,l),r(V,e,l),s(e,L,l),s(e,X,l),q=!0},p:me,i(e){q||(J(h.$$.fragment,e),J(b.$$.fragment,e),J(g.$$.fragment,e),J(f.$$.fragment,e),J(j.$$.fragment,e),J(I.$$.fragment,e),J(B.$$.fragment,e),J(V.$$.fragment,e),q=!0)},o(e){y(h.$$.fragment,e),y(b.$$.fragment,e),y(g.$$.fragment,e),y(f.$$.fragment,e),y(j.$$.fragment,e),y(I.$$.fragment,e),y(B.$$.fragment,e),y(V.$$.fragment,e),q=!1},d(e){e&&(t(k),t(W),t(C),t(x),t(u),t(H),t(T),t(R),t(E),t(U),t(Y),t(_),t($),t(Z),t(S),t(N),t(M),t(F),t(Q),t(G),t(z),t(D),t(m),t(A),t(L),t(X)),t(p),w(h,e),w(b,e),w(g,e),w(f,e),w(j,e),w(I,e),w(B,e),w(V,e)}}}const ue='{"title":"CogVideoX","local":"cogvideox","sections":[{"title":"Load model checkpoints","local":"load-model-checkpoints","sections":[],"depth":2},{"title":"Text-to-Video","local":"text-to-video","sections":[],"depth":2},{"title":"Image-to-Video","local":"image-to-video","sections":[],"depth":2}],"depth":1}';function Te(ee){return de(()=>{new URLSearchParams(window.location.search).get("fw")}),[]}class Ze extends ce{constructor(p){super(),re(this,p,Te,he,Me,{})}}export{Ze as component};
