Views
No views yet

1# ConsisID will be merged into diffusers in the next version. So for now, you should install from source.
2pip install --upgrade consisid_eva_clip pyfacer insightface facexlib transformers accelerate imageio-ffmpeg
3pip install git+https://github.com/huggingface/diffusers.git1import torch
2from diffusers import ConsisIDPipeline
3from diffusers.pipelines.consisid.consisid_utils import prepare_face_models, process_face_embeddings_infer
4from diffusers.utils import export_to_video
5from huggingface_hub import snapshot_download
6
7snapshot_download(repo_id="BestWishYsh/ConsisID-preview", local_dir="BestWishYsh/ConsisID-preview")
8face_helper_1, face_helper_2, face_clip_model, face_main_model, eva_transform_mean, eva_transform_std = (
9 prepare_face_models("BestWishYsh/ConsisID-preview", device="cuda", dtype=torch.bfloat16)
10)
11pipe = ConsisIDPipeline.from_pretrained("BestWishYsh/ConsisID-preview", torch_dtype=torch.bfloat16)
12pipe.to("cuda")
13
14# ConsisID works well with long and well-described prompts. Make sure the face in the image is clearly visible (e.g., preferably half-body or full-body).
15prompt = "The video captures a boy walking along a city street, filmed in black and white on a classic 35mm camera. His expression is thoughtful, his brow slightly furrowed as if he's lost in contemplation. The film grain adds a textured, timeless quality to the image, evoking a sense of nostalgia. Around him, the cityscape is filled with vintage buildings, cobblestone sidewalks, and softly blurred figures passing by, their outlines faint and indistinct. Streetlights cast a gentle glow, while shadows play across the boy's path, adding depth to the scene. The lighting highlights the boy's subtle smile, hinting at a fleeting moment of curiosity. The overall cinematic atmosphere, complete with classic film still aesthetics and dramatic contrasts, gives the scene an evocative and introspective feel."
16image = "https://github.com/PKU-YuanGroup/ConsisID/blob/main/asserts/example_images/2.png?raw=true"
17
18id_cond, id_vit_hidden, image, face_kps = process_face_embeddings_infer(
19 face_helper_1,
20 face_clip_model,
21 face_helper_2,
22 eva_transform_mean,
23 eva_transform_std,
24 face_main_model,
25 "cuda",
26 torch.bfloat16,
27 image,
28 is_align_face=True,
29)
30
31video = pipe(
32 image=image,
33 prompt=prompt,
34 num_inference_steps=50,
35 guidance_scale=6.0,
36 use_dynamic_cfg=False,
37 id_vit_hidden=id_vit_hidden,
38 id_cond=id_cond,
39 kps_cond=face_kps,
40 generator=torch.Generator("cuda").manual_seed(42),
41)
42export_to_video(video.frames[0], "output.mp4", fps=8)1a man is playing guitar.
2
3Change the sentence above to something like this (add some facial changes, even if they are minor. Don't make the sentence too long):
4
5The video features a man standing next to an airplane, engaged in a conversation on his cell phone. he is wearing sunglasses and a black top, and he appears to be talking seriously. The airplane has a green stripe running along its side, and there is a large engine visible behind his. The man seems to be standing near the entrance of the airplane, possibly preparing to board or just having disembarked. The setting suggests that he might be at an airport or a private airfield. The overall atmosphere of the video is professional and focused, with the man's attire and the presence of the airplane indicating a business or travel context.| Feature (overlay the previous) | Max Memory Allocated | Max Memory Reserved |
|---|---|---|
| - | 37 GB | 44 GB |
| enable_model_cpu_offload | 22 GB | 25 GB |
| enable_sequential_cpu_offload | 16 GB | 22 GB |
| vae.enable_slicing | 16 GB | 22 GB |
| vae.enable_tiling | 5 GB | 7 GB |
1# turn on if you don't have multiple GPUs or enough GPU memory(such as H100)
2pipe.enable_model_cpu_offload()
3pipe.enable_sequential_cpu_offload()
4pipe.vae.enable_slicing()
5pipe.vae.enable_tiling()1@inproceedings{yuan2025identity,
2 title={Identity-preserving text-to-video generation by frequency decomposition},
3 author={Yuan, Shenghai and Huang, Jinfa and He, Xianyi and Ge, Yunyang and Shi, Yujun and Chen, Liuhan and Luo, Jiebo and Yuan, Li},
4 booktitle={Proceedings of the Computer Vision and Pattern Recognition Conference},
5 pages={12978--12988},
6 year={2025}
7}