Spaces:
Paused
Paused
Update app.py
Browse files
app.py
CHANGED
|
@@ -44,8 +44,11 @@ with open("requirements.txt", "r") as f_in, open("filtered_requirements.txt", "w
|
|
| 44 |
print("Instalando dependências filtradas...")
|
| 45 |
subprocess.run([python_executable, "-m", "pip", "install", "-r", "filtered_requirements.txt"], check=True)
|
| 46 |
|
| 47 |
-
|
| 48 |
-
|
|
|
|
|
|
|
|
|
|
| 49 |
|
| 50 |
from pathlib import Path
|
| 51 |
from urllib.parse import urlparse
|
|
@@ -122,7 +125,6 @@ def configure_runner():
|
|
| 122 |
config = load_config('configs_3b/main.yaml')
|
| 123 |
runner = VideoDiffusionInfer(config)
|
| 124 |
OmegaConf.set_readonly(runner.config, False)
|
| 125 |
-
# A chamada de inicialização crítica é feita aqui
|
| 126 |
init_torch(cudnn_benchmark=False, timeout=datetime.timedelta(seconds=3600))
|
| 127 |
runner.configure_dit_model(device="cuda", checkpoint='ckpts/seedvr2_ema_3b.pth')
|
| 128 |
runner.configure_vae_model()
|
|
@@ -130,7 +132,6 @@ def configure_runner():
|
|
| 130 |
runner.vae.set_memory_limit(**runner.config.vae.memory_limit)
|
| 131 |
return runner
|
| 132 |
|
| 133 |
-
# Criamos o runner globalmente, UMA ÚNICA VEZ
|
| 134 |
GLOBAL_RUNNER = configure_runner()
|
| 135 |
print("✅ Setup completo. Aplicação pronta para receber requisições.")
|
| 136 |
|
|
@@ -170,9 +171,7 @@ def cut_videos(videos, sp_size=1):
|
|
| 170 |
@spaces.GPU
|
| 171 |
def generation_loop(video_path, seed=666, fps_out=24):
|
| 172 |
if video_path is None: return None, None, None
|
| 173 |
-
# CORREÇÃO: Usamos o runner global em vez de criar um novo
|
| 174 |
runner = GLOBAL_RUNNER
|
| 175 |
-
|
| 176 |
text_embeds = {
|
| 177 |
"texts_pos": [torch.load('pos_emb.pt', weights_only=True).to("cuda")],
|
| 178 |
"texts_neg": [torch.load('neg_emb.pt', weights_only=True).to("cuda")]
|
|
@@ -234,4 +233,5 @@ with gr.Blocks(title="SeedVR") as demo:
|
|
| 234 |
download_link = gr.File(label="Baixar Resultado")
|
| 235 |
run_button.click(fn=generation_loop, inputs=[input_file, seed, fps], outputs=[output_image, output_video, download_link])
|
| 236 |
|
|
|
|
| 237 |
demo.queue().launch(share=True)
|
|
|
|
| 44 |
print("Instalando dependências filtradas...")
|
| 45 |
subprocess.run([python_executable, "-m", "pip", "install", "-r", "filtered_requirements.txt"], check=True)
|
| 46 |
|
| 47 |
+
# CORREÇÃO CRÍTICA: Remover a versão específica do flash-attn.
|
| 48 |
+
# Deixar o pip escolher a versão compatível com a GPU do ambiente.
|
| 49 |
+
print("Instalando a versão compatível do flash-attn...")
|
| 50 |
+
subprocess.run([python_executable, "-m", "pip", "install", "flash-attn", "--no-build-isolation"], check=True)
|
| 51 |
+
|
| 52 |
|
| 53 |
from pathlib import Path
|
| 54 |
from urllib.parse import urlparse
|
|
|
|
| 125 |
config = load_config('configs_3b/main.yaml')
|
| 126 |
runner = VideoDiffusionInfer(config)
|
| 127 |
OmegaConf.set_readonly(runner.config, False)
|
|
|
|
| 128 |
init_torch(cudnn_benchmark=False, timeout=datetime.timedelta(seconds=3600))
|
| 129 |
runner.configure_dit_model(device="cuda", checkpoint='ckpts/seedvr2_ema_3b.pth')
|
| 130 |
runner.configure_vae_model()
|
|
|
|
| 132 |
runner.vae.set_memory_limit(**runner.config.vae.memory_limit)
|
| 133 |
return runner
|
| 134 |
|
|
|
|
| 135 |
GLOBAL_RUNNER = configure_runner()
|
| 136 |
print("✅ Setup completo. Aplicação pronta para receber requisições.")
|
| 137 |
|
|
|
|
| 171 |
@spaces.GPU
|
| 172 |
def generation_loop(video_path, seed=666, fps_out=24):
|
| 173 |
if video_path is None: return None, None, None
|
|
|
|
| 174 |
runner = GLOBAL_RUNNER
|
|
|
|
| 175 |
text_embeds = {
|
| 176 |
"texts_pos": [torch.load('pos_emb.pt', weights_only=True).to("cuda")],
|
| 177 |
"texts_neg": [torch.load('neg_emb.pt', weights_only=True).to("cuda")]
|
|
|
|
| 233 |
download_link = gr.File(label="Baixar Resultado")
|
| 234 |
run_button.click(fn=generation_loop, inputs=[input_file, seed, fps], outputs=[output_image, output_video, download_link])
|
| 235 |
|
| 236 |
+
|
| 237 |
demo.queue().launch(share=True)
|