Spaces:
Paused
Paused
Update scripts/run_gradio.sh
Browse files- scripts/run_gradio.sh +17 -13
scripts/run_gradio.sh
CHANGED
|
@@ -1,13 +1,17 @@
|
|
| 1 |
#!/bin/bash
|
| 2 |
|
| 3 |
-
|
|
|
|
|
|
|
|
|
|
| 4 |
export PYTHONPATH=./
|
| 5 |
|
| 6 |
-
|
| 7 |
-
MODEL_DIR
|
| 8 |
-
CHECKPOINT_FILE
|
| 9 |
|
| 10 |
-
# Step 1:
|
|
|
|
| 11 |
if [ -f "$CHECKPOINT_FILE" ]; then
|
| 12 |
echo "β
Model checkpoint already exists. Skipping download."
|
| 13 |
else
|
|
@@ -15,10 +19,8 @@ else
|
|
| 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,
|
|
@@ -26,7 +28,7 @@ snapshot_download(
|
|
| 26 |
)
|
| 27 |
EOF
|
| 28 |
|
| 29 |
-
#
|
| 30 |
if [ ! -f "$CHECKPOINT_FILE" ]; then
|
| 31 |
echo "β Failed to download model checkpoint. Exiting."
|
| 32 |
exit 1
|
|
@@ -34,11 +36,11 @@ EOF
|
|
| 34 |
echo "β
Model downloaded successfully."
|
| 35 |
fi
|
| 36 |
|
| 37 |
-
# Step 2:
|
| 38 |
echo "π Starting flask_audio.py..."
|
| 39 |
-
torchrun --nnodes=1 --nproc_per_node=8 --master_port
|
| 40 |
--input 'assets/test.csv' \
|
| 41 |
-
--ckpt ${CHECKPOINT_FILE} \
|
| 42 |
--sample-n-frames 129 \
|
| 43 |
--seed 128 \
|
| 44 |
--image-size 704 \
|
|
@@ -47,6 +49,8 @@ torchrun --nnodes=1 --nproc_per_node=8 --master_port 29605 hymm_gradio/flask_aud
|
|
| 47 |
--use-deepcache 1 \
|
| 48 |
--flow-shift-eval-video 5.0 &
|
| 49 |
|
| 50 |
-
# Step 3:
|
| 51 |
echo "π’ Starting gradio_audio.py UI..."
|
| 52 |
-
|
|
|
|
|
|
|
|
|
| 1 |
#!/bin/bash
|
| 2 |
|
| 3 |
+
set -e # Exit immediately on error
|
| 4 |
+
set -o pipefail # Catch errors in pipelines
|
| 5 |
+
|
| 6 |
+
JOBS_DIR=$(dirname "$(dirname "$0")")
|
| 7 |
export PYTHONPATH=./
|
| 8 |
|
| 9 |
+
MODEL_BASE=./weights
|
| 10 |
+
MODEL_DIR="${MODEL_BASE}/ckpts/hunyuan-video-t2v-720p"
|
| 11 |
+
CHECKPOINT_FILE="${MODEL_DIR}/transformers/mp_rank_00_model_states.pt"
|
| 12 |
|
| 13 |
+
# Step 1: Ensure model is downloaded
|
| 14 |
+
echo "π¦ Checking model checkpoint..."
|
| 15 |
if [ -f "$CHECKPOINT_FILE" ]; then
|
| 16 |
echo "β
Model checkpoint already exists. Skipping download."
|
| 17 |
else
|
|
|
|
| 19 |
python3 - <<EOF
|
| 20 |
from huggingface_hub import snapshot_download
|
| 21 |
import os
|
|
|
|
| 22 |
target_dir = "${MODEL_DIR}"
|
| 23 |
os.makedirs(target_dir, exist_ok=True)
|
|
|
|
| 24 |
snapshot_download(
|
| 25 |
repo_id="tencent/HunyuanVideo-Avatar",
|
| 26 |
local_dir=target_dir,
|
|
|
|
| 28 |
)
|
| 29 |
EOF
|
| 30 |
|
| 31 |
+
# Confirm model was downloaded
|
| 32 |
if [ ! -f "$CHECKPOINT_FILE" ]; then
|
| 33 |
echo "β Failed to download model checkpoint. Exiting."
|
| 34 |
exit 1
|
|
|
|
| 36 |
echo "β
Model downloaded successfully."
|
| 37 |
fi
|
| 38 |
|
| 39 |
+
# Step 2: Launch the Flask audio server
|
| 40 |
echo "π Starting flask_audio.py..."
|
| 41 |
+
torchrun --nnodes=1 --nproc_per_node=8 --master_port=29605 hymm_gradio/flask_audio.py \
|
| 42 |
--input 'assets/test.csv' \
|
| 43 |
+
--ckpt "${CHECKPOINT_FILE}" \
|
| 44 |
--sample-n-frames 129 \
|
| 45 |
--seed 128 \
|
| 46 |
--image-size 704 \
|
|
|
|
| 49 |
--use-deepcache 1 \
|
| 50 |
--flow-shift-eval-video 5.0 &
|
| 51 |
|
| 52 |
+
# Step 3: Run Gradio UI
|
| 53 |
echo "π’ Starting gradio_audio.py UI..."
|
| 54 |
+
# Add your command to run gradio_audio.py here
|
| 55 |
+
# Example (uncomment and adjust as needed):
|
| 56 |
+
|