Spaces:
Paused
Paused
Update app.py
Browse files
app.py
CHANGED
|
@@ -32,12 +32,18 @@ print(f"Diretório atual adicionado ao sys.path.")
|
|
| 32 |
# --- ETAPA 3: Instalar Dependências Corretamente ---
|
| 33 |
python_executable = sys.executable
|
| 34 |
|
| 35 |
-
# CORREÇÃO: Instalar o Apex a partir do código-fonte
|
| 36 |
-
#
|
| 37 |
-
# se o wheel não foi compilado para a arquitetura de GPU específica do ambiente de execução.
|
| 38 |
print("Instalando Apex a partir do código-fonte...")
|
| 39 |
subprocess.run(
|
| 40 |
-
[
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 41 |
check=True
|
| 42 |
)
|
| 43 |
print("✅ Configuração do Apex concluída.")
|
|
@@ -140,26 +146,25 @@ def generation_loop(video_path, seed=666, fps_out=24):
|
|
| 140 |
runner = configure_runner()
|
| 141 |
# Adicionado `weights_only=True` para segurança e para suprimir o aviso
|
| 142 |
text_embeds = {
|
| 143 |
-
"texts_pos": [torch.load('pos_emb.pt', weights_only=True).to("cuda")],
|
| 144 |
"texts_neg": [torch.load('neg_emb.pt', weights_only=True).to("cuda")]
|
| 145 |
}
|
| 146 |
runner.configure_diffusion()
|
| 147 |
set_seed(int(seed))
|
| 148 |
os.makedirs("output", exist_ok=True)
|
| 149 |
-
|
| 150 |
-
# CORREÇÃO: Fornecer os argumentos que faltam para NaResize.
|
| 151 |
res_h, res_w = 1280, 720
|
| 152 |
transform = Compose([
|
| 153 |
NaResize(resolution=(res_h * res_w)**0.5, mode="area", downsample_only=False),
|
| 154 |
Lambda(lambda x: torch.clamp(x, 0.0, 1.0)),
|
| 155 |
-
DivisibleCrop((16, 16)),
|
| 156 |
-
Normalize(0.5, 0.5),
|
| 157 |
Rearrange("t c h w -> c t h w")
|
| 158 |
])
|
| 159 |
|
| 160 |
media_type, _ = mimetypes.guess_type(video_path)
|
| 161 |
is_video = media_type and media_type.startswith("video")
|
| 162 |
-
|
| 163 |
if is_video:
|
| 164 |
video, _, _ = read_video(video_path, output_format="TCHW")
|
| 165 |
video = video[:121] / 255.0
|
|
@@ -184,8 +189,7 @@ def generation_loop(video_path, seed=666, fps_out=24):
|
|
| 184 |
|
| 185 |
with gr.Blocks(title="SeedVR") as demo:
|
| 186 |
gr.HTML(f"""
|
| 187 |
-
|
| 188 |
-
<p><b>Demonstração oficial do Gradio</b> para
|
| 189 |
<a href='https://github.com/ByteDance-Seed/SeedVR' target='_blank'>
|
| 190 |
<b>SeedVR2: One-Step Video Restoration via Diffusion Adversarial Post-Training</b></a>.<br>
|
| 191 |
🔥 <b>SeedVR2</b> é um algoritmo de restauração de imagem e vídeo em um passo para conteúdo do mundo real e AIGC.
|
|
|
|
| 32 |
# --- ETAPA 3: Instalar Dependências Corretamente ---
|
| 33 |
python_executable = sys.executable
|
| 34 |
|
| 35 |
+
# CORREÇÃO: Instalar o Apex a partir do código-fonte usando --no-build-isolation
|
| 36 |
+
# para que ele possa encontrar o PyTorch já instalado a partir do requirements.txt.
|
|
|
|
| 37 |
print("Instalando Apex a partir do código-fonte...")
|
| 38 |
subprocess.run(
|
| 39 |
+
[
|
| 40 |
+
python_executable,
|
| 41 |
+
"-m",
|
| 42 |
+
"pip",
|
| 43 |
+
"install",
|
| 44 |
+
"--no-build-isolation", # Garante que o torch seja encontrado durante a compilação
|
| 45 |
+
"git+https://github.com/NVIDIA/apex.git"
|
| 46 |
+
],
|
| 47 |
check=True
|
| 48 |
)
|
| 49 |
print("✅ Configuração do Apex concluída.")
|
|
|
|
| 146 |
runner = configure_runner()
|
| 147 |
# Adicionado `weights_only=True` para segurança e para suprimir o aviso
|
| 148 |
text_embeds = {
|
| 149 |
+
"texts_pos": [torch.load('pos_emb.pt', weights_only=True).to("cuda")],
|
| 150 |
"texts_neg": [torch.load('neg_emb.pt', weights_only=True).to("cuda")]
|
| 151 |
}
|
| 152 |
runner.configure_diffusion()
|
| 153 |
set_seed(int(seed))
|
| 154 |
os.makedirs("output", exist_ok=True)
|
| 155 |
+
|
|
|
|
| 156 |
res_h, res_w = 1280, 720
|
| 157 |
transform = Compose([
|
| 158 |
NaResize(resolution=(res_h * res_w)**0.5, mode="area", downsample_only=False),
|
| 159 |
Lambda(lambda x: torch.clamp(x, 0.0, 1.0)),
|
| 160 |
+
DivisibleCrop((16, 16)),
|
| 161 |
+
Normalize(0.5, 0.5),
|
| 162 |
Rearrange("t c h w -> c t h w")
|
| 163 |
])
|
| 164 |
|
| 165 |
media_type, _ = mimetypes.guess_type(video_path)
|
| 166 |
is_video = media_type and media_type.startswith("video")
|
| 167 |
+
|
| 168 |
if is_video:
|
| 169 |
video, _, _ = read_video(video_path, output_format="TCHW")
|
| 170 |
video = video[:121] / 255.0
|
|
|
|
| 189 |
|
| 190 |
with gr.Blocks(title="SeedVR") as demo:
|
| 191 |
gr.HTML(f"""
|
| 192 |
+
<p><b>Demonstração oficial do Gradio</b> para
|
|
|
|
| 193 |
<a href='https://github.com/ByteDance-Seed/SeedVR' target='_blank'>
|
| 194 |
<b>SeedVR2: One-Step Video Restoration via Diffusion Adversarial Post-Training</b></a>.<br>
|
| 195 |
🔥 <b>SeedVR2</b> é um algoritmo de restauração de imagem e vídeo em um passo para conteúdo do mundo real e AIGC.
|