The generated video got stuck?

#16
by VIVI0815 - opened

code

import torch
from diffusers import CogVideoXPipeline
from diffusers.utils import export_to_video, load_image
import os
from PIL import Image

import torch._dynamo
torch._dynamo.config.suppress_errors = True # 保留抑制错误
torch._dynamo.disable() # 完全禁用Dynamo编译

pipe = CogVideoXPipeline.from_pretrained("CogVideoX-5b", torch_dtype=torch.bfloat16).to("cuda")

pipe.vae.enable_slicing()

pipe.transformer.to(memory_format=torch.channels_last)

def get_vid_size(vid_max_edge=480):
return 720, 480

vid_w, vid_h = get_vid_size(vid_max_edge=480)

prompt = "A woman is riding a bear on the back of a brown bear while wearing a black leather jacket, jeans, and having blonde hair. They walk past people on the sidewalk, with yellow taxis and buildings in the background. The atmosphere is cheerful and playful."# abnormal after 3s
prompt = "A woman is riding a bear on the back of a brown bear while wearing a black leather jacket, jeans, and having blonde hair." # abnormal after 5s
prompt = "A woman" # normal

device = 'cuda:1'
video = pipe(
prompt=prompt,
guidance_scale=6, # 控制提示词的影响力
generator=torch.Generator(device=device).manual_seed(42),
num_inference_steps=50, # 定义推理步数
# num_frames=48, # 设置生成的帧数为49
# height=vid_h, # 设置视频高度
# width=vid_w # 设置视频宽度
).frames[0] # 只获取第一段视频的帧

output_path = "video_480.mp4"
export_to_video(video, output_path, fps=8)
print(f"Video saved to {output_path}")

model: CogVideoX-5b

promblem: I found that different prompts may get the generated video stuck. For example, for prompt = "A woman is riding a bear on the back of a brown bear while wearing a black leather jacket, jeans, and having blonde hair. They walk past people on the sidewalk, with yellow taxis and buildings in the background. The atmosphere is cheerful and playful.", the video get stuck after 3 s. For prompt = "A woman is riding a bear on the back of a brown bear while wearing a black leather jacket, jeans, and having blonde hair.", the video get stuck after 5 s. For prompt = "A woman ", the video didn't get stuck.

Sign up or log in to comment