eeuuia commited on
Commit
4a6b416
·
verified ·
1 Parent(s): a7e6912

Upload app.py

Browse files
Files changed (1) hide show
  1. app.py +14 -14
app.py CHANGED
@@ -15,9 +15,9 @@ from PIL import Image as PILImage
15
  # --- IMPORTAÇÃO DOS SERVIÇOS DE BACKEND E UTILS (CAMINHOS ATUALIZADOS) ---
16
  # ==============================================================================
17
 
18
- from api.ltx.ltx_aduc_pipeline import video_generation_service
19
  from utils.debug_utils import log_function_io
20
- from api.seedvr.seedvr_aduc_pipeline import seed_aduc_pipeline as seedvr_inference_server
21
  logging.info("All backend services and utils imported successfully from new paths.")
22
 
23
  # ==============================================================================
@@ -50,7 +50,7 @@ def run_generate_base_video(
50
  "skip_final_inference_steps": fp_skip_final_steps,
51
  }
52
 
53
- video_path, tensor_path, final_seed = video_generation_service.generate_low_resolution(
54
  prompt_list=prompt_list,
55
  negative_prompt=neg_prompt,
56
  height=height, width=width, duration=duration,
@@ -75,7 +75,7 @@ def run_ltx_refinement(state: dict, prompt: str, neg_prompt: str, progress=gr.Pr
75
  raise gr.Error("Error: Please generate a base video in Step 1 before refining.")
76
  try:
77
  logging.info(f"[UI] Requesting LTX refinement for latents: {state.get('low_res_latents')}")
78
- video_path, tensor_path = video_generation_service.generate_upscale_denoise(
79
  latents_path=state["low_res_latents"],
80
  prompt=prompt, negative_prompt=neg_prompt,
81
  seed=state["used_seed"]
@@ -95,12 +95,12 @@ def run_seedvr_upscaling(state: dict, seed: int, resolution: int, batch_size: in
95
  """Wrapper para o upscale de resolução SeedVR."""
96
  if not state or not state.get("low_res_video"):
97
  raise gr.Error("Error: Please generate a base video in Step 1 before upscaling.")
98
- if not seedvr_inference_server:
99
  raise gr.Error("Error: The SeedVR upscaling server is not available.")
100
  try:
101
  logging.info(f"[UI] Requesting SeedVR upscaling for video: {state.get('low_res_video')}")
102
  def progress_wrapper(p, desc=""): progress(p, desc=desc)
103
- output_filepath = seedvr_inference_server.run_inference(
104
  file_path=state["low_res_video"], seed=int(seed), resolution=int(resolution),
105
  batch_size=int(batch_size), fps=float(fps), progress=progress_wrapper
106
  )
@@ -121,13 +121,13 @@ def build_ui():
121
  with gr.Blocks(theme=gr.themes.Soft(primary_hue="indigo")) as demo:
122
  app_state = gr.State(value={"low_res_video": None, "low_res_latents": None, "used_seed": None})
123
  ui_components = {}
124
- gr.Markdown("# ADUC-SDR Video Suite - LTX & SeedVR Workflow", elem_id="main-title")
125
  with gr.Row():
126
  with gr.Column(scale=1): _build_generation_controls(ui_components)
127
  with gr.Column(scale=1):
128
  gr.Markdown("### Etapa 1: Vídeo Base Gerado")
129
- ui_components['low_res_video_output'] = gr.Video(label="O resultado aparecerá aqui", interactive=False)
130
- ui_components['used_seed_display'] = gr.Textbox(label="Seed Utilizada", interactive=False)
131
  _build_postprod_controls(ui_components)
132
  _register_event_handlers(app_state, ui_components)
133
  return demo
@@ -135,15 +135,15 @@ def build_ui():
135
  def _build_generation_controls(ui: dict):
136
  """Constrói os componentes da UI, sem seleção de modo."""
137
  gr.Markdown("### Configurações de Geração")
138
- ui['prompt'] = gr.Textbox(label="Prompt(s)", info="Para múltiplas cenas (modo narrativo), escreva um prompt por linha.", value="Um leão majestoso caminha pela savana\nEle sobe em uma grande pedra e olha o horizonte", lines=4)
139
- ui['neg_prompt'] = gr.Textbox(label="Negative Prompt", value="blurry, low quality, bad anatomy, deformed", lines=2)
140
  ui['start_image'] = gr.Image(label="Imagem de Início (Opcional)", type="pil", sources=["upload"])
141
 
142
  with gr.Accordion("Parâmetros Principais", open=True):
143
  ui['duration'] = gr.Slider(label="Duração Total (s)", value=4, step=1, minimum=1, maximum=30)
144
  with gr.Row():
145
- ui['height'] = gr.Slider(label="Height", value=432, step=8, minimum=256, maximum=1024)
146
- ui['width'] = gr.Slider(label="Width", value=768, step=8, minimum=256, maximum=1024)
147
 
148
  with gr.Accordion("Opções Avançadas LTX", open=False):
149
  gr.Markdown("#### Configurações de Passos de Inferência")
@@ -168,7 +168,7 @@ def _build_postprod_controls(ui: dict):
168
  ui['ltx_refined_video_output'] = gr.Video(label="Vídeo com Textura Refinada", interactive=False)
169
 
170
  with gr.TabItem("✨ Upscaler de Resolução (SeedVR)"):
171
- is_seedvr_available = seedvr_inference_server is not None
172
  if not is_seedvr_available:
173
  gr.Markdown("🔴 **AVISO: O serviço SeedVR não está disponível.**")
174
  with gr.Row():
 
15
  # --- IMPORTAÇÃO DOS SERVIÇOS DE BACKEND E UTILS (CAMINHOS ATUALIZADOS) ---
16
  # ==============================================================================
17
 
18
+ from api.ltx.ltx_aduc_pipeline import ltx_aduc_pipeline
19
  from utils.debug_utils import log_function_io
20
+ from api.seedvr.seedvr_aduc_pipeline import seed_aduc_pipeline as seed_aduc_pipeline
21
  logging.info("All backend services and utils imported successfully from new paths.")
22
 
23
  # ==============================================================================
 
50
  "skip_final_inference_steps": fp_skip_final_steps,
51
  }
52
 
53
+ video_path, tensor_path, final_seed = ltx_aduc_pipeline.generate_low_resolution(
54
  prompt_list=prompt_list,
55
  negative_prompt=neg_prompt,
56
  height=height, width=width, duration=duration,
 
75
  raise gr.Error("Error: Please generate a base video in Step 1 before refining.")
76
  try:
77
  logging.info(f"[UI] Requesting LTX refinement for latents: {state.get('low_res_latents')}")
78
+ video_path, tensor_path = ltx_aduc_pipeline.generate_upscale_denoise(
79
  latents_path=state["low_res_latents"],
80
  prompt=prompt, negative_prompt=neg_prompt,
81
  seed=state["used_seed"]
 
95
  """Wrapper para o upscale de resolução SeedVR."""
96
  if not state or not state.get("low_res_video"):
97
  raise gr.Error("Error: Please generate a base video in Step 1 before upscaling.")
98
+ if not seed_aduc_pipeline:
99
  raise gr.Error("Error: The SeedVR upscaling server is not available.")
100
  try:
101
  logging.info(f"[UI] Requesting SeedVR upscaling for video: {state.get('low_res_video')}")
102
  def progress_wrapper(p, desc=""): progress(p, desc=desc)
103
+ output_filepath = seed_aduc_pipeline.run_inference(
104
  file_path=state["low_res_video"], seed=int(seed), resolution=int(resolution),
105
  batch_size=int(batch_size), fps=float(fps), progress=progress_wrapper
106
  )
 
121
  with gr.Blocks(theme=gr.themes.Soft(primary_hue="indigo")) as demo:
122
  app_state = gr.State(value={"low_res_video": None, "low_res_latents": None, "used_seed": None})
123
  ui_components = {}
124
+ gr.Markdown("🚀 ADUC-SDR Video Suite - Infinite LTX & SeedVR Workflow", elem_id="main-title")
125
  with gr.Row():
126
  with gr.Column(scale=1): _build_generation_controls(ui_components)
127
  with gr.Column(scale=1):
128
  gr.Markdown("### Etapa 1: Vídeo Base Gerado")
129
+ ui_components['low_res_video_output'] = gr.Video(label="O resultado aparecerá aqui", interactive=True)
130
+ ui_components['used_seed_display'] = gr.Textbox(label="Seed Utilizada", visible=False interactive=False)
131
  _build_postprod_controls(ui_components)
132
  _register_event_handlers(app_state, ui_components)
133
  return demo
 
135
  def _build_generation_controls(ui: dict):
136
  """Constrói os componentes da UI, sem seleção de modo."""
137
  gr.Markdown("### Configurações de Geração")
138
+ ui['prompt'] = gr.Textbox(label="Prompt(s)", info="Para múltiplas cenas escreva um linha por prompt.", value="", lines=6)
139
+ ui['neg_prompt'] = gr.Textbox(label="Negative Prompt", visible=False, value="blurry, low quality, bad anatomy, deformed", lines=2)
140
  ui['start_image'] = gr.Image(label="Imagem de Início (Opcional)", type="pil", sources=["upload"])
141
 
142
  with gr.Accordion("Parâmetros Principais", open=True):
143
  ui['duration'] = gr.Slider(label="Duração Total (s)", value=4, step=1, minimum=1, maximum=30)
144
  with gr.Row():
145
+ ui['height'] = gr.Slider(label="Height", value=432, step=128, minimum=256, maximum=1024)
146
+ ui['width'] = gr.Slider(label="Width", value=768, step=128, minimum=256, maximum=1024)
147
 
148
  with gr.Accordion("Opções Avançadas LTX", open=False):
149
  gr.Markdown("#### Configurações de Passos de Inferência")
 
168
  ui['ltx_refined_video_output'] = gr.Video(label="Vídeo com Textura Refinada", interactive=False)
169
 
170
  with gr.TabItem("✨ Upscaler de Resolução (SeedVR)"):
171
+ is_seedvr_available = seed_aduc_pipeline is not None
172
  if not is_seedvr_available:
173
  gr.Markdown("🔴 **AVISO: O serviço SeedVR não está disponível.**")
174
  with gr.Row():