สร้างวิดีโอกัน!
ถึงเวลาลองสร้างวิดีโอจาก text prompt ด้วยตัวเองแล้ว! ใช้ pipeline CogVideoXPipeline พร้อม prompt ต่อไปนี้เพื่อกำหนดทิศทางการสร้าง:
A robot doing the robot dance. The dance floor has colorful squares and a glitterball.
หมายเหตุ: การ inference บนโมเดลสร้างวิดีโออาจใช้เวลานาน จึงได้โหลดวิดีโอที่สร้างไว้ล่วงหน้าให้แล้ว การรันด้วย prompt ที่แตกต่างออกไปจะไม่สร้างวิดีโอใหม่
คลาส CogVideoXPipeline ถูก import ให้เรียบร้อยแล้ว
แบบฝึกหัดนี้เป็นส่วนหนึ่งของหลักสูตร
โมเดล Multi-Modal ด้วย Hugging Face
คำแนะนำการฝึกหัด
- สร้าง
CogVideoXPipelineจาก checkpointTHUDM/CogVideoX-2b - รัน pipeline โดยใช้ prompt ที่กำหนด ตั้งค่าจำนวน inference steps เป็น
20, จำนวน frames ที่จะสร้างเป็น20และ guidance scale เป็น6
แบบฝึกหัดเชิงโต้ตอบแบบลงมือทำ
ลองทำแบบฝึกหัดนี้โดยเติมโค้ดตัวอย่างนี้ให้สมบูรณ์
prompt = "A robot doing the robot dance. The dance floor has colorful squares and a glitterball."
# Create a CogVideoXPipeline
pipe = ____(
"____",
torch_dtype=torch.float16
)
# Run the pipeline with the provided prompt
video = pipe(
prompt=____,
num_inference_steps=____,
num_frames=____,
guidance_scale=____
)
video = video.frames[0]
video_path = export_to_video(video, "output.mp4", fps=8)
video = VideoFileClip(video_path)
video.write_gif("video_ex.gif")