carlex3321 commited on
Commit
85b9c99
·
verified ·
1 Parent(s): 616032b

Update app_vince.py

Browse files
Files changed (1) hide show
  1. app_vince.py +11 -12
app_vince.py CHANGED
@@ -1,17 +1,18 @@
1
  #!/usr/bin/env python3
2
  import gradio as gr
3
- import os
4
  from pathlib import Path
5
  from typing import List
6
  from services.vincie import VincieService
7
 
8
- # Inicializa serviço e materializa modelo antes da UI
9
  svc = VincieService()
10
  try:
11
- # Permite forçar caminho direto definindo VINCIE_DIRECT_TO_CKPT=1 no ambiente
12
  svc.ensure_model()
13
  except Exception as e:
14
- print(f"[app] Falha em ensure_model no boot: {e}")
 
 
 
 
15
 
16
  def ui_multi_turn(input_image: str, turns: List[str], seed: int = 1, steps: int = 50,
17
  cfg_scale: float = 7.5, negative_prompt: str = "", resolution: int = 512,
@@ -29,12 +30,10 @@ def ui_multi_turn(input_image: str, turns: List[str], seed: int = 1, steps: int
29
  num_gpus=num_gpus,
30
  use_vae_slicing=True,
31
  )
32
- generated_files = []
33
- for ext in (".png", ".jpg", ".jpeg", ".mp4", ".gif"):
34
- generated_files.extend(str(p) for p in Path(outdir).rglob(f"*{ext}") if p.is_file())
35
- if not generated_files:
36
  return gr.Gallery(value=None, label="Nenhum arquivo gerado encontrado. Verifique os logs.")
37
- return gr.Gallery(value=generated_files, label="Resultados Gerados")
38
  except Exception as e:
39
  print(f"[app] Erro na geração: {e}")
40
  return gr.Gallery(value=None, label=f"[Erro] {str(e)}")
@@ -56,10 +55,10 @@ def ui_text_to_video(input_image: str, prompt: str, seed: int = 1, steps: int =
56
  num_gpus=num_gpus,
57
  use_vae_slicing=True,
58
  )
59
- video_files = [str(p) for p in Path(outdir).rglob("*.mp4") if p.is_file()]
60
- if not video_files:
61
  return gr.Video(value=None, label="Nenhum vídeo gerado encontrado. Verifique os logs.")
62
- return gr.Video(value=video_files[0], label="Vídeo Gerado")
63
  except Exception as e:
64
  print(f"[app] Erro na geração: {e}")
65
  return gr.Video(value=None, label=f"[Erro] {str(e)}")
 
1
  #!/usr/bin/env python3
2
  import gradio as gr
 
3
  from pathlib import Path
4
  from typing import List
5
  from services.vincie import VincieService
6
 
 
7
  svc = VincieService()
8
  try:
 
9
  svc.ensure_model()
10
  except Exception as e:
11
+ print(f"[app] Falha em ensure_model: {e}")
12
+
13
+ def _collect_media(outdir: Path):
14
+ exts = (".png",".jpg",".jpeg",".gif",".mp4")
15
+ return sorted(str(p) for p in outdir.rglob("*") if p.is_file() and p.suffix.lower() in exts)
16
 
17
  def ui_multi_turn(input_image: str, turns: List[str], seed: int = 1, steps: int = 50,
18
  cfg_scale: float = 7.5, negative_prompt: str = "", resolution: int = 512,
 
30
  num_gpus=num_gpus,
31
  use_vae_slicing=True,
32
  )
33
+ files = _collect_media(Path(outdir))
34
+ if not files:
 
 
35
  return gr.Gallery(value=None, label="Nenhum arquivo gerado encontrado. Verifique os logs.")
36
+ return gr.Gallery(value=files, label="Resultados Gerados")
37
  except Exception as e:
38
  print(f"[app] Erro na geração: {e}")
39
  return gr.Gallery(value=None, label=f"[Erro] {str(e)}")
 
55
  num_gpus=num_gpus,
56
  use_vae_slicing=True,
57
  )
58
+ videos = [p for p in _collect_media(Path(outdir)) if p.endswith(".mp4")]
59
+ if not videos:
60
  return gr.Video(value=None, label="Nenhum vídeo gerado encontrado. Verifique os logs.")
61
+ return gr.Video(value=videos[0], label="Vídeo Gerado")
62
  except Exception as e:
63
  print(f"[app] Erro na geração: {e}")
64
  return gr.Video(value=None, label=f"[Erro] {str(e)}")