Commit 142f6872 authored by Dongz's avatar Dongz Committed by GitHub
Browse files

[hotfix]: fix config, requirements, update readme (#21)

parent 7fde7063
...@@ -21,12 +21,20 @@ ...@@ -21,12 +21,20 @@
## Fast Start Up With Conda ## Fast Start Up With Conda
```shell ```shell
# clone repo and submodules
git clone https://github.com/ModelTC/lightx2v.git lightx2v && cd lightx2v git clone https://github.com/ModelTC/lightx2v.git lightx2v && cd lightx2v
git submodule update --init --recursive git submodule update --init --recursive
# create conda env and install requirments
conda create -n lightx2v python=3.11 && conda activate lightx2v conda create -n lightx2v python=3.11 && conda activate lightx2v
pip install -r requirements.txt pip install -r requirements.txt
# install flash-attention 2
RUN cd lightx2v/3rd/flash-attention && pip install --no-cache-dir -v -e .
# install flash-attention 3, only if hopper
RUN cd lightx2v/3rd/flash-attention/hopper && pip install --no-cache-dir -v -e .
# modify the parameters of the running script # modify the parameters of the running script
bash scripts/run_hunyuan_t2v.sh bash scripts/run_hunyuan_t2v.sh
``` ```
...@@ -35,7 +43,7 @@ bash scripts/run_hunyuan_t2v.sh ...@@ -35,7 +43,7 @@ bash scripts/run_hunyuan_t2v.sh
```shell ```shell
docker pull lightx2v/lightx2v:latest docker pull lightx2v/lightx2v:latest
docker run -it --rm --gpus all --ipc=host lightx2v/lightx2v:latest docker run -it --rm --name lightx2v --gpus all --ipc=host lightx2v/lightx2v:latest
``` ```
## Contributing Guidelines ## Contributing Guidelines
......
...@@ -285,9 +285,8 @@ if __name__ == "__main__": ...@@ -285,9 +285,8 @@ if __name__ == "__main__":
parser.add_argument("--model_cls", type=str, required=True, choices=["wan2.1", "hunyuan"], default="hunyuan") parser.add_argument("--model_cls", type=str, required=True, choices=["wan2.1", "hunyuan"], default="hunyuan")
parser.add_argument("--task", type=str, choices=["t2v", "i2v"], default="t2v") parser.add_argument("--task", type=str, choices=["t2v", "i2v"], default="t2v")
parser.add_argument("--model_path", type=str, required=True) parser.add_argument("--model_path", type=str, required=True)
parser.add_argument("--config_path", type=str, default=None) parser.add_argument("--image_path", type=str, default=None, help="The path to input image file or path for image-to-video (i2v) task")
parser.add_argument("--image_path", type=str, default=None) parser.add_argument("--save_video_path", type=str, default="./output_lightx2v.mp4", help="The path to save video path/file")
parser.add_argument("--save_video_path", type=str, default="./output_ligthx2v.mp4")
parser.add_argument("--prompt", type=str, required=True) parser.add_argument("--prompt", type=str, required=True)
parser.add_argument("--infer_steps", type=int, required=True) parser.add_argument("--infer_steps", type=int, required=True)
parser.add_argument("--target_video_length", type=int, required=True) parser.add_argument("--target_video_length", type=int, required=True)
......
import json import json
import os
from easydict import EasyDict from easydict import EasyDict
...@@ -11,9 +12,11 @@ def set_config(args): ...@@ -11,9 +12,11 @@ def set_config(args):
else: else:
config.mm_config = None config.mm_config = None
if args.config_path is not None: try:
with open(args.config_path, "r") as f: with open(os.path.join(args.model_path, "config.json"), "r") as f:
model_config = json.load(f) model_config = json.load(f)
config.update(model_config) config.update(model_config)
except Exception as e:
print(e)
return config return config
...@@ -29,7 +29,6 @@ fastapi==0.115.12 ...@@ -29,7 +29,6 @@ fastapi==0.115.12
fastapi-cli==0.0.7 fastapi-cli==0.0.7
fastrlock==0.8.3 fastrlock==0.8.3
filelock==3.18.0 filelock==3.18.0
flash_attn_3==3.0.0b1
frozenlist==1.5.0 frozenlist==1.5.0
fsspec==2025.3.2 fsspec==2025.3.2
ftfy==6.3.1 ftfy==6.3.1
...@@ -149,3 +148,6 @@ xformers==0.0.29.post2 ...@@ -149,3 +148,6 @@ xformers==0.0.29.post2
xgrammar==0.1.16 xgrammar==0.1.16
yarl==1.18.3 yarl==1.18.3
zipp==3.21.0 zipp==3.21.0
ruff==0.11.6
pre_commit==4.2.0
easydict==1.13
...@@ -3,7 +3,6 @@ ...@@ -3,7 +3,6 @@
# set path and first # set path and first
lightx2v_path="" lightx2v_path=""
model_path="" model_path=""
config_path=""
# check section # check section
if [ -z "${CUDA_VISIBLE_DEVICES}" ]; then if [ -z "${CUDA_VISIBLE_DEVICES}" ]; then
...@@ -22,11 +21,6 @@ if [ -z "${model_path}" ]; then ...@@ -22,11 +21,6 @@ if [ -z "${model_path}" ]; then
exit 1 exit 1
fi fi
if [ -z "${config_path}" ]; then
echo "Error: config_path is not set. Please set this variable first."
exit 1
fi
export PYTHONPATH=${lightx2v_path}:$PYTHONPATH export PYTHONPATH=${lightx2v_path}:$PYTHONPATH
export ENABLE_PROFILING_DEBUG=true export ENABLE_PROFILING_DEBUG=true
...@@ -44,7 +38,6 @@ python ${lightx2v_path}/lightx2v/__main__.py \ ...@@ -44,7 +38,6 @@ python ${lightx2v_path}/lightx2v/__main__.py \
--attention_type flash_attn3 \ --attention_type flash_attn3 \
--seed 42 \ --seed 42 \
--sample_neg_promp 色调艳丽,过曝,静态,细节模糊不清,字幕,风格,作品,画作,画面,静止,整体发灰,最差质量,低质量,JPEG压缩残留,丑陋的,残缺的,多余的手指,画得不好的手部,画得不好的脸部,畸形的,毁容的,形态畸形的肢体,手指融合,静止不动的画面,杂乱的背景,三条腿,背景人很多,倒着走 \ --sample_neg_promp 色调艳丽,过曝,静态,细节模糊不清,字幕,风格,作品,画作,画面,静止,整体发灰,最差质量,低质量,JPEG压缩残留,丑陋的,残缺的,多余的手指,画得不好的手部,画得不好的脸部,畸形的,毁容的,形态畸形的肢体,手指融合,静止不动的画面,杂乱的背景,三条腿,背景人很多,倒着走 \
--config_path $config_path \
--save_video_path ./output_lightx2v_wan_i2v.mp4 \ --save_video_path ./output_lightx2v_wan_i2v.mp4 \
--sample_guide_scale 5 \ --sample_guide_scale 5 \
--sample_shift 5 \ --sample_shift 5 \
......
#!/bin/bash #!/bin/bash
# set path and first # set path and first
script_dir="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)" lightx2v_path=''
lightx2v_path="$(dirname "$script_dir")" model_path=''
lora_path=''
model_path=/mnt/aigc/shared_data/cache/huggingface/hub/Wan2.1-I2V-14B-480P
config_path=$model_path/config.json
lora_path=/mnt/aigc/shared_data/wan_quant/lora/toy_zoe_epoch_324.safetensors
# check section # check section
if [ -z "${CUDA_VISIBLE_DEVICES}" ]; then if [ -z "${CUDA_VISIBLE_DEVICES}" ]; then
cuda_devices=0 cuda_devices=0
...@@ -19,8 +17,8 @@ if [ -z "${model_path}" ]; then ...@@ -19,8 +17,8 @@ if [ -z "${model_path}" ]; then
exit 1 exit 1
fi fi
if [ -z "${config_path}" ]; then if [ -z "${lora_path}" ]; then
echo "Error: config_path is not set. Please set this variable first." echo "Error: lora_path is not set. Please set this variable first."
exit 1 exit 1
fi fi
...@@ -40,7 +38,6 @@ python -m lightx2v \ ...@@ -40,7 +38,6 @@ python -m lightx2v \
--attention_type flash_attn3 \ --attention_type flash_attn3 \
--seed 42 \ --seed 42 \
--sample_neg_promp "画面过曝,模糊,文字,字幕" \ --sample_neg_promp "画面过曝,模糊,文字,字幕" \
--config_path $config_path \
--save_video_path ./output_lightx2v_wan_i2v.mp4 \ --save_video_path ./output_lightx2v_wan_i2v.mp4 \
--sample_guide_scale 5 \ --sample_guide_scale 5 \
--sample_shift 5 \ --sample_shift 5 \
......
...@@ -3,7 +3,6 @@ ...@@ -3,7 +3,6 @@
# set path and first # set path and first
lightx2v_path="" lightx2v_path=""
model_path="" model_path=""
config_path=""
# check section # check section
if [ -z "${CUDA_VISIBLE_DEVICES}" ]; then if [ -z "${CUDA_VISIBLE_DEVICES}" ]; then
...@@ -22,11 +21,6 @@ if [ -z "${model_path}" ]; then ...@@ -22,11 +21,6 @@ if [ -z "${model_path}" ]; then
exit 1 exit 1
fi fi
if [ -z "${config_path}" ]; then
echo "Error: config_path is not set. Please set this variable first."
exit 1
fi
export PYTHONPATH=${lightx2v_path}:$PYTHONPATH export PYTHONPATH=${lightx2v_path}:$PYTHONPATH
export ENABLE_PROFILING_DEBUG=true export ENABLE_PROFILING_DEBUG=true
...@@ -44,7 +38,6 @@ python ${lightx2v_path}/lightx2v/__main__.py \ ...@@ -44,7 +38,6 @@ python ${lightx2v_path}/lightx2v/__main__.py \
--attention_type flash_attn2 \ --attention_type flash_attn2 \
--seed 42 \ --seed 42 \
--sample_neg_promp 色调艳丽,过曝,静态,细节模糊不清,字幕,风格,作品,画作,画面,静止,整体发灰,最差质量,低质量,JPEG压缩残留,丑陋的,残缺的,多余的手指,画得不好的手部,画得不好的脸部,畸形的,毁容的,形态畸形的肢体,手指融合,静止不动的画面,杂乱的背景,三条腿,背景人很多,倒着走 \ --sample_neg_promp 色调艳丽,过曝,静态,细节模糊不清,字幕,风格,作品,画作,画面,静止,整体发灰,最差质量,低质量,JPEG压缩残留,丑陋的,残缺的,多余的手指,画得不好的手部,画得不好的脸部,畸形的,毁容的,形态畸形的肢体,手指融合,静止不动的画面,杂乱的背景,三条腿,背景人很多,倒着走 \
--config_path $config_path \
--save_video_path ./output_lightx2v_wan_t2v.mp4 \ --save_video_path ./output_lightx2v_wan_t2v.mp4 \
--sample_guide_scale 6 \ --sample_guide_scale 6 \
--sample_shift 8 \ --sample_shift 8 \
......
...@@ -3,7 +3,6 @@ ...@@ -3,7 +3,6 @@
# set path and first # set path and first
lightx2v_path="" lightx2v_path=""
model_path="" model_path=""
config_path=""
# check section # check section
if [ -z "${CUDA_VISIBLE_DEVICES}" ]; then if [ -z "${CUDA_VISIBLE_DEVICES}" ]; then
...@@ -22,11 +21,6 @@ if [ -z "${model_path}" ]; then ...@@ -22,11 +21,6 @@ if [ -z "${model_path}" ]; then
exit 1 exit 1
fi fi
if [ -z "${config_path}" ]; then
echo "Error: config_path is not set. Please set this variable first."
exit 1
fi
export PYTHONPATH=${lightx2v_path}:$PYTHONPATH export PYTHONPATH=${lightx2v_path}:$PYTHONPATH
export ENABLE_PROFILING_DEBUG=true export ENABLE_PROFILING_DEBUG=true
...@@ -43,7 +37,6 @@ torchrun --nproc_per_node=4 ${lightx2v_path}/lightx2v/__main__.py \ ...@@ -43,7 +37,6 @@ torchrun --nproc_per_node=4 ${lightx2v_path}/lightx2v/__main__.py \
--attention_type flash_attn2 \ --attention_type flash_attn2 \
--seed 42 \ --seed 42 \
--sample_neg_promp 色调艳丽,过曝,静态,细节模糊不清,字幕,风格,作品,画作,画面,静止,整体发灰,最差质量,低质量,JPEG压缩残留,丑陋的,残缺的,多余的手指,画得不好的手部,画得不好的脸部,畸形的,毁容的,形态畸形的肢体,手指融合,静止不动的画面,杂乱的背景,三条腿,背景人很多,倒着走 \ --sample_neg_promp 色调艳丽,过曝,静态,细节模糊不清,字幕,风格,作品,画作,画面,静止,整体发灰,最差质量,低质量,JPEG压缩残留,丑陋的,残缺的,多余的手指,画得不好的手部,画得不好的脸部,畸形的,毁容的,形态畸形的肢体,手指融合,静止不动的画面,杂乱的背景,三条腿,背景人很多,倒着走 \
--config_path $config_path \
--sample_guide_scale 6 \ --sample_guide_scale 6 \
--sample_shift 8 \ --sample_shift 8 \
--parallel_attn_type ring \ --parallel_attn_type ring \
...@@ -62,7 +55,6 @@ torchrun --nproc_per_node=4 ${lightx2v_path}/lightx2v/__main__.py \ ...@@ -62,7 +55,6 @@ torchrun --nproc_per_node=4 ${lightx2v_path}/lightx2v/__main__.py \
--attention_type flash_attn2 \ --attention_type flash_attn2 \
--seed 42 \ --seed 42 \
--sample_neg_promp 色调艳丽,过曝,静态,细节模糊不清,字幕,风格,作品,画作,画面,静止,整体发灰,最差质量,低质量,JPEG压缩残留,丑陋的,残缺的,多余的手指,画得不好的手部,画得不好的脸部,畸形的,毁容的,形态畸形的肢体,手指融合,静止不动的画面,杂乱的背景,三条腿,背景人很多,倒着走 \ --sample_neg_promp 色调艳丽,过曝,静态,细节模糊不清,字幕,风格,作品,画作,画面,静止,整体发灰,最差质量,低质量,JPEG压缩残留,丑陋的,残缺的,多余的手指,画得不好的手部,画得不好的脸部,畸形的,毁容的,形态畸形的肢体,手指融合,静止不动的画面,杂乱的背景,三条腿,背景人很多,倒着走 \
--config_path $config_path \
--sample_guide_scale 6 \ --sample_guide_scale 6 \
--sample_shift 8 \ --sample_shift 8 \
--parallel_attn_type ulysses \ --parallel_attn_type ulysses \
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment