Spaces:
Paused
Paused
Update app.py
Browse files
app.py
CHANGED
@@ -43,16 +43,14 @@ print(f"Diretório de trabalho alterado para: {os.getcwd()}")
|
|
43 |
sys.path.insert(0, os.path.abspath('.'))
|
44 |
print(f"Diretório atual adicionado ao sys.path para importações.")
|
45 |
|
46 |
-
# --- ETAPA 3: Instalação de Dependências
|
47 |
-
# ORDEM CORRETA: Instalar requisitos, DEPOIS compilar apex/flash-attn, DEPOIS baixar modelos.
|
48 |
|
49 |
python_executable = sys.executable
|
50 |
|
51 |
# **CORREÇÃO CRÍTICA: Instalar requisitos PRIMEIRO para ter o PyTorch disponível**
|
52 |
print("Instalando dependências a partir do requirements.txt (isso inclui o PyTorch)...")
|
53 |
subprocess.run([python_executable, "-m", "pip", "install", "-r", "requirements.txt"], check=True)
|
54 |
-
print("✅ Dependências básicas instaladas.")
|
55 |
-
|
56 |
|
57 |
# **Compilar dependências otimizadas para a GPU L40S (Ada Lovelace)**
|
58 |
print("Instalando flash-attn compilando do zero...")
|
@@ -62,15 +60,14 @@ print("Clonando e compilando o Apex do zero (isso pode demorar um pouco)...")
|
|
62 |
if not os.path.exists("apex"):
|
63 |
subprocess.run("git clone https://github.com/NVIDIA/apex", shell=True, check=True)
|
64 |
|
65 |
-
# Instala o Apex a partir da fonte clonada
|
66 |
subprocess.run(
|
67 |
[python_executable, "-m", "pip", "install", "-v", "--disable-pip-version-check", "--no-cache-dir", "--global-option=--cpp_ext", "--global-option=--cuda_ext", "./apex"],
|
68 |
check=True
|
69 |
)
|
70 |
print("✅ Configuração do Apex concluída.")
|
71 |
|
72 |
-
|
73 |
-
# **Download dos modelos e dados**
|
74 |
import torch
|
75 |
from pathlib import Path
|
76 |
from urllib.parse import urlparse
|
@@ -183,7 +180,7 @@ def generation_step(runner, text_embeds_dict, cond_latents):
|
|
183 |
video_tensors = runner.inference(noises=noises, conditions=conditions, dit_offload=False, **text_embeds_dict)
|
184 |
return [rearrange(video, "c t h w -> t c h w") for video in video_tensors]
|
185 |
|
186 |
-
|
187 |
def generation_loop(video_path, seed=666, fps_out=24, batch_size=1, cfg_scale=1.0, cfg_rescale=0.0, sample_steps=1, res_h=1280, res_w=720, sp_size=1):
|
188 |
if video_path is None: return None, None, None
|
189 |
runner = configure_runner(1)
|
|
|
43 |
sys.path.insert(0, os.path.abspath('.'))
|
44 |
print(f"Diretório atual adicionado ao sys.path para importações.")
|
45 |
|
46 |
+
# --- ETAPA 3: Instalação de Dependências (NA ORDEM CORRETA) ---
|
|
|
47 |
|
48 |
python_executable = sys.executable
|
49 |
|
50 |
# **CORREÇÃO CRÍTICA: Instalar requisitos PRIMEIRO para ter o PyTorch disponível**
|
51 |
print("Instalando dependências a partir do requirements.txt (isso inclui o PyTorch)...")
|
52 |
subprocess.run([python_executable, "-m", "pip", "install", "-r", "requirements.txt"], check=True)
|
53 |
+
print("✅ Dependências básicas (incluindo PyTorch) instaladas.")
|
|
|
54 |
|
55 |
# **Compilar dependências otimizadas para a GPU L40S (Ada Lovelace)**
|
56 |
print("Instalando flash-attn compilando do zero...")
|
|
|
60 |
if not os.path.exists("apex"):
|
61 |
subprocess.run("git clone https://github.com/NVIDIA/apex", shell=True, check=True)
|
62 |
|
63 |
+
# Instala o Apex a partir da fonte clonada. Agora o PyTorch já existe e a compilação funcionará.
|
64 |
subprocess.run(
|
65 |
[python_executable, "-m", "pip", "install", "-v", "--disable-pip-version-check", "--no-cache-dir", "--global-option=--cpp_ext", "--global-option=--cuda_ext", "./apex"],
|
66 |
check=True
|
67 |
)
|
68 |
print("✅ Configuração do Apex concluída.")
|
69 |
|
70 |
+
# **Download dos modelos e dados de exemplo**
|
|
|
71 |
import torch
|
72 |
from pathlib import Path
|
73 |
from urllib.parse import urlparse
|
|
|
180 |
video_tensors = runner.inference(noises=noises, conditions=conditions, dit_offload=False, **text_embeds_dict)
|
181 |
return [rearrange(video, "c t h w -> t c h w") for video in video_tensors]
|
182 |
|
183 |
+
@spaces.GPU
|
184 |
def generation_loop(video_path, seed=666, fps_out=24, batch_size=1, cfg_scale=1.0, cfg_rescale=0.0, sample_steps=1, res_h=1280, res_w=720, sp_size=1):
|
185 |
if video_path is None: return None, None, None
|
186 |
runner = configure_runner(1)
|