영상 만들어 보기!
이제 텍스트 프롬프트만으로 영상을 직접 만들어 볼 차례예요! CogVideoXPipeline 파이프라인과 아래 프롬프트를 사용해 생성을 진행하세요:
A robot doing the robot dance. The dance floor has colorful squares and a glitterball.
참고: 비디오 생성 모델의 추론에는 시간이 오래 걸릴 수 있어, 미리 생성된 영상을 불러와 두었습니다. 다른 프롬프트를 실행해도 새 영상이 생성되지는 않습니다.
CogVideoXPipeline 클래스는 이미 임포트되어 있습니다.
이 연습은 강의의 일부입니다
Hugging Face로 배우는 멀티모달 모델
연습 안내
THUDM/CogVideoX-2b체크포인트에서CogVideoXPipeline을 생성하세요.- 제공된 프롬프트로 파이프라인을 실행하되, inference step 수를
20, 생성할 프레임 수를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")