Update app.py
Browse files
app.py
CHANGED
|
@@ -2,11 +2,11 @@
|
|
| 2 |
#
|
| 3 |
# Copyright (C) August 4, 2025 Carlos Rodrigues dos Santos
|
| 4 |
#
|
| 5 |
-
# Versão
|
| 6 |
#
|
| 7 |
-
#
|
| 8 |
-
#
|
| 9 |
-
#
|
| 10 |
|
| 11 |
import gradio as gr
|
| 12 |
import yaml
|
|
@@ -61,6 +61,12 @@ try:
|
|
| 61 |
logger.info("Interface Gradio inicializada e conectada ao Aduc Framework.")
|
| 62 |
except Exception as e:
|
| 63 |
logger.critical(f"ERRO CRÍTICO durante a inicialização: {e}", exc_info=True)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 64 |
exit()
|
| 65 |
|
| 66 |
# --- 2. FUNÇÕES WRAPPER (CAMADA DE TRADUÇÃO UI <-> FRAMEWORK) ---
|
|
@@ -87,11 +93,11 @@ def run_upscaler_wrapper(latent_paths, chunk_size, progress=gr.Progress()):
|
|
| 87 |
if "final_path" in update: final_path = update['final_path']
|
| 88 |
yield {upscaler_video_output: gr.update(value=final_path, label="✅ Upscale Latente Concluído"), final_video_output: gr.update(value=final_path), upscaled_video_path_state: final_path, current_source_video_state: final_path}
|
| 89 |
|
| 90 |
-
def run_hd_wrapper(source_video,
|
| 91 |
if not source_video: raise gr.Error("Não é possível executar a Masterização HD.")
|
| 92 |
yield {hd_video_output: gr.update(value=None, visible=True, label="Aplicando masterização HD..."), final_video_output: gr.update(label="Pós-Produção: Masterização HD...")}
|
| 93 |
final_path = None
|
| 94 |
-
for update in aduc.task_run_hd_mastering(source_video,
|
| 95 |
if "final_path" in update: final_path = update['final_path']
|
| 96 |
yield {hd_video_output: gr.update(value=final_path, label="✅ Masterização HD Concluída"), final_video_output: gr.update(value=final_path), hd_video_path_state: final_path, current_source_video_state: final_path}
|
| 97 |
|
|
@@ -152,9 +158,8 @@ with gr.Blocks(theme=cinematic_theme, css="style.css") as demo:
|
|
| 152 |
run_upscaler_button = gr.Button("Executar Upscaler Latente", variant="secondary")
|
| 153 |
upscaler_video_output = gr.Video(label="Vídeo com Upscale", visible=False, interactive=False)
|
| 154 |
with gr.Accordion("B. Masterização HD (SeedVR)", open=True):
|
| 155 |
-
hd_model_radio = gr.Radio(["3B", "7B"], value="7B", label="Modelo SeedVR")
|
| 156 |
hd_steps_slider = gr.Slider(minimum=20, maximum=150, value=100, step=5, label="Passos de Inferência HD")
|
| 157 |
-
run_hd_button = gr.Button("Executar Masterização HD", variant="secondary")
|
| 158 |
hd_video_output = gr.Video(label="Vídeo Masterizado em HD", visible=False, interactive=False)
|
| 159 |
with gr.Accordion("C. Geração de Áudio", open=True):
|
| 160 |
audio_prompt_input = gr.Textbox(label="Prompt de Áudio Detalhado (Opcional)", lines=3, placeholder="Descreva os sons, efeitos e música desejados. Se vazio, usará o prompt geral do filme.")
|
|
@@ -175,7 +180,7 @@ with gr.Blocks(theme=cinematic_theme, css="style.css") as demo:
|
|
| 175 |
produce_original_button.click(fn=run_original_production_wrapper, inputs=[generation_state_holder, trim_percent_slider, handler_strength, dest_strength, guidance_scale_slider, stg_scale_slider, inference_steps_slider], outputs=[original_video_output, final_video_output, step4_accordion, original_latents_paths_state, original_video_path_state, current_source_video_state, generation_state_holder, generation_data_output])
|
| 176 |
|
| 177 |
run_upscaler_button.click(fn=run_upscaler_wrapper, inputs=[original_latents_paths_state, upscaler_chunk_size_slider], outputs=[upscaler_video_output, final_video_output, upscaled_video_path_state, current_source_video_state])
|
| 178 |
-
run_hd_button.click(fn=run_hd_wrapper, inputs=[current_source_video_state,
|
| 179 |
run_audio_button.click(fn=run_audio_wrapper, inputs=[current_source_video_state, audio_prompt_input, prompt_input], outputs=[audio_video_output, final_video_output])
|
| 180 |
|
| 181 |
generation_state_holder.change(fn=lambda state: state, inputs=generation_state_holder, outputs=generation_data_output)
|
|
|
|
| 2 |
#
|
| 3 |
# Copyright (C) August 4, 2025 Carlos Rodrigues dos Santos
|
| 4 |
#
|
| 5 |
+
# Versão 4.0.0 (UI for Forced SeedVR 3B)
|
| 6 |
#
|
| 7 |
+
# Esta versão da interface de usuário foi atualizada para refletir as mudanças
|
| 8 |
+
# no backend, onde o SeedVR agora usa exclusivamente o modelo 3B. O seletor
|
| 9 |
+
# de modelo foi removido para simplificar a experiência do usuário.
|
| 10 |
|
| 11 |
import gradio as gr
|
| 12 |
import yaml
|
|
|
|
| 61 |
logger.info("Interface Gradio inicializada e conectada ao Aduc Framework.")
|
| 62 |
except Exception as e:
|
| 63 |
logger.critical(f"ERRO CRÍTICO durante a inicialização: {e}", exc_info=True)
|
| 64 |
+
# Em caso de erro crítico, exibe a mensagem na interface do Gradio antes de sair
|
| 65 |
+
with gr.Blocks() as demo:
|
| 66 |
+
gr.Markdown("# ERRO CRÍTICO NA INICIALIZAÇÃO")
|
| 67 |
+
gr.Markdown("Não foi possível iniciar o Aduc Framework. Verifique os logs para mais detalhes.")
|
| 68 |
+
gr.Textbox(value=str(e), label="Detalhes do Erro", lines=10)
|
| 69 |
+
demo.launch()
|
| 70 |
exit()
|
| 71 |
|
| 72 |
# --- 2. FUNÇÕES WRAPPER (CAMADA DE TRADUÇÃO UI <-> FRAMEWORK) ---
|
|
|
|
| 93 |
if "final_path" in update: final_path = update['final_path']
|
| 94 |
yield {upscaler_video_output: gr.update(value=final_path, label="✅ Upscale Latente Concluído"), final_video_output: gr.update(value=final_path), upscaled_video_path_state: final_path, current_source_video_state: final_path}
|
| 95 |
|
| 96 |
+
def run_hd_wrapper(source_video, steps, global_prompt, progress=gr.Progress()):
|
| 97 |
if not source_video: raise gr.Error("Não é possível executar a Masterização HD.")
|
| 98 |
yield {hd_video_output: gr.update(value=None, visible=True, label="Aplicando masterização HD..."), final_video_output: gr.update(label="Pós-Produção: Masterização HD...")}
|
| 99 |
final_path = None
|
| 100 |
+
for update in aduc.task_run_hd_mastering(source_video, int(steps), global_prompt, progress):
|
| 101 |
if "final_path" in update: final_path = update['final_path']
|
| 102 |
yield {hd_video_output: gr.update(value=final_path, label="✅ Masterização HD Concluída"), final_video_output: gr.update(value=final_path), hd_video_path_state: final_path, current_source_video_state: final_path}
|
| 103 |
|
|
|
|
| 158 |
run_upscaler_button = gr.Button("Executar Upscaler Latente", variant="secondary")
|
| 159 |
upscaler_video_output = gr.Video(label="Vídeo com Upscale", visible=False, interactive=False)
|
| 160 |
with gr.Accordion("B. Masterização HD (SeedVR)", open=True):
|
|
|
|
| 161 |
hd_steps_slider = gr.Slider(minimum=20, maximum=150, value=100, step=5, label="Passos de Inferência HD")
|
| 162 |
+
run_hd_button = gr.Button("Executar Masterização HD (Modelo 3B)", variant="secondary")
|
| 163 |
hd_video_output = gr.Video(label="Vídeo Masterizado em HD", visible=False, interactive=False)
|
| 164 |
with gr.Accordion("C. Geração de Áudio", open=True):
|
| 165 |
audio_prompt_input = gr.Textbox(label="Prompt de Áudio Detalhado (Opcional)", lines=3, placeholder="Descreva os sons, efeitos e música desejados. Se vazio, usará o prompt geral do filme.")
|
|
|
|
| 180 |
produce_original_button.click(fn=run_original_production_wrapper, inputs=[generation_state_holder, trim_percent_slider, handler_strength, dest_strength, guidance_scale_slider, stg_scale_slider, inference_steps_slider], outputs=[original_video_output, final_video_output, step4_accordion, original_latents_paths_state, original_video_path_state, current_source_video_state, generation_state_holder, generation_data_output])
|
| 181 |
|
| 182 |
run_upscaler_button.click(fn=run_upscaler_wrapper, inputs=[original_latents_paths_state, upscaler_chunk_size_slider], outputs=[upscaler_video_output, final_video_output, upscaled_video_path_state, current_source_video_state])
|
| 183 |
+
run_hd_button.click(fn=run_hd_wrapper, inputs=[current_source_video_state, hd_steps_slider, prompt_input], outputs=[hd_video_output, final_video_output, hd_video_path_state, current_source_video_state])
|
| 184 |
run_audio_button.click(fn=run_audio_wrapper, inputs=[current_source_video_state, audio_prompt_input, prompt_input], outputs=[audio_video_output, final_video_output])
|
| 185 |
|
| 186 |
generation_state_holder.change(fn=lambda state: state, inputs=generation_state_holder, outputs=generation_data_output)
|