Spaces:
Paused
Paused
Update scripts/run_gradio.sh
Browse files- scripts/run_gradio.sh +26 -13
scripts/run_gradio.sh
CHANGED
|
@@ -5,35 +5,48 @@ export PYTHONPATH=./
|
|
| 5 |
|
| 6 |
export MODEL_BASE=./weights
|
| 7 |
MODEL_DIR=${MODEL_BASE}/ckpts/hunyuan-video-t2v-720p
|
| 8 |
-
|
| 9 |
-
|
| 10 |
-
|
| 11 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
| 12 |
from huggingface_hub import snapshot_download
|
| 13 |
import os
|
| 14 |
|
| 15 |
target_dir = "${MODEL_DIR}"
|
| 16 |
os.makedirs(target_dir, exist_ok=True)
|
| 17 |
|
| 18 |
-
|
| 19 |
-
|
| 20 |
-
|
| 21 |
-
|
| 22 |
-
|
| 23 |
EOF
|
| 24 |
|
| 25 |
-
#
|
| 26 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 27 |
|
|
|
|
|
|
|
| 28 |
torchrun --nnodes=1 --nproc_per_node=8 --master_port 29605 hymm_gradio/flask_audio.py \
|
| 29 |
--input 'assets/test.csv' \
|
| 30 |
-
--ckpt ${
|
| 31 |
--sample-n-frames 129 \
|
| 32 |
--seed 128 \
|
| 33 |
--image-size 704 \
|
| 34 |
--cfg-scale 7.5 \
|
| 35 |
--infer-steps 50 \
|
| 36 |
--use-deepcache 1 \
|
| 37 |
-
--flow-shift-eval-video 5.0
|
| 38 |
|
|
|
|
|
|
|
| 39 |
python3 hymm_gradio/gradio_audio.py
|
|
|
|
| 5 |
|
| 6 |
export MODEL_BASE=./weights
|
| 7 |
MODEL_DIR=${MODEL_BASE}/ckpts/hunyuan-video-t2v-720p
|
| 8 |
+
CHECKPOINT_FILE=${MODEL_DIR}/transformers/mp_rank_00_model_states.pt
|
| 9 |
+
|
| 10 |
+
# Step 1: Check if model already exists
|
| 11 |
+
if [ -f "$CHECKPOINT_FILE" ]; then
|
| 12 |
+
echo "✅ Model checkpoint already exists. Skipping download."
|
| 13 |
+
else
|
| 14 |
+
echo "⬇️ Model not found. Downloading from Hugging Face..."
|
| 15 |
+
python3 - <<EOF
|
| 16 |
from huggingface_hub import snapshot_download
|
| 17 |
import os
|
| 18 |
|
| 19 |
target_dir = "${MODEL_DIR}"
|
| 20 |
os.makedirs(target_dir, exist_ok=True)
|
| 21 |
|
| 22 |
+
snapshot_download(
|
| 23 |
+
repo_id="tencent/HunyuanVideo-Avatar",
|
| 24 |
+
local_dir=target_dir,
|
| 25 |
+
local_dir_use_symlinks=False
|
| 26 |
+
)
|
| 27 |
EOF
|
| 28 |
|
| 29 |
+
# Check again if download succeeded
|
| 30 |
+
if [ ! -f "$CHECKPOINT_FILE" ]; then
|
| 31 |
+
echo "❌ Failed to download model checkpoint. Exiting."
|
| 32 |
+
exit 1
|
| 33 |
+
fi
|
| 34 |
+
echo "✅ Model downloaded successfully."
|
| 35 |
+
fi
|
| 36 |
|
| 37 |
+
# Step 2: Run the Flask audio process in the background
|
| 38 |
+
echo "🚀 Starting flask_audio.py..."
|
| 39 |
torchrun --nnodes=1 --nproc_per_node=8 --master_port 29605 hymm_gradio/flask_audio.py \
|
| 40 |
--input 'assets/test.csv' \
|
| 41 |
+
--ckpt ${CHECKPOINT_FILE} \
|
| 42 |
--sample-n-frames 129 \
|
| 43 |
--seed 128 \
|
| 44 |
--image-size 704 \
|
| 45 |
--cfg-scale 7.5 \
|
| 46 |
--infer-steps 50 \
|
| 47 |
--use-deepcache 1 \
|
| 48 |
+
--flow-shift-eval-video 5.0 &
|
| 49 |
|
| 50 |
+
# Step 3: After flask is backgrounded, run Gradio UI
|
| 51 |
+
echo "🟢 Starting gradio_audio.py UI..."
|
| 52 |
python3 hymm_gradio/gradio_audio.py
|