MCPcopy Create free account
hub / github.com/MooreThreads/Moore-AnimateAnyone / main

Function main

scripts/pose2vid.py:42–163  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

40
41
42def main():
43 args = parse_args()
44
45 config = OmegaConf.load(args.config)
46
47 if config.weight_dtype == "fp16":
48 weight_dtype = torch.float16
49 else:
50 weight_dtype = torch.float32
51
52 vae = AutoencoderKL.from_pretrained(
53 config.pretrained_vae_path,
54 ).to("cuda", dtype=weight_dtype)
55
56 reference_unet = UNet2DConditionModel.from_pretrained(
57 config.pretrained_base_model_path,
58 subfolder="unet",
59 ).to(dtype=weight_dtype, device="cuda")
60
61 inference_config_path = config.inference_config
62 infer_config = OmegaConf.load(inference_config_path)
63 denoising_unet = UNet3DConditionModel.from_pretrained_2d(
64 config.pretrained_base_model_path,
65 config.motion_module_path,
66 subfolder="unet",
67 unet_additional_kwargs=infer_config.unet_additional_kwargs,
68 ).to(dtype=weight_dtype, device="cuda")
69
70 pose_guider = PoseGuider(320, block_out_channels=(16, 32, 96, 256)).to(
71 dtype=weight_dtype, device="cuda"
72 )
73
74 image_enc = CLIPVisionModelWithProjection.from_pretrained(
75 config.image_encoder_path
76 ).to(dtype=weight_dtype, device="cuda")
77
78 sched_kwargs = OmegaConf.to_container(infer_config.noise_scheduler_kwargs)
79 scheduler = DDIMScheduler(**sched_kwargs)
80
81 generator = torch.manual_seed(args.seed)
82
83 width, height = args.W, args.H
84
85 # load pretrained weights
86 denoising_unet.load_state_dict(
87 torch.load(config.denoising_unet_path, map_location="cpu"),
88 strict=False,
89 )
90 reference_unet.load_state_dict(
91 torch.load(config.reference_unet_path, map_location="cpu"),
92 )
93 pose_guider.load_state_dict(
94 torch.load(config.pose_guider_path, map_location="cpu"),
95 )
96
97 pipe = Pose2VideoPipeline(
98 vae=vae,
99 image_encoder=image_enc,

Callers 1

pose2vid.pyFile · 0.70

Calls 8

PoseGuiderClass · 0.90
Pose2VideoPipelineClass · 0.90
read_framesFunction · 0.90
get_fpsFunction · 0.90
save_videos_gridFunction · 0.90
toMethod · 0.80
from_pretrained_2dMethod · 0.80
parse_argsFunction · 0.70

Tested by

no test coverage detected