(image, video)
| 76 | |
| 77 | |
| 78 | def upscale_video(image, video): |
| 79 | # Load models |
| 80 | download_models(["stable-video-diffusion-img2vid-xt", "ExVideo-SVD-128f-v1"]) |
| 81 | model_manager = ModelManager(torch_dtype=torch.float16, device="cuda", |
| 82 | file_path_list=[ |
| 83 | "models/stable_video_diffusion/svd_xt.safetensors", |
| 84 | "models/stable_video_diffusion/model.fp16.safetensors", |
| 85 | ]) |
| 86 | pipe = SVDVideoPipeline.from_model_manager(model_manager) |
| 87 | |
| 88 | # Generate a video |
| 89 | torch.manual_seed(2) |
| 90 | video = pipe( |
| 91 | input_image=image.resize((1024, 1024)), |
| 92 | input_video=[frame.resize((1024, 1024)) for frame in video], denoising_strength=0.5, |
| 93 | num_frames=128, fps=30, height=1024, width=1024, |
| 94 | motion_bucket_id=127, |
| 95 | num_inference_steps=25, |
| 96 | min_cfg_scale=2, max_cfg_scale=2, contrast_enhance_scale=1.2 |
| 97 | ) |
| 98 | model_manager.to("cpu") |
| 99 | return video |
| 100 | |
| 101 | |
| 102 | # We use Hunyuan DiT to generate the first frame. 10GB VRAM is required. |
no test coverage detected