# **hunyuanVideo模型**

# 镜像获取

curl -f -C - -o hy_video_latest_perf.tar.gz https://ksefile.hpccube.com:65241/efile/s/d/aGVwag==/b4ffdcfc220e2b92  

```Bash
#启动容器示例
docker run -it --network=host --name=video --privileged --device=/dev/kfd --device=/dev/dri --ipc=host --shm-size=512G --memory="700g" --group-add video --cap-add=SYS_PTRACE --security-opt seccomp=unconfined -u root --ulimit stack=-1:-1 --ulimit memlock=-1:-1  -v /etc/hosts:/etc/hosts:ro -v   /usr/local/hyhal/:/usr/local/hyhal/:ro  -v /opt/hyhal:/opt/hyhal:ro -v XXX:XXX 4c104c1ed46a /bin/bash
```

## 数据集准备

https://huggingface.co/datasets/FastVideo/HD-Mixkit-Finetune-Hunyuan/tree/main

下载整个文件夹后重命名为  Image-Vid-Finetune-HunYuan

```
数据集结构如下：
├── latent
├── prompt_attention_mask
├── prompt_embed
├── validation
└── videos2caption.json
```



## 模型下载

```Python
python -m pip install "huggingface_hub[cli]"

huggingface-cli download tencent/HunyuanVideo --local-dir ./model
```

魔塔社区地址：https://modelscope.cn/models/AI-ModelScope/HunyuanVideo/files

## 模型运行

```Python
cd scripts/finetune 
bash finetune_hunyuan.sh

#finetune_hunyuan.sh中以下路径需要改为实际路径

HOME_PATH=/public/tengcent-hy
data_path=/public/tengcent-hy/data/Image-Vid-Finetune-HunYuan/videos2caption.json
#rm -rf $ROCM_PATH/rccl/lib/*xml
torchrun --nnodes 1 --nproc_per_node 8 \
    /public/tengcent-hy/FastVideo-main-1021/fastvideo/train.py \
    --seed 42 \
    --pretrained_model_name_or_path $HOME_PATH/model/HunyuanVideo/hunyuan-video-t2v-720p \
    --dit_model_name_or_path $HOME_PATH/model/HunyuanVideo/hunyuan-video-t2v-720p/transformers/mp_rank_00_model_states.pt\
    --model_type "hunyuan" \
    --cache_dir data/.cache \
    --data_json_path ${data_path} \
    --validation_prompt_dir $HOME_PATH/data/Image-Vid-Finetune-HunYuan/validation \
```
