Fix Space configuration and add missing files - Corregir configuración del Space y agregar archivos faltantes
Browse files- .gitignore +75 -0
- README.md +2 -2
- SPACE_SETUP.md +3 -0
- app.py +25 -0
- requirements.txt +2 -2
- setup.py +27 -0
- space_config.py +142 -0
.gitignore
ADDED
|
@@ -0,0 +1,75 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
# Python
|
| 2 |
+
__pycache__/
|
| 3 |
+
*.py[cod]
|
| 4 |
+
*$py.class
|
| 5 |
+
*.so
|
| 6 |
+
.Python
|
| 7 |
+
build/
|
| 8 |
+
develop-eggs/
|
| 9 |
+
dist/
|
| 10 |
+
downloads/
|
| 11 |
+
eggs/
|
| 12 |
+
.eggs/
|
| 13 |
+
lib/
|
| 14 |
+
lib64/
|
| 15 |
+
parts/
|
| 16 |
+
sdist/
|
| 17 |
+
var/
|
| 18 |
+
wheels/
|
| 19 |
+
*.egg-info/
|
| 20 |
+
.installed.cfg
|
| 21 |
+
*.egg
|
| 22 |
+
MANIFEST
|
| 23 |
+
|
| 24 |
+
# PyTorch
|
| 25 |
+
*.pth
|
| 26 |
+
*.pt
|
| 27 |
+
*.ckpt
|
| 28 |
+
*.safetensors
|
| 29 |
+
|
| 30 |
+
# Audio/Video files
|
| 31 |
+
*.mp4
|
| 32 |
+
*.avi
|
| 33 |
+
*.mov
|
| 34 |
+
*.wav
|
| 35 |
+
*.mp3
|
| 36 |
+
*.flac
|
| 37 |
+
*.aac
|
| 38 |
+
|
| 39 |
+
# Temporary files
|
| 40 |
+
*.tmp
|
| 41 |
+
*.temp
|
| 42 |
+
temp/
|
| 43 |
+
tmp/
|
| 44 |
+
|
| 45 |
+
# Logs
|
| 46 |
+
*.log
|
| 47 |
+
logs/
|
| 48 |
+
|
| 49 |
+
# Environment variables
|
| 50 |
+
.env
|
| 51 |
+
.env.local
|
| 52 |
+
.env.production
|
| 53 |
+
|
| 54 |
+
# IDE
|
| 55 |
+
.vscode/
|
| 56 |
+
.idea/
|
| 57 |
+
*.swp
|
| 58 |
+
*.swo
|
| 59 |
+
|
| 60 |
+
# OS
|
| 61 |
+
.DS_Store
|
| 62 |
+
Thumbs.db
|
| 63 |
+
|
| 64 |
+
# Jupyter
|
| 65 |
+
.ipynb_checkpoints
|
| 66 |
+
|
| 67 |
+
# Model files (large)
|
| 68 |
+
models/
|
| 69 |
+
checkpoints/
|
| 70 |
+
weights/
|
| 71 |
+
|
| 72 |
+
# Generated content
|
| 73 |
+
outputs/
|
| 74 |
+
results/
|
| 75 |
+
generated/
|
README.md
CHANGED
|
@@ -1,3 +1,3 @@
|
|
| 1 |
version https://git-lfs.github.com/spec/v1
|
| 2 |
-
oid sha256:
|
| 3 |
-
size
|
|
|
|
| 1 |
version https://git-lfs.github.com/spec/v1
|
| 2 |
+
oid sha256:c812e999cac2fa2550cc44310bfb02fa236c0209b10fe432a4bb875b70aa5237
|
| 3 |
+
size 6706
|
SPACE_SETUP.md
ADDED
|
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
version https://git-lfs.github.com/spec/v1
|
| 2 |
+
oid sha256:e86fcff3e629f22476ad4365f47da2516aceaaccd247ab976de2dbfc34ffacaf
|
| 3 |
+
size 4655
|
app.py
CHANGED
|
@@ -3,10 +3,30 @@ import random
|
|
| 3 |
import spaces
|
| 4 |
import logging
|
| 5 |
import os
|
|
|
|
| 6 |
from pathlib import Path
|
| 7 |
from datetime import datetime
|
| 8 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 9 |
import torch
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 10 |
import numpy as np
|
| 11 |
import torchaudio
|
| 12 |
from diffusers import AutoencoderKLWan, UniPCMultistepScheduler
|
|
@@ -22,9 +42,12 @@ from src.transformer_wan_nag import NagWanTransformer3DModel
|
|
| 22 |
# MMAudio imports
|
| 23 |
try:
|
| 24 |
import mmaudio
|
|
|
|
| 25 |
except ImportError:
|
|
|
|
| 26 |
os.system("pip install -e .")
|
| 27 |
import mmaudio
|
|
|
|
| 28 |
|
| 29 |
from mmaudio.eval_utils import (ModelConfig, all_model_cfg, generate as mmaudio_generate,
|
| 30 |
load_video, make_video, setup_eval_logging)
|
|
@@ -33,6 +56,8 @@ from mmaudio.model.networks import MMAudio, get_my_mmaudio
|
|
| 33 |
from mmaudio.model.sequence_config import SequenceConfig
|
| 34 |
from mmaudio.model.utils.features_utils import FeaturesUtils
|
| 35 |
|
|
|
|
|
|
|
| 36 |
# NAG Video Settings
|
| 37 |
MOD_VALUE = 32
|
| 38 |
DEFAULT_DURATION_SECONDS = 4
|
|
|
|
| 3 |
import spaces
|
| 4 |
import logging
|
| 5 |
import os
|
| 6 |
+
import sys
|
| 7 |
from pathlib import Path
|
| 8 |
from datetime import datetime
|
| 9 |
|
| 10 |
+
# Configuración para Hugging Face Spaces
|
| 11 |
+
print("🚀 Iniciando VEO3 Free Space...")
|
| 12 |
+
|
| 13 |
+
# Configurar logging
|
| 14 |
+
logging.basicConfig(level=logging.INFO)
|
| 15 |
+
logger = logging.getLogger(__name__)
|
| 16 |
+
|
| 17 |
+
# Verificar entorno del Space
|
| 18 |
+
space_id = os.getenv("SPACE_ID")
|
| 19 |
+
if space_id:
|
| 20 |
+
print(f"✅ Ejecutando en Space: {space_id}")
|
| 21 |
+
|
| 22 |
+
# Verificar GPU
|
| 23 |
import torch
|
| 24 |
+
if torch.cuda.is_available():
|
| 25 |
+
print(f"✅ GPU disponible: {torch.cuda.get_device_name()}")
|
| 26 |
+
print(f"✅ Memoria GPU: {torch.cuda.get_device_properties(0).total_memory / 1e9:.1f} GB")
|
| 27 |
+
else:
|
| 28 |
+
print("⚠️ GPU no disponible - usando CPU")
|
| 29 |
+
|
| 30 |
import numpy as np
|
| 31 |
import torchaudio
|
| 32 |
from diffusers import AutoencoderKLWan, UniPCMultistepScheduler
|
|
|
|
| 42 |
# MMAudio imports
|
| 43 |
try:
|
| 44 |
import mmaudio
|
| 45 |
+
print("✅ mmaudio importado correctamente")
|
| 46 |
except ImportError:
|
| 47 |
+
print("📦 Instalando mmaudio...")
|
| 48 |
os.system("pip install -e .")
|
| 49 |
import mmaudio
|
| 50 |
+
print("✅ mmaudio instalado e importado")
|
| 51 |
|
| 52 |
from mmaudio.eval_utils import (ModelConfig, all_model_cfg, generate as mmaudio_generate,
|
| 53 |
load_video, make_video, setup_eval_logging)
|
|
|
|
| 56 |
from mmaudio.model.sequence_config import SequenceConfig
|
| 57 |
from mmaudio.model.utils.features_utils import FeaturesUtils
|
| 58 |
|
| 59 |
+
print("✅ Todas las importaciones completadas")
|
| 60 |
+
|
| 61 |
# NAG Video Settings
|
| 62 |
MOD_VALUE = 32
|
| 63 |
DEFAULT_DURATION_SECONDS = 4
|
requirements.txt
CHANGED
|
@@ -1,3 +1,3 @@
|
|
| 1 |
version https://git-lfs.github.com/spec/v1
|
| 2 |
-
oid sha256:
|
| 3 |
-
size
|
|
|
|
| 1 |
version https://git-lfs.github.com/spec/v1
|
| 2 |
+
oid sha256:af9613be75695f3b288927b9219672d10a2bca0f85c067c5dcd22c06cd04fb86
|
| 3 |
+
size 615
|
setup.py
ADDED
|
@@ -0,0 +1,27 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
from setuptools import setup, find_packages
|
| 2 |
+
|
| 3 |
+
setup(
|
| 4 |
+
name="mmaudio",
|
| 5 |
+
version="0.1.0",
|
| 6 |
+
description="MMAudio package for audio generation",
|
| 7 |
+
packages=find_packages(),
|
| 8 |
+
install_requires=[
|
| 9 |
+
"torch>=2.1.0",
|
| 10 |
+
"torchaudio>=2.1.0",
|
| 11 |
+
"numpy>=1.21.0",
|
| 12 |
+
"librosa>=0.8.1",
|
| 13 |
+
"soundfile",
|
| 14 |
+
"av",
|
| 15 |
+
"einops>=0.6",
|
| 16 |
+
"hydra-core>=1.3.2",
|
| 17 |
+
"requests",
|
| 18 |
+
"torchdiffeq",
|
| 19 |
+
"nitrous-ema",
|
| 20 |
+
"auraloss",
|
| 21 |
+
"hydra_colorlog",
|
| 22 |
+
"tensordict",
|
| 23 |
+
"colorlog",
|
| 24 |
+
"open_clip_torch",
|
| 25 |
+
],
|
| 26 |
+
python_requires=">=3.8",
|
| 27 |
+
)
|
space_config.py
ADDED
|
@@ -0,0 +1,142 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
#!/usr/bin/env python3
|
| 2 |
+
"""
|
| 3 |
+
Script de configuración para Hugging Face Space
|
| 4 |
+
Resuelve problemas comunes de configuración y dependencias
|
| 5 |
+
"""
|
| 6 |
+
|
| 7 |
+
import os
|
| 8 |
+
import sys
|
| 9 |
+
import subprocess
|
| 10 |
+
import logging
|
| 11 |
+
|
| 12 |
+
# Configurar logging
|
| 13 |
+
logging.basicConfig(level=logging.INFO)
|
| 14 |
+
logger = logging.getLogger(__name__)
|
| 15 |
+
|
| 16 |
+
def check_environment():
|
| 17 |
+
"""Verifica el entorno de ejecución"""
|
| 18 |
+
logger.info("🔍 Verificando entorno...")
|
| 19 |
+
|
| 20 |
+
# Verificar variables de entorno del Space
|
| 21 |
+
space_id = os.getenv("SPACE_ID")
|
| 22 |
+
space_host = os.getenv("SPACE_HOST")
|
| 23 |
+
|
| 24 |
+
if space_id:
|
| 25 |
+
logger.info(f"✅ Space ID: {space_id}")
|
| 26 |
+
if space_host:
|
| 27 |
+
logger.info(f"✅ Space Host: {space_host}")
|
| 28 |
+
|
| 29 |
+
# Verificar GPU
|
| 30 |
+
try:
|
| 31 |
+
import torch
|
| 32 |
+
if torch.cuda.is_available():
|
| 33 |
+
logger.info(f"✅ GPU disponible: {torch.cuda.get_device_name()}")
|
| 34 |
+
logger.info(f"✅ Memoria GPU: {torch.cuda.get_device_properties(0).total_memory / 1e9:.1f} GB")
|
| 35 |
+
else:
|
| 36 |
+
logger.warning("⚠️ GPU no disponible")
|
| 37 |
+
except ImportError:
|
| 38 |
+
logger.error("❌ PyTorch no está instalado")
|
| 39 |
+
|
| 40 |
+
def install_mmaudio():
|
| 41 |
+
"""Instala el paquete mmaudio local"""
|
| 42 |
+
logger.info("📦 Instalando mmaudio...")
|
| 43 |
+
|
| 44 |
+
try:
|
| 45 |
+
# Verificar si mmaudio ya está instalado
|
| 46 |
+
import mmaudio
|
| 47 |
+
logger.info("✅ mmaudio ya está instalado")
|
| 48 |
+
return True
|
| 49 |
+
except ImportError:
|
| 50 |
+
pass
|
| 51 |
+
|
| 52 |
+
try:
|
| 53 |
+
# Instalar mmaudio desde el directorio local
|
| 54 |
+
result = subprocess.run(
|
| 55 |
+
["pip", "install", "-e", "."],
|
| 56 |
+
capture_output=True,
|
| 57 |
+
text=True,
|
| 58 |
+
cwd=os.getcwd()
|
| 59 |
+
)
|
| 60 |
+
|
| 61 |
+
if result.returncode == 0:
|
| 62 |
+
logger.info("✅ mmaudio instalado correctamente")
|
| 63 |
+
return True
|
| 64 |
+
else:
|
| 65 |
+
logger.error(f"❌ Error instalando mmaudio: {result.stderr}")
|
| 66 |
+
return False
|
| 67 |
+
except Exception as e:
|
| 68 |
+
logger.error(f"❌ Error en instalación: {e}")
|
| 69 |
+
return False
|
| 70 |
+
|
| 71 |
+
def verify_dependencies():
|
| 72 |
+
"""Verifica que todas las dependencias estén instaladas"""
|
| 73 |
+
logger.info("🔍 Verificando dependencias...")
|
| 74 |
+
|
| 75 |
+
dependencies = [
|
| 76 |
+
"torch",
|
| 77 |
+
"torchvision",
|
| 78 |
+
"torchaudio",
|
| 79 |
+
"diffusers",
|
| 80 |
+
"transformers",
|
| 81 |
+
"accelerate",
|
| 82 |
+
"gradio",
|
| 83 |
+
"numpy",
|
| 84 |
+
"Pillow",
|
| 85 |
+
"librosa",
|
| 86 |
+
"soundfile",
|
| 87 |
+
"av"
|
| 88 |
+
]
|
| 89 |
+
|
| 90 |
+
missing = []
|
| 91 |
+
for dep in dependencies:
|
| 92 |
+
try:
|
| 93 |
+
__import__(dep)
|
| 94 |
+
logger.info(f"✅ {dep}")
|
| 95 |
+
except ImportError:
|
| 96 |
+
logger.error(f"❌ {dep} no está instalado")
|
| 97 |
+
missing.append(dep)
|
| 98 |
+
|
| 99 |
+
if missing:
|
| 100 |
+
logger.warning(f"⚠️ Dependencias faltantes: {', '.join(missing)}")
|
| 101 |
+
return False
|
| 102 |
+
|
| 103 |
+
logger.info("✅ Todas las dependencias están instaladas")
|
| 104 |
+
return True
|
| 105 |
+
|
| 106 |
+
def setup_models():
|
| 107 |
+
"""Configura los modelos necesarios"""
|
| 108 |
+
logger.info("🤖 Configurando modelos...")
|
| 109 |
+
|
| 110 |
+
# Verificar que los directorios de modelos existan
|
| 111 |
+
model_dirs = ["models", "checkpoints"]
|
| 112 |
+
for dir_name in model_dirs:
|
| 113 |
+
if not os.path.exists(dir_name):
|
| 114 |
+
os.makedirs(dir_name)
|
| 115 |
+
logger.info(f"📁 Creado directorio: {dir_name}")
|
| 116 |
+
|
| 117 |
+
def main():
|
| 118 |
+
"""Función principal de configuración"""
|
| 119 |
+
logger.info("🚀 Iniciando configuración del Space...")
|
| 120 |
+
|
| 121 |
+
# Verificar entorno
|
| 122 |
+
check_environment()
|
| 123 |
+
|
| 124 |
+
# Instalar mmaudio
|
| 125 |
+
if not install_mmaudio():
|
| 126 |
+
logger.error("❌ No se pudo instalar mmaudio")
|
| 127 |
+
return False
|
| 128 |
+
|
| 129 |
+
# Verificar dependencias
|
| 130 |
+
if not verify_dependencies():
|
| 131 |
+
logger.error("❌ Faltan dependencias")
|
| 132 |
+
return False
|
| 133 |
+
|
| 134 |
+
# Configurar modelos
|
| 135 |
+
setup_models()
|
| 136 |
+
|
| 137 |
+
logger.info("✅ Configuración completada exitosamente")
|
| 138 |
+
return True
|
| 139 |
+
|
| 140 |
+
if __name__ == "__main__":
|
| 141 |
+
success = main()
|
| 142 |
+
sys.exit(0 if success else 1)
|