Spaces:
Paused
Paused
Update app.py
Browse files
app.py
CHANGED
|
@@ -2,65 +2,80 @@ import os
|
|
| 2 |
import sys
|
| 3 |
import subprocess
|
| 4 |
import gradio as gr
|
| 5 |
-
from huggingface_hub import
|
| 6 |
|
| 7 |
MODEL_REPO = "tencent/HunyuanVideo-Avatar"
|
| 8 |
BASE_DIR = os.getcwd()
|
| 9 |
WEIGHTS_DIR = os.path.join(BASE_DIR, "weights")
|
| 10 |
OUTPUT_BASEPATH = os.path.join(BASE_DIR, "results-poor")
|
| 11 |
|
| 12 |
-
|
| 13 |
-
|
|
|
|
|
|
|
|
|
|
| 14 |
|
| 15 |
-
|
| 16 |
-
|
|
|
|
| 17 |
|
| 18 |
-
|
| 19 |
-
|
| 20 |
-
|
| 21 |
-
|
| 22 |
-
|
| 23 |
-
|
| 24 |
-
|
| 25 |
-
|
| 26 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 27 |
|
| 28 |
def download_ckpts():
|
| 29 |
-
os.makedirs(WEIGHTS_DIR, exist_ok=True)
|
| 30 |
logs = []
|
|
|
|
| 31 |
|
| 32 |
-
for
|
| 33 |
-
|
| 34 |
-
|
| 35 |
-
|
| 36 |
-
if os.path.exists(target_path):
|
| 37 |
-
logs.append(f"β
Exists: {target_path}")
|
| 38 |
continue
|
| 39 |
|
| 40 |
-
os.makedirs(os.path.dirname(
|
| 41 |
-
logs.append(f"β¬οΈ Downloading: {filepath}")
|
| 42 |
try:
|
|
|
|
| 43 |
hf_hub_download(
|
| 44 |
repo_id=MODEL_REPO,
|
| 45 |
-
filename=
|
| 46 |
-
local_dir=os.path.dirname(
|
| 47 |
-
local_dir_use_symlinks=False
|
| 48 |
)
|
| 49 |
except Exception as e:
|
| 50 |
-
logs.append(f"β Failed
|
|
|
|
| 51 |
return "\n".join(logs)
|
| 52 |
|
| 53 |
def run_sample_gpu_poor():
|
| 54 |
-
|
| 55 |
-
|
| 56 |
-
)
|
| 57 |
-
|
| 58 |
-
return f"β Missing checkpoint: {checkpoint_fp8}"
|
| 59 |
|
| 60 |
cmd = [
|
| 61 |
"python3", "hymm_sp/sample_gpu_poor.py",
|
| 62 |
"--input", "assets/test.csv",
|
| 63 |
-
"--ckpt",
|
| 64 |
"--sample-n-frames", "129",
|
| 65 |
"--seed", "128",
|
| 66 |
"--image-size", "704",
|
|
@@ -92,7 +107,7 @@ def download_and_run():
|
|
| 92 |
|
| 93 |
# Gradio UI
|
| 94 |
with gr.Blocks() as demo:
|
| 95 |
-
gr.Markdown("## π¦ Download
|
| 96 |
output = gr.Textbox(lines=30, label="Logs")
|
| 97 |
button = gr.Button("π Download + Run")
|
| 98 |
button.click(fn=download_and_run, outputs=output)
|
|
|
|
| 2 |
import sys
|
| 3 |
import subprocess
|
| 4 |
import gradio as gr
|
| 5 |
+
from huggingface_hub import hf_hub_download
|
| 6 |
|
| 7 |
MODEL_REPO = "tencent/HunyuanVideo-Avatar"
|
| 8 |
BASE_DIR = os.getcwd()
|
| 9 |
WEIGHTS_DIR = os.path.join(BASE_DIR, "weights")
|
| 10 |
OUTPUT_BASEPATH = os.path.join(BASE_DIR, "results-poor")
|
| 11 |
|
| 12 |
+
ESSENTIAL_PATHS = [
|
| 13 |
+
# Transformers
|
| 14 |
+
#"hunyuan-video-t2v-720p/transformers/mp_rank_00_model_states.pt",
|
| 15 |
+
"hunyuan-video-t2v-720p/transformers/mp_rank_00_model_states_fp8.pt",
|
| 16 |
+
#"hunyuan-video-t2v-720p/transformers/mp_rank_00_model_states_fp8_map.pt",
|
| 17 |
|
| 18 |
+
# VAE
|
| 19 |
+
"hunyuan-video-t2v-720p/vae/config.json",
|
| 20 |
+
"hunyuan-video-t2v-720p/vae/pytorch_model.pt",
|
| 21 |
|
| 22 |
+
# # llava_llama_image
|
| 23 |
+
# "llava_llama_image/model-00001-of-00004.safetensors",
|
| 24 |
+
# "llava_llama_image/model-00002-of-00004.safetensors",
|
| 25 |
+
# "llava_llama_image/model-00003-of-00004.safetensors",
|
| 26 |
+
# "llava_llama_image/model-00004-of-00004.safetensors",
|
| 27 |
+
# "llava_llama_image/config.json",
|
| 28 |
+
|
| 29 |
+
# text_encoder_2
|
| 30 |
+
"text_encoder_2/config.json",
|
| 31 |
+
"text_encoder_2/pytorch_model.bin",
|
| 32 |
+
|
| 33 |
+
# whisper-tiny
|
| 34 |
+
"whisper-tiny/config.json",
|
| 35 |
+
"whisper-tiny/pytorch_model.bin",
|
| 36 |
+
"whisper-tiny/tokenizer.json",
|
| 37 |
+
"whisper-tiny/tokenizer_config.json",
|
| 38 |
+
"whisper-tiny/vocab.json",
|
| 39 |
+
|
| 40 |
+
# det_align
|
| 41 |
+
"det_align/config.json",
|
| 42 |
+
"det_align/pytorch_model.bin",
|
| 43 |
+
]
|
| 44 |
|
| 45 |
def download_ckpts():
|
|
|
|
| 46 |
logs = []
|
| 47 |
+
os.makedirs(os.path.join(WEIGHTS_DIR, "ckpts"), exist_ok=True)
|
| 48 |
|
| 49 |
+
for path in ESSENTIAL_PATHS:
|
| 50 |
+
local_path = os.path.join(WEIGHTS_DIR, "ckpts", path)
|
| 51 |
+
if os.path.exists(local_path):
|
| 52 |
+
logs.append(f"β
Exists: {path}")
|
|
|
|
|
|
|
| 53 |
continue
|
| 54 |
|
| 55 |
+
os.makedirs(os.path.dirname(local_path), exist_ok=True)
|
|
|
|
| 56 |
try:
|
| 57 |
+
logs.append(f"β¬οΈ Downloading: {path}")
|
| 58 |
hf_hub_download(
|
| 59 |
repo_id=MODEL_REPO,
|
| 60 |
+
filename="ckpts/" + path,
|
| 61 |
+
local_dir=os.path.dirname(local_path),
|
| 62 |
+
local_dir_use_symlinks=False,
|
| 63 |
)
|
| 64 |
except Exception as e:
|
| 65 |
+
logs.append(f"β Failed: {path} - {str(e)}")
|
| 66 |
+
|
| 67 |
return "\n".join(logs)
|
| 68 |
|
| 69 |
def run_sample_gpu_poor():
|
| 70 |
+
ckpt_fp8 = os.path.join(WEIGHTS_DIR, "ckpts", "hunyuan-video-t2v-720p", "transformers", "mp_rank_00_model_states_fp8.pt")
|
| 71 |
+
|
| 72 |
+
if not os.path.isfile(ckpt_fp8):
|
| 73 |
+
return f"β Missing checkpoint: {ckpt_fp8}"
|
|
|
|
| 74 |
|
| 75 |
cmd = [
|
| 76 |
"python3", "hymm_sp/sample_gpu_poor.py",
|
| 77 |
"--input", "assets/test.csv",
|
| 78 |
+
"--ckpt", ckpt_fp8,
|
| 79 |
"--sample-n-frames", "129",
|
| 80 |
"--seed", "128",
|
| 81 |
"--image-size", "704",
|
|
|
|
| 107 |
|
| 108 |
# Gradio UI
|
| 109 |
with gr.Blocks() as demo:
|
| 110 |
+
gr.Markdown("## π¦ Download Selective Checkpoints + Run sample_gpu_poor.py")
|
| 111 |
output = gr.Textbox(lines=30, label="Logs")
|
| 112 |
button = gr.Button("π Download + Run")
|
| 113 |
button.click(fn=download_and_run, outputs=output)
|