Spaces:
Paused
Paused
Update app.py
Browse files
app.py
CHANGED
@@ -11,21 +11,10 @@
|
|
11 |
# // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
12 |
# // See the License for the specific language governing permissions and
|
13 |
# // limitations under the License.
|
14 |
-
import
|
15 |
-
import
|
16 |
import os
|
17 |
-
import gc
|
18 |
-
import logging
|
19 |
import sys
|
20 |
-
import subprocess
|
21 |
-
from pathlib import Path
|
22 |
-
from urllib.parse import urlparse
|
23 |
-
from torch.hub import download_url_to_file
|
24 |
-
import gradio as gr
|
25 |
-
import mediapy
|
26 |
-
from einops import rearrange
|
27 |
-
import shutil
|
28 |
-
from omegaconf import OmegaConf
|
29 |
|
30 |
# --- ETAPA 1: Preparação do Ambiente ---
|
31 |
# Clonar o repositório para garantir que todas as pastas de código (data, common, etc.) existam.
|
@@ -52,6 +41,7 @@ print("Instalando dependências a partir do requirements.txt (isso inclui o PyTo
|
|
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...")
|
57 |
subprocess.run([python_executable, "-m", "pip", "install", "--force-reinstall", "--no-cache-dir", "flash-attn"], check=True)
|
@@ -61,12 +51,14 @@ 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
|
@@ -107,6 +99,7 @@ torch.hub.download_url_to_file('https://huggingface.co/datasets/Iceclear/SeedVR_
|
|
107 |
torch.hub.download_url_to_file('https://huggingface.co/datasets/Iceclear/SeedVR_VideoDemos/resolve/main/seedvr_videos_crf23/aigc1k/2_1_lq.mp4', '03.mp4')
|
108 |
print("✅ Modelos e dados de exemplo baixados.")
|
109 |
|
|
|
110 |
# --- ETAPA 4: Execução do Código Principal da Aplicação ---
|
111 |
import mediapy
|
112 |
from einops import rearrange
|
|
|
11 |
# // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
12 |
# // See the License for the specific language governing permissions and
|
13 |
# // limitations under the License.
|
14 |
+
import spaces
|
15 |
+
import subprocess
|
16 |
import os
|
|
|
|
|
17 |
import sys
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
18 |
|
19 |
# --- ETAPA 1: Preparação do Ambiente ---
|
20 |
# Clonar o repositório para garantir que todas as pastas de código (data, common, etc.) existam.
|
|
|
41 |
subprocess.run([python_executable, "-m", "pip", "install", "-r", "requirements.txt"], check=True)
|
42 |
print("✅ Dependências básicas (incluindo PyTorch) instaladas.")
|
43 |
|
44 |
+
|
45 |
# **Compilar dependências otimizadas para a GPU L40S (Ada Lovelace)**
|
46 |
print("Instalando flash-attn compilando do zero...")
|
47 |
subprocess.run([python_executable, "-m", "pip", "install", "--force-reinstall", "--no-cache-dir", "flash-attn"], check=True)
|
|
|
51 |
subprocess.run("git clone https://github.com/NVIDIA/apex", shell=True, check=True)
|
52 |
|
53 |
# Instala o Apex a partir da fonte clonada. Agora o PyTorch já existe e a compilação funcionará.
|
54 |
+
# As flags --cpp_ext e --cuda_ext são essenciais para a compilação.
|
55 |
subprocess.run(
|
56 |
[python_executable, "-m", "pip", "install", "-v", "--disable-pip-version-check", "--no-cache-dir", "--global-option=--cpp_ext", "--global-option=--cuda_ext", "./apex"],
|
57 |
check=True
|
58 |
)
|
59 |
print("✅ Configuração do Apex concluída.")
|
60 |
|
61 |
+
|
62 |
# **Download dos modelos e dados de exemplo**
|
63 |
import torch
|
64 |
from pathlib import Path
|
|
|
99 |
torch.hub.download_url_to_file('https://huggingface.co/datasets/Iceclear/SeedVR_VideoDemos/resolve/main/seedvr_videos_crf23/aigc1k/2_1_lq.mp4', '03.mp4')
|
100 |
print("✅ Modelos e dados de exemplo baixados.")
|
101 |
|
102 |
+
|
103 |
# --- ETAPA 4: Execução do Código Principal da Aplicação ---
|
104 |
import mediapy
|
105 |
from einops import rearrange
|