File size: 4,418 Bytes
e13f5a4
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
# Prince Xiang HunyuanVideo LoRA

This repository contains the necessary setup and scripts to generate videos using the HunyuanVideo model with a LoRA (Low-Rank Adaptation) fine-tuned for Prince Xiang. Below are the instructions to install dependencies, download models, and run the demo.

---

## Installation

### Step 1: Install System Dependencies
Run the following command to install required system packages:
```bash
sudo apt-get update && sudo apt-get install git-lfs ffmpeg cbm
```

### Step 2: Clone the Repository
Clone the repository and navigate to the project directory:
```bash
git clone https://huggingface.co/svjack/Prince_Xiang_ConsistentID_HunyuanVideo_lora
cd Prince_Xiang_ConsistentID_HunyuanVideo_lora
```

### Step 3: Install Python Dependencies
Install the required Python packages:
```bash
conda create -n py310 python=3.10
conda activate py310
pip install ipykernel
python -m ipykernel install --user --name py310 --display-name "py310"

pip install -r requirements.txt
pip install ascii-magic matplotlib tensorboard huggingface_hub
pip install moviepy==1.0.3
pip install sageattention==1.0.6

pip install torch==2.5.0 torchvision
```

---

## Download Models

### Step 1: Download HunyuanVideo Model
Download the HunyuanVideo model and place it in the `ckpts` directory:
```bash
huggingface-cli download tencent/HunyuanVideo --local-dir ./ckpts
```

### Step 2: Download LLaVA Model
Download the LLaVA model and preprocess it:
```bash
cd ckpts
huggingface-cli download xtuner/llava-llama-3-8b-v1_1-transformers --local-dir ./llava-llama-3-8b-v1_1-transformers
wget https://raw.githubusercontent.com/Tencent/HunyuanVideo/refs/heads/main/hyvideo/utils/preprocess_text_encoder_tokenizer_utils.py
python preprocess_text_encoder_tokenizer_utils.py --input_dir llava-llama-3-8b-v1_1-transformers --output_dir text_encoder
```

### Step 3: Download CLIP Model
Download the CLIP model for the text encoder:
```bash
huggingface-cli download openai/clip-vit-large-patch14 --local-dir ./text_encoder_2
```

---

## Demo

### Generate Video 1: Prince Xiang
Run the following command to generate a video of Prince Xiang:
```bash
python hv_generate_video.py \
    --fp8 \
    --video_size 544 960 \
    --video_length 60 \
    --infer_steps 30 \
    --prompt "Unreal 5 render of a handsome man img. warm atmosphere, at home, bedroom. a small fishing village on a pier in the background." \
    --save_path . \
    --output_type both \
    --dit ckpts/hunyuan-video-t2v-720p/transformers/mp_rank_00_model_states.pt \
    --attn_mode sdpa \
    --vae ckpts/hunyuan-video-t2v-720p/vae/pytorch_model.pt \
    --vae_chunk_size 32 \
    --vae_spatial_tile_sample_min_size 128 \
    --text_encoder1 ckpts/text_encoder \
    --text_encoder2 ckpts/text_encoder_2 \
    --seed 1234 \
    --lora_multiplier 1.0 \
    --lora_weight Xiang_Consis_im_lora_dir/Xiang_Consis_im_lora-000006.safetensors
```


<video controls autoplay src="https://huggingface.co/svjack/Prince_Xiang_ConsistentID_HunyuanVideo_lora/resolve/main/20250209-123847_1234.mp4 "></video>


### Generate Video 2: Prince Xiang
Run the following command to generate a video of Prince Xiang:
```bash
python hv_generate_video.py \
    --fp8 \
    --video_size 544 960 \
    --video_length 60 \
    --infer_steps 30 \
    --prompt "Unreal 5 render of a handsome man, warm atmosphere, in a lush, vibrant forest. The scene is bathed in golden sunlight filtering through the dense canopy." \
    --save_path . \
    --output_type both \
    --dit ckpts/hunyuan-video-t2v-720p/transformers/mp_rank_00_model_states.pt \
    --attn_mode sdpa \
    --vae ckpts/hunyuan-video-t2v-720p/vae/pytorch_model.pt \
    --vae_chunk_size 32 \
    --vae_spatial_tile_sample_min_size 128 \
    --text_encoder1 ckpts/text_encoder \
    --text_encoder2 ckpts/text_encoder_2 \
    --seed 1234 \
    --lora_multiplier 1.0 \
    --lora_weight Xiang_Consis_im_lora_dir/Xiang_Consis_im_lora-000006.safetensors

```


<video controls autoplay src="https://huggingface.co/svjack/Prince_Xiang_ConsistentID_HunyuanVideo_lora/resolve/main/20250209-131316_1234.mp4"></video>


---

## Notes
- Ensure you have sufficient GPU resources for video generation.
- Adjust the `--video_size`, `--video_length`, and `--infer_steps` parameters as needed for different output qualities and lengths.
- The `--prompt` parameter can be modified to generate videos with different scenes or actions.

---