Spaces:
Runtime error
Runtime error
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.
|
| 6 |
#
|
| 7 |
-
#
|
| 8 |
-
#
|
| 9 |
-
#
|
| 10 |
|
| 11 |
import gradio as gr
|
| 12 |
import yaml
|
|
@@ -17,61 +17,17 @@ import shutil
|
|
| 17 |
import time
|
| 18 |
import json
|
| 19 |
|
| 20 |
-
# --- 1.
|
| 21 |
import aduc_framework
|
| 22 |
from aduc_framework.types import PreProductionParams, ProductionParams
|
|
|
|
|
|
|
| 23 |
|
| 24 |
-
#
|
| 25 |
-
cinematic_theme = gr.themes.Base(
|
| 26 |
-
primary_hue=gr.themes.colors.indigo,
|
| 27 |
-
secondary_hue=gr.themes.colors.purple,
|
| 28 |
-
neutral_hue=gr.themes.colors.slate,
|
| 29 |
-
font=(gr.themes.GoogleFont("Inter"), "ui-sans-serif", "system-ui", "sans-serif"),
|
| 30 |
-
).set(
|
| 31 |
-
body_background_fill="#111827", body_text_color="#E5E7EB",
|
| 32 |
-
button_primary_background_fill="linear-gradient(90deg, #4F46E5, #8B5CF6)",
|
| 33 |
-
button_primary_text_color="#FFFFFF", button_secondary_background_fill="#374151",
|
| 34 |
-
button_secondary_border_color="#4B5563", button_secondary_text_color="#E5E7EB",
|
| 35 |
-
block_background_fill="#1F2937", block_border_width="1px", block_border_color="#374151",
|
| 36 |
-
block_label_background_fill="#374151", block_label_text_color="#E5E7EB",
|
| 37 |
-
block_title_text_color="#FFFFFF", input_background_fill="#374151",
|
| 38 |
-
input_border_color="#4B5563", input_placeholder_color="#9CA3AF",
|
| 39 |
-
)
|
| 40 |
-
|
| 41 |
-
# Configuração de Logging
|
| 42 |
-
LOG_FILE_PATH = "aduc_log.txt"
|
| 43 |
-
if os.path.exists(LOG_FILE_PATH):
|
| 44 |
-
os.remove(LOG_FILE_PATH)
|
| 45 |
-
|
| 46 |
-
log_format = '%(asctime)s - %(levelname)s - [%(name)s:%(funcName)s] - %(message)s'
|
| 47 |
-
root_logger = logging.getLogger()
|
| 48 |
-
root_logger.setLevel(logging.INFO)
|
| 49 |
-
root_logger.handlers.clear()
|
| 50 |
-
stream_handler = logging.StreamHandler(sys.stdout)
|
| 51 |
-
stream_handler.setFormatter(logging.Formatter(log_format))
|
| 52 |
-
root_logger.addHandler(stream_handler)
|
| 53 |
-
file_handler = logging.FileHandler(LOG_FILE_PATH, mode='w', encoding='utf-8')
|
| 54 |
-
file_handler.setFormatter(logging.Formatter(log_format))
|
| 55 |
-
root_logger.addHandler(file_handler)
|
| 56 |
-
logger = logging.getLogger(__name__)
|
| 57 |
-
|
| 58 |
-
# Inicialização do Aduc Framework
|
| 59 |
-
try:
|
| 60 |
-
with open("config.yaml", 'r') as f: config = yaml.safe_load(f)
|
| 61 |
-
WORKSPACE_DIR = config['application']['workspace_dir']
|
| 62 |
-
aduc = aduc_framework.create_aduc_instance(workspace_dir=WORKSPACE_DIR)
|
| 63 |
-
logger.info("Interface Gradio inicializada e conectada ao Aduc Framework.")
|
| 64 |
-
except Exception as e:
|
| 65 |
-
logger.critical(f"ERRO CRÍTICO durante a inicialização: {e}", exc_info=True)
|
| 66 |
-
with gr.Blocks() as demo:
|
| 67 |
-
gr.Markdown("# ERRO CRÍTICO NA INICIALIZAÇÃO")
|
| 68 |
-
gr.Markdown("Não foi possível iniciar o Aduc Framework. Verifique os logs para mais detalhes.")
|
| 69 |
-
gr.Textbox(value=str(e), label="Detalhes do Erro", lines=10)
|
| 70 |
-
demo.launch()
|
| 71 |
-
exit()
|
| 72 |
|
| 73 |
# --- 2. FUNÇÕES WRAPPER (UI <-> FRAMEWORK) ---
|
| 74 |
|
|
|
|
| 75 |
def run_pre_production_wrapper(prompt, num_keyframes, ref_files, resolution_str, duration_per_fragment, progress=gr.Progress()):
|
| 76 |
if not ref_files: raise gr.Error("Por favor, forneça pelo menos uma imagem de referência.")
|
| 77 |
|
|
@@ -80,6 +36,9 @@ def run_pre_production_wrapper(prompt, num_keyframes, ref_files, resolution_str,
|
|
| 80 |
|
| 81 |
params = PreProductionParams(prompt=prompt, num_keyframes=int(num_keyframes), ref_paths=ref_paths, resolution=target_resolution, duration_per_fragment=duration_per_fragment)
|
| 82 |
|
|
|
|
|
|
|
|
|
|
| 83 |
final_result = {}
|
| 84 |
for update in aduc.task_pre_production(params, progress):
|
| 85 |
yield {
|
|
@@ -94,55 +53,36 @@ def run_pre_production_wrapper(prompt, num_keyframes, ref_files, resolution_str,
|
|
| 94 |
step3_accordion: gr.update(visible=True, open=True)
|
| 95 |
}
|
| 96 |
|
| 97 |
-
|
| 98 |
-
yield {final_video_output: gr.update(value=None, visible=True, label="🎬 Produzindo seu filme...")}
|
| 99 |
-
production_params = ProductionParams(trim_percent=int(trim_percent), handler_strength=handler_strength, destination_convergence_strength=dest_strength, guidance_scale=guidance_scale, stg_scale=stg_scale, inference_steps=int(steps))
|
| 100 |
-
final_video_path, latent_paths, updated_state = aduc.task_produce_original_movie(params=production_params, progress_callback=progress)
|
| 101 |
-
|
| 102 |
-
yield {
|
| 103 |
-
final_video_output: gr.update(value=final_video_path, label="✅ Filme Original Master"),
|
| 104 |
-
step4_accordion: gr.update(visible=True, open=True),
|
| 105 |
-
original_latents_paths_state: latent_paths,
|
| 106 |
-
current_source_video_state: final_video_path,
|
| 107 |
-
generation_state_holder: updated_state.model_dump(),
|
| 108 |
-
}
|
| 109 |
|
| 110 |
-
|
| 111 |
-
|
| 112 |
-
|
| 113 |
-
|
| 114 |
-
|
| 115 |
-
|
| 116 |
-
|
| 117 |
|
| 118 |
-
yield
|
| 119 |
-
|
| 120 |
-
|
| 121 |
-
|
| 122 |
|
| 123 |
-
def
|
| 124 |
-
|
| 125 |
-
|
|
|
|
|
|
|
|
|
|
| 126 |
|
| 127 |
-
|
| 128 |
-
for update in aduc.task_run_hd_mastering(source_video, int(steps), global_prompt, progress):
|
| 129 |
-
if "final_path" in update: final_path = update['final_path']
|
| 130 |
-
|
| 131 |
-
yield {
|
| 132 |
-
final_video_output: gr.update(value=final_path, label="✅ Masterização HD Concluída"),
|
| 133 |
-
current_source_video_state: final_path
|
| 134 |
-
}
|
| 135 |
-
|
| 136 |
-
def run_audio_wrapper(source_video, audio_prompt, global_prompt, progress=gr.Progress()):
|
| 137 |
-
if not source_video: raise gr.Error("Fonte de vídeo não encontrada para a Geração de Áudio.")
|
| 138 |
-
yield {final_video_output: gr.update(label="Pós-Produção: Geração de Áudio...")}
|
| 139 |
|
| 140 |
-
|
| 141 |
-
|
| 142 |
-
|
| 143 |
-
|
| 144 |
-
|
| 145 |
-
yield
|
| 146 |
|
| 147 |
def get_log_content():
|
| 148 |
try:
|
|
@@ -151,76 +91,72 @@ def get_log_content():
|
|
| 151 |
|
| 152 |
# --- 3. DEFINIÇÃO DA UI ---
|
| 153 |
with gr.Blocks(theme=cinematic_theme, css="style.css") as demo:
|
| 154 |
-
# Estados
|
| 155 |
generation_state_holder = gr.State(value={})
|
| 156 |
original_latents_paths_state = gr.State(value=[])
|
| 157 |
current_source_video_state = gr.State(value=None)
|
|
|
|
| 158 |
|
| 159 |
gr.Markdown("<h1>ADUC-SDR 🎬 - O Diretor de Cinema IA</h1>")
|
| 160 |
-
|
| 161 |
-
|
| 162 |
-
with gr.Accordion("Etapa 1: Roteiro e Cenas-Chave (Pré-Produção)", open=True) as step1_accordion:
|
| 163 |
-
prompt_input = gr.Textbox(label="Ideia Geral do Filme", value="Um leão majestoso caminha pela savana, senta-se e ruge para o sol poente.")
|
| 164 |
-
with gr.Row():
|
| 165 |
-
lang_selector = gr.Radio(["🇧🇷", "🇺🇸", "🇨🇳"], value="🇧🇷", label="Idioma / Language")
|
| 166 |
-
resolution_selector = gr.Radio(["512x512", "768x768", "1024x1024"], value="512x512", label="Resolução Base")
|
| 167 |
-
ref_image_input = gr.File(label="Grupo de Imagens do Usuário", file_count="multiple", file_types=["image"])
|
| 168 |
-
with gr.Row():
|
| 169 |
-
num_keyframes_slider = gr.Slider(minimum=2, maximum=42, value=4, step=2, label="Número de Cenas-Chave (Par)")
|
| 170 |
-
duration_per_fragment_slider = gr.Slider(label="Duração de cada Clipe (s)", minimum=2.0, maximum=10.0, value=4.0, step=0.1)
|
| 171 |
-
storyboard_and_keyframes_button = gr.Button("Gerar Roteiro e Keyframes", variant="primary")
|
| 172 |
-
|
| 173 |
-
with gr.Accordion("Etapa 2: Produção do Vídeo Original", open=False, visible=False) as step3_accordion:
|
| 174 |
-
trim_percent_slider = gr.Slider(minimum=10, maximum=90, value=50, step=5, label="Poda Causal (%)")
|
| 175 |
-
handler_strength = gr.Slider(label="Força do Déjà-Vu", minimum=0.0, maximum=1.0, value=0.5, step=0.05)
|
| 176 |
-
dest_strength = gr.Slider(label="Força da Âncora Final", minimum=0.0, maximum=1.0, value=0.75, step=0.05)
|
| 177 |
-
guidance_scale_slider = gr.Slider(minimum=1.0, maximum=10.0, value=2.0, step=0.1, label="Escala de Orientação")
|
| 178 |
-
stg_scale_slider = gr.Slider(minimum=0.0, maximum=1.0, value=0.025, step=0.005, label="Escala STG")
|
| 179 |
-
inference_steps_slider = gr.Slider(minimum=10, maximum=50, value=20, step=1, label="Passos de Inferência")
|
| 180 |
-
produce_original_button = gr.Button("🎬 Produzir Vídeo Original", variant="primary")
|
| 181 |
-
|
| 182 |
-
with gr.Accordion("Etapa 3: Pós-Produção (Opcional)", open=False, visible=False) as step4_accordion:
|
| 183 |
-
gr.Markdown("Aplique melhorias ao filme. Cada etapa usa o resultado da anterior como fonte.")
|
| 184 |
-
with gr.Accordion("A. Upscaler Latente 2x", open=True):
|
| 185 |
-
upscaler_chunk_size_slider = gr.Slider(minimum=1, maximum=10, value=2, step=1, label="Fragmentos por Lote")
|
| 186 |
-
run_upscaler_button = gr.Button("Executar Upscaler Latente", variant="secondary")
|
| 187 |
-
with gr.Accordion("B. Masterização HD (SeedVR)", open=True):
|
| 188 |
-
hd_steps_slider = gr.Slider(minimum=20, maximum=150, value=100, step=5, label="Passos de Inferência HD")
|
| 189 |
-
run_hd_button = gr.Button("Executar Masterização HD", variant="secondary")
|
| 190 |
-
with gr.Accordion("C. Geração de Áudio", open=True):
|
| 191 |
-
audio_prompt_input = gr.Textbox(label="Prompt de Áudio Detalhado (Opcional)", lines=2, placeholder="Descreva os sons, efeitos e música.")
|
| 192 |
-
run_audio_button = gr.Button("Gerar Áudio", variant="secondary")
|
| 193 |
-
|
| 194 |
-
# --- RESULTADOS CONSOLIDADOS ---
|
| 195 |
-
final_video_output = gr.Video(label="Filme Final (Resultado da Última Etapa)", visible=False, interactive=False)
|
| 196 |
|
| 197 |
-
|
| 198 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 199 |
|
| 200 |
-
|
| 201 |
-
|
| 202 |
-
|
| 203 |
-
|
| 204 |
-
|
| 205 |
-
|
| 206 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
| 207 |
|
| 208 |
# --- 4. CONEXÕES DE EVENTOS ---
|
| 209 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 210 |
|
| 211 |
-
|
| 212 |
|
| 213 |
-
|
| 214 |
-
|
| 215 |
-
|
|
|
|
|
|
|
|
|
|
| 216 |
|
| 217 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 218 |
update_log_button.click(fn=get_log_content, inputs=[], outputs=[log_display])
|
|
|
|
| 219 |
|
| 220 |
# --- 5. INICIALIZAÇÃO DA APLICAÇÃO ---
|
| 221 |
if __name__ == "__main__":
|
| 222 |
-
if os.path.exists(WORKSPACE_DIR):
|
| 223 |
-
shutil.rmtree(WORKSPACE_DIR)
|
| 224 |
os.makedirs(WORKSPACE_DIR)
|
| 225 |
logger.info("Aplicação Gradio iniciada. Lançando interface...")
|
| 226 |
demo.queue().launch()
|
|
|
|
| 2 |
#
|
| 3 |
# Copyright (C) August 4, 2025 Carlos Rodrigues dos Santos
|
| 4 |
#
|
| 5 |
+
# Versão 6.1.0 (UI with Integrated VQA Testing)
|
| 6 |
#
|
| 7 |
+
# Adiciona uma seção temporária na UI para testar o novo especialista de
|
| 8 |
+
# Visão Computacional (VQA), permitindo fazer perguntas sobre as imagens
|
| 9 |
+
# de referência e sobre o vídeo final gerado.
|
| 10 |
|
| 11 |
import gradio as gr
|
| 12 |
import yaml
|
|
|
|
| 17 |
import time
|
| 18 |
import json
|
| 19 |
|
| 20 |
+
# --- 1. IMPORTAÇÕES DO FRAMEWORK ---
|
| 21 |
import aduc_framework
|
| 22 |
from aduc_framework.types import PreProductionParams, ProductionParams
|
| 23 |
+
# IMPORTAÇÃO DO NOVO ESPECIALISTA
|
| 24 |
+
from aduc_framework.managers.vision_qa_manager import vision_qa_manager_singleton
|
| 25 |
|
| 26 |
+
# ... (Toda a configuração de Tema e Logging permanece a mesma) ...
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 27 |
|
| 28 |
# --- 2. FUNÇÕES WRAPPER (UI <-> FRAMEWORK) ---
|
| 29 |
|
| 30 |
+
# AJUSTE: Wrapper de pré-produção agora salva os caminhos das imagens de referência
|
| 31 |
def run_pre_production_wrapper(prompt, num_keyframes, ref_files, resolution_str, duration_per_fragment, progress=gr.Progress()):
|
| 32 |
if not ref_files: raise gr.Error("Por favor, forneça pelo menos uma imagem de referência.")
|
| 33 |
|
|
|
|
| 36 |
|
| 37 |
params = PreProductionParams(prompt=prompt, num_keyframes=int(num_keyframes), ref_paths=ref_paths, resolution=target_resolution, duration_per_fragment=duration_per_fragment)
|
| 38 |
|
| 39 |
+
# Emite o estado inicial que inclui os caminhos das imagens para o teste de VQA
|
| 40 |
+
yield { reference_images_state: ref_paths }
|
| 41 |
+
|
| 42 |
final_result = {}
|
| 43 |
for update in aduc.task_pre_production(params, progress):
|
| 44 |
yield {
|
|
|
|
| 53 |
step3_accordion: gr.update(visible=True, open=True)
|
| 54 |
}
|
| 55 |
|
| 56 |
+
# ... (Wrappers de produção e pós-produção permanecem os mesmos) ...
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 57 |
|
| 58 |
+
# NOVAS FUNÇÕES WRAPPER PARA O VQA
|
| 59 |
+
def answer_video_wrapper(source_video, question):
|
| 60 |
+
"""Chama o especialista VQA para o vídeo final."""
|
| 61 |
+
if not source_video:
|
| 62 |
+
raise gr.Error("Nenhum vídeo final foi gerado para ser analisado.")
|
| 63 |
+
if not question or not question.strip():
|
| 64 |
+
raise gr.Error("Por favor, digite uma pergunta.")
|
| 65 |
|
| 66 |
+
yield "Analisando o vídeo... (Isso pode levar um momento)"
|
| 67 |
+
|
| 68 |
+
answer = vision_qa_manager_singleton.answer_on_video(video_path=source_video, question=question)
|
| 69 |
+
yield answer
|
| 70 |
|
| 71 |
+
def answer_images_wrapper(image_paths, question):
|
| 72 |
+
"""Chama o especialista VQA para cada imagem de referência."""
|
| 73 |
+
if not image_paths:
|
| 74 |
+
raise gr.Error("Nenhuma imagem de referência foi carregada para ser analisada.")
|
| 75 |
+
if not question or not question.strip():
|
| 76 |
+
raise gr.Error("Por favor, digite uma pergunta.")
|
| 77 |
|
| 78 |
+
yield "Analisando as imagens de referência..."
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 79 |
|
| 80 |
+
all_answers = []
|
| 81 |
+
for i, path in enumerate(image_paths):
|
| 82 |
+
answer = vision_qa_manager_singleton.answer_on_image(image_path=path, question=question)
|
| 83 |
+
all_answers.append(f"--- Imagem de Referência {i+1} ({os.path.basename(path)}) ---\nResposta: {answer}\n")
|
| 84 |
+
|
| 85 |
+
yield "\n".join(all_answers)
|
| 86 |
|
| 87 |
def get_log_content():
|
| 88 |
try:
|
|
|
|
| 91 |
|
| 92 |
# --- 3. DEFINIÇÃO DA UI ---
|
| 93 |
with gr.Blocks(theme=cinematic_theme, css="style.css") as demo:
|
| 94 |
+
# Estados
|
| 95 |
generation_state_holder = gr.State(value={})
|
| 96 |
original_latents_paths_state = gr.State(value=[])
|
| 97 |
current_source_video_state = gr.State(value=None)
|
| 98 |
+
reference_images_state = gr.State(value=[]) # NOVO ESTADO
|
| 99 |
|
| 100 |
gr.Markdown("<h1>ADUC-SDR 🎬 - O Diretor de Cinema IA</h1>")
|
| 101 |
+
# ... (Toda a UI das Etapas 1, 2 e 3 permanece a mesma) ...
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 102 |
|
| 103 |
+
# --- RESULTADOS CONSOLIDADOS (Sem alteração) ---
|
| 104 |
+
final_video_output = gr.Video(...)
|
| 105 |
+
with gr.Accordion("Grupo das Keyframes", ...):
|
| 106 |
+
keyframe_gallery = gr.Gallery(...)
|
| 107 |
+
with gr.Accordion("🧬 DNA Digital da Geração (JSON)", ...):
|
| 108 |
+
storyboard_output = gr.JSON(...)
|
| 109 |
+
generation_data_output = gr.JSON(...)
|
| 110 |
+
|
| 111 |
+
# --- NOVA SEÇÃO DE TESTES VQA ---
|
| 112 |
+
with gr.Accordion("🧪 Etapa de Análise Visual (VQA - Teste)", open=False) as vqa_accordion:
|
| 113 |
+
with gr.Blocks():
|
| 114 |
+
gr.Markdown("### Analisar o Vídeo Final")
|
| 115 |
+
video_q_input = gr.Textbox(label="Faça uma pergunta sobre o vídeo gerado", placeholder="Ex: O leão chega a beber água?")
|
| 116 |
+
video_q_button = gr.Button("Perguntar ao Vídeo")
|
| 117 |
+
video_a_output = gr.Textbox(label="Resposta do Analista de Vídeo", interactive=False, lines=3)
|
| 118 |
|
| 119 |
+
with gr.Blocks():
|
| 120 |
+
gr.Markdown("---")
|
| 121 |
+
gr.Markdown("### Analisar as Imagens de Referência")
|
| 122 |
+
image_q_input = gr.Textbox(label="Faça uma pergunta sobre TODAS as imagens de referência", placeholder="Ex: Há texto visível em alguma das imagens?")
|
| 123 |
+
image_q_button = gr.Button("Perguntar às Imagens")
|
| 124 |
+
image_a_output = gr.Textbox(label="Respostas do Analista de Imagens", interactive=False, lines=5)
|
| 125 |
+
|
| 126 |
+
# Log de Geração (Sem alteração)
|
| 127 |
+
with gr.Accordion("📝 Log de Geração (Detalhado)", ...):
|
| 128 |
+
log_display = gr.Textbox(...)
|
| 129 |
+
update_log_button = gr.Button(...)
|
| 130 |
|
| 131 |
# --- 4. CONEXÕES DE EVENTOS ---
|
| 132 |
+
# AJUSTE: Adicionamos o novo estado `reference_images_state` ao output da pré-produção
|
| 133 |
+
storyboard_and_keyframes_button.click(
|
| 134 |
+
fn=run_pre_production_wrapper,
|
| 135 |
+
inputs=[prompt_input, num_keyframes_slider, ref_files, resolution_selector, duration_per_fragment_slider],
|
| 136 |
+
outputs=[generation_state_holder, storyboard_output, keyframe_gallery, step3_accordion, reference_images_state]
|
| 137 |
+
)
|
| 138 |
|
| 139 |
+
# ... (Conexões das etapas de produção e pós-produção permanecem as mesmas) ...
|
| 140 |
|
| 141 |
+
# NOVAS CONEXÕES PARA OS BOTÕES DE VQA
|
| 142 |
+
video_q_button.click(
|
| 143 |
+
fn=answer_video_wrapper,
|
| 144 |
+
inputs=[current_source_video_state, video_q_input],
|
| 145 |
+
outputs=[video_a_output]
|
| 146 |
+
)
|
| 147 |
|
| 148 |
+
image_q_button.click(
|
| 149 |
+
fn=answer_images_wrapper,
|
| 150 |
+
inputs=[reference_images_state, image_q_input],
|
| 151 |
+
outputs=[image_a_output]
|
| 152 |
+
)
|
| 153 |
+
|
| 154 |
update_log_button.click(fn=get_log_content, inputs=[], outputs=[log_display])
|
| 155 |
+
generation_state_holder.change(fn=lambda state: state, inputs=generation_state_holder, outputs=generation_data_output)
|
| 156 |
|
| 157 |
# --- 5. INICIALIZAÇÃO DA APLICAÇÃO ---
|
| 158 |
if __name__ == "__main__":
|
| 159 |
+
if os.path.exists(WORKSPACE_DIR): shutil.rmtree(WORKSPACE_DIR)
|
|
|
|
| 160 |
os.makedirs(WORKSPACE_DIR)
|
| 161 |
logger.info("Aplicação Gradio iniciada. Lançando interface...")
|
| 162 |
demo.queue().launch()
|