CogVideoX वीडियो जनरेशन
Clore.ai GPUs पर Zhipu AI के CogVideoX diffusion transformer का उपयोग करके text या images से 6-सेकंड के videos बनाएं।
अंतिम अपडेट
क्या यह उपयोगी था?
क्या यह उपयोगी था?
# एनवायरनमेंट बनाएं
pip install torch torchvision --index-url https://download.pytorch.org/whl/cu124
pip install diffusers transformers accelerate sentencepiece imageio[ffmpeg]
# GPU सत्यापित करें
python -c "import torch; print(torch.cuda.get_device_name(0))"import torch
from diffusers import CogVideoXPipeline
from diffusers.utils import export_to_video
pipe = CogVideoXPipeline.from_pretrained(
"THUDM/CogVideoX-5b",
torch_dtype=torch.bfloat16,
)
pipe.to("cuda")
pipe.enable_model_cpu_offload() # ~4 GB पीक VRAM बचाता है
pipe.vae.enable_tiling() # 24 GB कार्ड पर 720x480 के लिए आवश्यक
prompt = (
"सूर्यास्त पर सूरजमुखी के खेत में दौड़ता हुआ सुनहरा रिट्रीवर, "
"सिनेमाई लाइटिंग, स्लो मोशन, 4K गुणवत्ता"
)
video_frames = pipe(
prompt=prompt,
num_frames=49,
guidance_scale=6.0,
num_inference_steps=50,
generator=torch.Generator("cuda").manual_seed(42),
).frames[0]
export_to_video(video_frames, "retriever_sunset.mp4", fps=8)
print("Saved retriever_sunset.mp4")import torch
from PIL import Image
from diffusers import CogVideoXImageToVideoPipeline
from diffusers.utils import export_to_video
pipe = CogVideoXImageToVideoPipeline.from_pretrained(
"THUDM/CogVideoX-5b-I2V",
torch_dtype=torch.bfloat16,
)
pipe.to("cuda")
pipe.enable_model_cpu_offload()
pipe.vae.enable_tiling()
image = Image.open("reference.png").resize((720, 480))
video_frames = pipe(
prompt="कैमरा धीरे-धीरे विषय के चारों ओर परिक्रमा करता है, हल्की हवा",
image=image,
num_frames=49,
guidance_scale=6.0,
num_inference_steps=50,
).frames[0]
export_to_video(video_frames, "animated.mp4", fps=8)from diffusers import CogVideoXPipeline
import torch
pipe = CogVideoXPipeline.from_pretrained(
"THUDM/CogVideoX-2b",
torch_dtype=torch.float16,
)
pipe.to("cuda")
pipe.vae.enable_tiling()
frames = pipe(
prompt="खिलते हुए चेरी ब्लॉसम पेड़ का टाइमलैप्स",
num_frames=49,
guidance_scale=6.0,
num_inference_steps=30, # कम कदम → तेज़
).frames[0]