|
45 | 45 | ```py |
46 | 46 | >>> import torch |
47 | 47 | >>> from diffusers import ConsisIDPipeline |
| 48 | + >>> from diffusers.pipelines.consisid.util_consisid import prepare_face_models, process_face_embeddings_infer |
48 | 49 | >>> from diffusers.utils import export_to_video, load_image |
49 | 50 |
|
| 51 | + >>> face_helper_1, face_helper_2, face_clip_model, face_main_model, eva_transform_mean, eva_transform_std = prepare_face_models("https://huggingface.co/BestWishYsh/ConsisID-preview", device="cuda", torch_dtype=torch.bfloat16) |
| 52 | + >>> face_helper_1.face_det.to(device) |
| 53 | + >>> face_helper_1.face_parse.to(device) |
| 54 | + >>> face_clip_model.to(device, dtype=dtype) |
| 55 | +
|
50 | 56 | >>> pipe = ConsisIDPipeline.from_pretrained("https://huggingface.co/BestWishYsh/ConsisID-preview", torch_dtype=torch.bfloat16) |
51 | 57 | >>> pipe.to("cuda") |
52 | 58 |
|
53 | 59 | >>> prompt = "A woman adorned with a delicate flower crown, is standing amidst a field of gently swaying wildflowers. Her eyes sparkle with a serene gaze, and a faint smile graces her lips, suggesting a moment of peaceful contentment. The shot is framed from the waist up, highlighting the gentle breeze lightly tousling her hair. The background reveals an expansive meadow under a bright blue sky, capturing the tranquility of a sunny afternoon." |
54 | 60 | >>> image = load_image( |
55 | 61 | ... "https://github.com/PKU-YuanGroup/ConsisID/blob/main/asserts/example_images/1.png?raw=true" |
56 | 62 | ... ) |
57 | | - >>> video = pipe(image, prompt, use_dynamic_cfg=True) |
| 63 | +
|
| 64 | + >>> id_cond, id_vit_hidden, image, face_kps = process_face_embeddings_infer(face_helper_1, face_clip_model, face_helper_2, eva_transform_mean, eva_transform_std, face_main_model, device, dtype, img_file_path, is_align_face=True) |
| 65 | + >>> is_kps = getattr(pipe.transformer.config, 'is_kps', False) |
| 66 | + >>> kps_cond = face_kps if is_kps else None |
| 67 | +
|
| 68 | + >>> video = pipe(image=image, prompt=prompt, use_dynamic_cfg=False, id_vit_hidden=id_vit_hidden, id_cond=id_cond, kps_cond=kps_cond) |
58 | 69 | >>> export_to_video(video.frames[0], "output.mp4", fps=8) |
59 | 70 | ``` |
60 | 71 | """ |
|
0 commit comments