Spaces:
Running on Zero
Running on Zero
Fix build errors and add Zero GPU support
Browse files- Add packages.txt for system dependencies (ffmpeg, mesa, OpenGL)
- Add spaces module import for Zero GPU decorator
- Fix Gradio API compatibility (remove show_share_button)
- Add PYOPENGL_PLATFORM environment variable
- Pin transformers==4.30.2 for PyTorch 2.1.0 compatibility
- Update Python version to 3.10.13 for Zero GPU support
- README.md +3 -2
- app.py +4 -3
- inference.py +14 -1
- packages.txt +8 -0
- requirements.txt +8 -5
README.md
CHANGED
|
@@ -1,15 +1,16 @@
|
|
| 1 |
---
|
| 2 |
title: TANGO
|
| 3 |
-
emoji: 🐠
|
| 4 |
colorFrom: blue
|
| 5 |
colorTo: gray
|
| 6 |
sdk: gradio
|
| 7 |
sdk_version: 5.34.2
|
| 8 |
-
python_version: 3.10.
|
| 9 |
app_file: app.py
|
| 10 |
pinned: false
|
| 11 |
short_description: Co-Speech Gesture Video Generation
|
| 12 |
license: cc-by-nc-4.0
|
|
|
|
| 13 |
---
|
| 14 |
|
| 15 |
Check out the configuration reference at https://huggingface.co/docs/hub/spaces-config-reference
|
|
|
|
| 1 |
---
|
| 2 |
title: TANGO
|
| 3 |
+
emoji: "🐠"
|
| 4 |
colorFrom: blue
|
| 5 |
colorTo: gray
|
| 6 |
sdk: gradio
|
| 7 |
sdk_version: 5.34.2
|
| 8 |
+
python_version: 3.10.13
|
| 9 |
app_file: app.py
|
| 10 |
pinned: false
|
| 11 |
short_description: Co-Speech Gesture Video Generation
|
| 12 |
license: cc-by-nc-4.0
|
| 13 |
+
suggested_hardware: zero-a10g
|
| 14 |
---
|
| 15 |
|
| 16 |
Check out the configuration reference at https://huggingface.co/docs/hub/spaces-config-reference
|
app.py
CHANGED
|
@@ -1,9 +1,12 @@
|
|
| 1 |
import os
|
| 2 |
import gradio as gr
|
| 3 |
import shutil
|
| 4 |
-
from inference import tango
|
| 5 |
import numpy as np
|
| 6 |
|
|
|
|
|
|
|
|
|
|
|
|
|
| 7 |
|
| 8 |
SCRIPT_PATH = os.path.dirname(os.path.realpath(__file__))
|
| 9 |
|
|
@@ -102,7 +105,6 @@ def make_demo():
|
|
| 102 |
interactive=False,
|
| 103 |
autoplay=False,
|
| 104 |
loop=False,
|
| 105 |
-
show_share_button=True,
|
| 106 |
)
|
| 107 |
with gr.Column(scale=4):
|
| 108 |
video_output_2 = gr.Video(
|
|
@@ -110,7 +112,6 @@ def make_demo():
|
|
| 110 |
interactive=False,
|
| 111 |
autoplay=False,
|
| 112 |
loop=False,
|
| 113 |
-
show_share_button=True,
|
| 114 |
)
|
| 115 |
with gr.Column(scale=1):
|
| 116 |
file_output_1 = gr.File(label="Download 3D Motion and Visualize in Blender")
|
|
|
|
| 1 |
import os
|
| 2 |
import gradio as gr
|
| 3 |
import shutil
|
|
|
|
| 4 |
import numpy as np
|
| 5 |
|
| 6 |
+
os.environ["PYOPENGL_PLATFORM"] = "osmesa"
|
| 7 |
+
|
| 8 |
+
from inference import tango
|
| 9 |
+
|
| 10 |
|
| 11 |
SCRIPT_PATH = os.path.dirname(os.path.realpath(__file__))
|
| 12 |
|
|
|
|
| 105 |
interactive=False,
|
| 106 |
autoplay=False,
|
| 107 |
loop=False,
|
|
|
|
| 108 |
)
|
| 109 |
with gr.Column(scale=4):
|
| 110 |
video_output_2 = gr.Video(
|
|
|
|
| 112 |
interactive=False,
|
| 113 |
autoplay=False,
|
| 114 |
loop=False,
|
|
|
|
| 115 |
)
|
| 116 |
with gr.Column(scale=1):
|
| 117 |
file_output_1 = gr.File(label="Download 3D Motion and Visualize in Blender")
|
inference.py
CHANGED
|
@@ -22,6 +22,13 @@ import smplx
|
|
| 22 |
import igraph
|
| 23 |
import fire
|
| 24 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 25 |
from utils.video_io import save_videos_from_pil
|
| 26 |
from utils.genextend_inference_utils import adjust_statistics_to_match_reference
|
| 27 |
from create_graph import path_visualization, graph_pruning, get_motion_reps_tensor, path_visualization_v2
|
|
@@ -526,7 +533,13 @@ TARGET_SR = 16000
|
|
| 526 |
OUTPUT_DIR = os.path.join(SCRIPT_PATH, "outputs/")
|
| 527 |
|
| 528 |
|
| 529 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 530 |
def tango(audio_path, character_name, seed=2024, create_graph=False, video_folder_path=None):
|
| 531 |
shutil.rmtree(OUTPUT_DIR, ignore_errors=True)
|
| 532 |
os.makedirs(OUTPUT_DIR, exist_ok=True)
|
|
|
|
| 22 |
import igraph
|
| 23 |
import fire
|
| 24 |
|
| 25 |
+
try:
|
| 26 |
+
import spaces
|
| 27 |
+
ZERO_GPU_AVAILABLE = True
|
| 28 |
+
except ImportError:
|
| 29 |
+
ZERO_GPU_AVAILABLE = False
|
| 30 |
+
spaces = None
|
| 31 |
+
|
| 32 |
from utils.video_io import save_videos_from_pil
|
| 33 |
from utils.genextend_inference_utils import adjust_statistics_to_match_reference
|
| 34 |
from create_graph import path_visualization, graph_pruning, get_motion_reps_tensor, path_visualization_v2
|
|
|
|
| 533 |
OUTPUT_DIR = os.path.join(SCRIPT_PATH, "outputs/")
|
| 534 |
|
| 535 |
|
| 536 |
+
def _gpu_decorator(func):
|
| 537 |
+
if ZERO_GPU_AVAILABLE and spaces is not None:
|
| 538 |
+
return spaces.GPU(duration=200)(func)
|
| 539 |
+
return func
|
| 540 |
+
|
| 541 |
+
|
| 542 |
+
@_gpu_decorator
|
| 543 |
def tango(audio_path, character_name, seed=2024, create_graph=False, video_folder_path=None):
|
| 544 |
shutil.rmtree(OUTPUT_DIR, ignore_errors=True)
|
| 545 |
os.makedirs(OUTPUT_DIR, exist_ok=True)
|
packages.txt
ADDED
|
@@ -0,0 +1,8 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
ffmpeg
|
| 2 |
+
libgl1-mesa-glx
|
| 3 |
+
libglib2.0-0
|
| 4 |
+
libsm6
|
| 5 |
+
libxext6
|
| 6 |
+
libxrender1
|
| 7 |
+
libosmesa6-dev
|
| 8 |
+
freeglut3-dev
|
requirements.txt
CHANGED
|
@@ -1,3 +1,5 @@
|
|
|
|
|
|
|
|
| 1 |
gradio
|
| 2 |
scikit-image==0.21.0
|
| 3 |
scikit-learn==1.3.2
|
|
@@ -10,7 +12,7 @@ opencv-python==4.8.1.78
|
|
| 10 |
tensorboardx
|
| 11 |
filterpy
|
| 12 |
cython
|
| 13 |
-
Pillow=
|
| 14 |
trimesh
|
| 15 |
pyrender
|
| 16 |
matplotlib
|
|
@@ -23,7 +25,7 @@ easydict
|
|
| 23 |
pycocotools
|
| 24 |
plyfile
|
| 25 |
timm
|
| 26 |
-
pyglet
|
| 27 |
eval_type_backport
|
| 28 |
wandb
|
| 29 |
wget
|
|
@@ -31,8 +33,8 @@ av==11.0.0
|
|
| 31 |
ffmpeg-python
|
| 32 |
mediapipe
|
| 33 |
batch-face @ git+https://github.com/elliottzheng/batch-face.git@master
|
| 34 |
-
decord
|
| 35 |
-
diffusers=
|
| 36 |
imageio==2.33.0
|
| 37 |
imageio-ffmpeg==0.4.9
|
| 38 |
omegaconf==2.2.3
|
|
@@ -43,4 +45,5 @@ igraph
|
|
| 43 |
ConfigArgParse
|
| 44 |
librosa
|
| 45 |
pytorch-fid
|
| 46 |
-
fire
|
|
|
|
|
|
| 1 |
+
spaces
|
| 2 |
+
huggingface_hub
|
| 3 |
gradio
|
| 4 |
scikit-image==0.21.0
|
| 5 |
scikit-learn==1.3.2
|
|
|
|
| 12 |
tensorboardx
|
| 13 |
filterpy
|
| 14 |
cython
|
| 15 |
+
Pillow>=9.5.0
|
| 16 |
trimesh
|
| 17 |
pyrender
|
| 18 |
matplotlib
|
|
|
|
| 25 |
pycocotools
|
| 26 |
plyfile
|
| 27 |
timm
|
| 28 |
+
pyglet<2.0.0
|
| 29 |
eval_type_backport
|
| 30 |
wandb
|
| 31 |
wget
|
|
|
|
| 33 |
ffmpeg-python
|
| 34 |
mediapipe
|
| 35 |
batch-face @ git+https://github.com/elliottzheng/batch-face.git@master
|
| 36 |
+
decord
|
| 37 |
+
diffusers>=0.24.0
|
| 38 |
imageio==2.33.0
|
| 39 |
imageio-ffmpeg==0.4.9
|
| 40 |
omegaconf==2.2.3
|
|
|
|
| 45 |
ConfigArgParse
|
| 46 |
librosa
|
| 47 |
pytorch-fid
|
| 48 |
+
fire
|
| 49 |
+
soundfile
|