Views
No views yet
1from diffusers import EulerDiscreteScheduler
2import torch
3from diffusers.utils import load_image, export_to_video
4from svd.inference.pipline_CILsvd import StableVideoDiffusionCILPipeline
5
6# set the start time M (sigma_max) for inference
7scheduler = EulerDiscreteScheduler.from_pretrained(
8 "zhuhz22/try4",
9 subfolder="scheduler",
10 sigma_max=100
11)
12
13pipeline = StableVideoDiffusionCILPipeline.from_pretrained(
14 "zhuhz22/try4", scheduler=scheduler, torch_dtype=torch.float16, variant="fp16"
15) # Note that set the default parameters, fps, motion_bucket_id
16
17pipeline.enable_model_cpu_offload()
18
19# demo
20image = load_image("demo/a car parked in a parking lot with palm trees nearby,calm seas and skies..png")
21image = image.resize((512,320))
22
23generator = torch.manual_seed(42)
24
25# analytic_path:
26# if is video path, compute the initial noise automatically.
27# if is tensor path, load
28# if none, standard inference
29analytic_path=None
30
31frames = pipeline(
32 image,
33 height=image.height,
34 width=image.width,
35 num_frames=16,
36 fps=3,
37 motion_bucket_id=20,
38 decode_chunk_size=8,
39 generator=generator,
40 analytic_path=analytic_path
41 ).frames[0]
42
43export_to_video(frames, "generated.mp4", fps=7)
44# TODO: add an example code snippet for running this diffusion pipeline