Spaces:
Build error
Build error
Update app.py
Browse files
app.py
CHANGED
|
@@ -2,7 +2,7 @@
|
|
| 2 |
#
|
| 3 |
# Copyright (C) August 4, 2025 Carlos Rodrigues dos Santos
|
| 4 |
#
|
| 5 |
-
# Versão
|
| 6 |
|
| 7 |
import gradio as gr
|
| 8 |
import yaml
|
|
@@ -10,13 +10,14 @@ import logging
|
|
| 10 |
import os
|
| 11 |
import sys
|
| 12 |
import shutil
|
|
|
|
|
|
|
| 13 |
|
| 14 |
# --- 1. IMPORTAÇÃO DO FRAMEWORK E CONFIGURAÇÃO ---
|
| 15 |
import aduc_framework
|
| 16 |
from aduc_framework.types import PreProductionParams, ProductionParams
|
| 17 |
|
| 18 |
-
# Configuração de Tema Cinemático
|
| 19 |
-
# (O código do tema permanece o mesmo, omitido para brevidade, mas deve estar aqui)
|
| 20 |
cinematic_theme = gr.themes.Base(
|
| 21 |
primary_hue=gr.themes.colors.indigo,
|
| 22 |
secondary_hue=gr.themes.colors.purple,
|
|
@@ -34,12 +35,11 @@ cinematic_theme = gr.themes.Base(
|
|
| 34 |
)
|
| 35 |
|
| 36 |
# Configuração de Logging
|
| 37 |
-
# (O código de logging permanece o mesmo, omitido para brevidade, mas deve estar aqui)
|
| 38 |
LOG_FILE_PATH = "aduc_log.txt"
|
| 39 |
if os.path.exists(LOG_FILE_PATH): os.remove(LOG_FILE_PATH)
|
| 40 |
log_format = '%(asctime)s - %(levelname)s - [%(name)s:%(funcName)s] - %(message)s'
|
| 41 |
root_logger = logging.getLogger()
|
| 42 |
-
root_logger.setLevel(logging.INFO)
|
| 43 |
root_logger.handlers.clear()
|
| 44 |
stream_handler = logging.StreamHandler(sys.stdout)
|
| 45 |
stream_handler.setFormatter(logging.Formatter(log_format))
|
|
@@ -57,211 +57,126 @@ try:
|
|
| 57 |
logger.info("Interface Gradio inicializada e conectada ao Aduc Framework.")
|
| 58 |
except Exception as e:
|
| 59 |
logger.critical(f"ERRO CRÍTICO durante a inicialização: {e}", exc_info=True)
|
| 60 |
-
|
| 61 |
-
with gr.Blocks() as demo:
|
| 62 |
gr.Markdown("# ERRO CRÍTICO NA INICIALIZAÇÃO")
|
| 63 |
-
gr.Markdown("Não foi possível iniciar o Aduc Framework. Verifique os logs para mais detalhes.")
|
| 64 |
gr.Textbox(value=str(e), label="Detalhes do Erro", lines=10)
|
| 65 |
demo.launch()
|
| 66 |
exit()
|
| 67 |
|
| 68 |
# --- 2. FUNÇÕES WRAPPER (UI <-> FRAMEWORK) ---
|
| 69 |
|
| 70 |
-
def run_pre_production_wrapper(prompt, num_scenes, ref_files, resolution_str,
|
| 71 |
"""
|
| 72 |
-
Wrapper reativo
|
| 73 |
-
Captura os eventos do Composer e atualiza a UI em tempo real.
|
| 74 |
"""
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 75 |
if not ref_files:
|
| 76 |
raise gr.Error("Por favor, forneça pelo menos uma imagem de referência.")
|
| 77 |
|
| 78 |
target_resolution = int(resolution_str.split('x')[0])
|
| 79 |
-
|
| 80 |
-
# Processa as imagens de referência
|
| 81 |
ref_paths = [aduc.process_image_for_story(f.name, target_resolution, f"ref_processed_{i}.png") for i, f in enumerate(ref_files)]
|
| 82 |
|
| 83 |
-
params =
|
| 84 |
-
prompt
|
| 85 |
-
|
| 86 |
-
|
| 87 |
-
|
| 88 |
-
duration_per_fragment=duration_per_fragment
|
| 89 |
-
)
|
| 90 |
|
| 91 |
-
|
| 92 |
-
|
| 93 |
-
|
| 94 |
-
|
| 95 |
-
|
| 96 |
-
|
| 97 |
-
|
| 98 |
-
|
| 99 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 100 |
|
| 101 |
-
# Gera o dicionário de atualização para os componentes da UI
|
| 102 |
yield {
|
| 103 |
-
|
| 104 |
dna_display: update.get("dna_snapshot", gr.skip()),
|
| 105 |
}
|
| 106 |
|
| 107 |
if status == "error":
|
| 108 |
raise gr.Error(f"Ocorreu um erro no backend: {message}")
|
| 109 |
|
| 110 |
-
if status == "
|
| 111 |
-
|
|
|
|
| 112 |
yield {
|
| 113 |
-
|
| 114 |
-
dna_display: update.get("dna_snapshot"),
|
| 115 |
-
keyframe_gallery: gr.update(value=update.get("keyframe_gallery", [])),
|
| 116 |
-
step3_accordion: gr.update(visible=True, open=True)
|
| 117 |
}
|
| 118 |
-
# O gerador termina aqui para a pré-produção
|
| 119 |
-
return
|
| 120 |
-
|
| 121 |
-
|
| 122 |
-
def run_production_wrapper(current_state_dict, trim_percent, handler_strength, dest_strength, guidance_scale, stg_scale, steps, progress=gr.Progress(track_tqdm=True)):
|
| 123 |
-
"""Wrapper para a geração do vídeo principal."""
|
| 124 |
-
yield {final_video_output: gr.update(value=None, visible=True, label="🎬 Produzindo seu filme...")}
|
| 125 |
-
|
| 126 |
-
# Esta função no orquestrador não é um gerador, então a chamamos diretamente.
|
| 127 |
-
# Precisaremos do estado atual (DNA) que foi salvo no `generation_state_holder`.
|
| 128 |
-
# AducDirector precisará de um método para carregar este estado.
|
| 129 |
-
# Por agora, vamos simular passando o dicionário.
|
| 130 |
-
# aduc.director.load_state_from_dict(current_state_dict) # Idealmente
|
| 131 |
-
|
| 132 |
-
production_params = ProductionParams(
|
| 133 |
-
trim_percent=int(trim_percent), handler_strength=handler_strength,
|
| 134 |
-
destination_convergence_strength=dest_strength, guidance_scale=guidance_scale,
|
| 135 |
-
stg_scale=stg_scale, inference_steps=int(steps)
|
| 136 |
-
)
|
| 137 |
-
|
| 138 |
-
# Assumindo que o `task_produce_original_movie` usa o estado já no `aduc.director`
|
| 139 |
-
# (que foi atualizado pela pré-produção)
|
| 140 |
-
final_video_path, latent_paths, updated_state = aduc.task_produce_original_movie(params=production_params, progress_callback=progress)
|
| 141 |
|
|
|
|
| 142 |
yield {
|
| 143 |
-
|
| 144 |
-
step4_accordion: gr.update(visible=True, open=True),
|
| 145 |
-
original_latents_paths_state: latent_paths,
|
| 146 |
-
current_source_video_state: final_video_path,
|
| 147 |
-
generation_state_holder: updated_state.model_dump(),
|
| 148 |
}
|
| 149 |
|
| 150 |
-
# ... (Os wrappers de pós-produção permanecem os mesmos, pois já usam geradores) ...
|
| 151 |
-
|
| 152 |
-
def get_log_content():
|
| 153 |
-
try:
|
| 154 |
-
with open(LOG_FILE_PATH, "r", encoding="utf-8") as f:
|
| 155 |
-
return f.read()
|
| 156 |
-
except FileNotFoundError:
|
| 157 |
-
return "Arquivo de log ainda não criado."
|
| 158 |
|
| 159 |
# --- 3. DEFINIÇÃO DA UI ---
|
| 160 |
with gr.Blocks(theme=cinematic_theme, css="style.css") as demo:
|
| 161 |
-
# Componentes de Estado
|
| 162 |
generation_state_holder = gr.State(value={})
|
| 163 |
-
original_latents_paths_state = gr.State(value=[])
|
| 164 |
-
current_source_video_state = gr.State(value=None)
|
| 165 |
-
|
| 166 |
-
# Título
|
| 167 |
-
gr.Markdown("<h1>ADUC-SDR 🎬 - O Diretor de Cinema IA</h1>")
|
| 168 |
-
gr.Markdown("<p>Crie um filme completo com vídeo e áudio, orquestrado por uma equipe de IAs especialistas.</p>")
|
| 169 |
|
| 170 |
-
|
| 171 |
-
|
| 172 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 173 |
with gr.Row():
|
| 174 |
-
resolution_selector = gr.Radio(["512x512", "768x768"
|
| 175 |
-
num_scenes_slider = gr.Slider(minimum=2, maximum=
|
| 176 |
-
ref_image_input = gr.File(label="Imagens de Referência
|
| 177 |
-
|
| 178 |
-
|
| 179 |
-
|
| 180 |
-
# Accordion para mostrar o progresso do planejamento em tempo real
|
| 181 |
-
with gr.Accordion("🧠 Diário do Planejador (Pré-Produção em Tempo Real)", open=False) as planning_log_accordion:
|
| 182 |
-
log_display_realtime = gr.Textbox(label="Log da Conversa com IA", lines=15, interactive=False, autoscroll=True)
|
| 183 |
-
dna_display = gr.JSON(label="DNA da Produção (em construção)")
|
| 184 |
|
| 185 |
-
#
|
| 186 |
-
with gr.Accordion("Etapa 2: Produção
|
| 187 |
-
|
| 188 |
-
|
| 189 |
-
handler_strength = gr.Slider(label="Força do Déjà-Vu", minimum=0.0, maximum=1.0, value=0.5, step=0.05)
|
| 190 |
-
dest_strength = gr.Slider(label="Força da Âncora Final", minimum=0.0, maximum=1.0, value=0.75, step=0.05)
|
| 191 |
-
guidance_scale_slider = gr.Slider(minimum=1.0, maximum=10.0, value=2.0, step=0.1, label="Escala de Orientação")
|
| 192 |
-
stg_scale_slider = gr.Slider(minimum=0.0, maximum=1.0, value=0.025, step=0.005, label="Escala STG")
|
| 193 |
-
inference_steps_slider = gr.Slider(minimum=10, maximum=50, value=20, step=1, label="Passos de Inferência")
|
| 194 |
-
produce_original_button = gr.Button("🎬 Produzir Vídeo Original", variant="primary")
|
| 195 |
|
| 196 |
-
# Etapa 3: Pós-Produção
|
| 197 |
-
with gr.Accordion("Etapa 3: Pós-Produção (Opcional)", open=False, visible=False) as step4_accordion:
|
| 198 |
-
# ... (Componentes de pós-produção permanecem os mesmos) ...
|
| 199 |
-
gr.Markdown("Aplique melhorias ao filme. Cada etapa usa o resultado da anterior como fonte.")
|
| 200 |
-
with gr.Accordion("A. Upscaler Latente 2x", open=True):
|
| 201 |
-
upscaler_chunk_size_slider = gr.Slider(minimum=1, maximum=10, value=2, step=1, label="Fragmentos por Lote")
|
| 202 |
-
run_upscaler_button = gr.Button("Executar Upscaler Latente", variant="secondary")
|
| 203 |
-
with gr.Accordion("B. Masterização HD (SeedVR)", open=True):
|
| 204 |
-
hd_steps_slider = gr.Slider(minimum=20, maximum=150, value=100, step=5, label="Passos de Inferência HD")
|
| 205 |
-
run_hd_button = gr.Button("Executar Masterização HD", variant="secondary")
|
| 206 |
-
with gr.Accordion("C. Geração de Áudio", open=True):
|
| 207 |
-
audio_prompt_input = gr.Textbox(label="Prompt de Áudio Detalhado (Opcional)", lines=2, placeholder="Descreva os sons, efeitos e música.")
|
| 208 |
-
run_audio_button = gr.Button("Gerar Áudio", variant="secondary")
|
| 209 |
-
|
| 210 |
-
# Saídas Finais e Logs
|
| 211 |
-
final_video_output = gr.Video(label="Filme Final (Resultado da Última Etapa)", visible=False, interactive=False)
|
| 212 |
-
with gr.Accordion("🖼️ Galeria de Keyframes (Referência)", open=False) as keyframes_accordion:
|
| 213 |
-
keyframe_gallery = gr.Gallery(label="Keyframes Gerados", visible=True, object_fit="contain", height="auto")
|
| 214 |
-
with gr.Accordion("📝 Log de Sessão (Completo)", open=False) as log_accordion:
|
| 215 |
-
log_display_full = gr.Textbox(label="Log da Sessão", lines=20, interactive=False, autoscroll=True)
|
| 216 |
-
update_log_button = gr.Button("Atualizar Log Completo")
|
| 217 |
|
| 218 |
# --- 4. CONEXÕES DE EVENTOS ---
|
| 219 |
-
|
| 220 |
-
# Conexão principal para a pré-produção reativa
|
| 221 |
-
start_planning_button.click(
|
| 222 |
-
fn=lambda: gr.update(open=True), outputs=[planning_log_accordion] # Abre o accordion de log
|
| 223 |
-
).then(
|
| 224 |
fn=run_pre_production_wrapper,
|
| 225 |
-
inputs=[prompt_input, num_scenes_slider, ref_image_input, resolution_selector,
|
| 226 |
-
outputs=[
|
| 227 |
-
)
|
| 228 |
-
|
| 229 |
-
# Conexões para as etapas seguintes
|
| 230 |
-
produce_original_button.click(
|
| 231 |
-
fn=run_production_wrapper,
|
| 232 |
-
inputs=[generation_state_holder, trim_percent_slider, handler_strength, dest_strength, guidance_scale_slider, stg_scale_slider, inference_steps_slider],
|
| 233 |
-
outputs=[final_video_output, step4_accordion, original_latents_paths_state, current_source_video_state, generation_state_holder]
|
| 234 |
-
)
|
| 235 |
-
|
| 236 |
-
run_upscaler_button.click(
|
| 237 |
-
fn=aduc.task_run_latent_upscaler, # Chamando diretamente se já for um gerador
|
| 238 |
-
inputs=[original_latents_paths_state, upscaler_chunk_size_slider],
|
| 239 |
-
outputs=[final_video_output] # Assumindo que o wrapper não é mais necessário
|
| 240 |
-
).then(
|
| 241 |
-
fn=lambda video_path: video_path, inputs=[final_video_output], outputs=[current_source_video_state]
|
| 242 |
)
|
| 243 |
|
| 244 |
-
run_hd_button.click(
|
| 245 |
-
fn=aduc.task_run_hd_mastering,
|
| 246 |
-
inputs=[current_source_video_state, hd_steps_slider, prompt_input],
|
| 247 |
-
outputs=[final_video_output]
|
| 248 |
-
).then(
|
| 249 |
-
fn=lambda video_path: video_path, inputs=[final_video_output], outputs=[current_source_video_state]
|
| 250 |
-
)
|
| 251 |
-
|
| 252 |
-
run_audio_button.click(
|
| 253 |
-
fn=aduc.task_run_audio_generation,
|
| 254 |
-
inputs=[current_source_video_state, audio_prompt_input, prompt_input],
|
| 255 |
-
outputs=[final_video_output]
|
| 256 |
-
)
|
| 257 |
-
|
| 258 |
-
# Conexão para atualizar o log completo
|
| 259 |
-
update_log_button.click(fn=get_log_content, inputs=[], outputs=[log_display_full])
|
| 260 |
-
|
| 261 |
-
# Atualiza o state holder com o DNA final quando a pré-produção termina
|
| 262 |
-
dna_display.change(fn=lambda data: data, inputs=dna_display, outputs=generation_state_holder)
|
| 263 |
-
|
| 264 |
-
|
| 265 |
# --- 5. INICIALIZAÇÃO DA APLICAÇÃO ---
|
| 266 |
if __name__ == "__main__":
|
| 267 |
if os.path.exists(WORKSPACE_DIR):
|
|
|
|
| 2 |
#
|
| 3 |
# Copyright (C) August 4, 2025 Carlos Rodrigues dos Santos
|
| 4 |
#
|
| 5 |
+
# Versão 8.0.0 (Live Writer's Room UI)
|
| 6 |
|
| 7 |
import gradio as gr
|
| 8 |
import yaml
|
|
|
|
| 10 |
import os
|
| 11 |
import sys
|
| 12 |
import shutil
|
| 13 |
+
import time
|
| 14 |
+
from typing import Dict, Any, Generator
|
| 15 |
|
| 16 |
# --- 1. IMPORTAÇÃO DO FRAMEWORK E CONFIGURAÇÃO ---
|
| 17 |
import aduc_framework
|
| 18 |
from aduc_framework.types import PreProductionParams, ProductionParams
|
| 19 |
|
| 20 |
+
# Configuração de Tema Cinemático
|
|
|
|
| 21 |
cinematic_theme = gr.themes.Base(
|
| 22 |
primary_hue=gr.themes.colors.indigo,
|
| 23 |
secondary_hue=gr.themes.colors.purple,
|
|
|
|
| 35 |
)
|
| 36 |
|
| 37 |
# Configuração de Logging
|
|
|
|
| 38 |
LOG_FILE_PATH = "aduc_log.txt"
|
| 39 |
if os.path.exists(LOG_FILE_PATH): os.remove(LOG_FILE_PATH)
|
| 40 |
log_format = '%(asctime)s - %(levelname)s - [%(name)s:%(funcName)s] - %(message)s'
|
| 41 |
root_logger = logging.getLogger()
|
| 42 |
+
root_logger.setLevel(logging.INFO) # Mude para DEBUG para ver todos os logs detalhados
|
| 43 |
root_logger.handlers.clear()
|
| 44 |
stream_handler = logging.StreamHandler(sys.stdout)
|
| 45 |
stream_handler.setFormatter(logging.Formatter(log_format))
|
|
|
|
| 57 |
logger.info("Interface Gradio inicializada e conectada ao Aduc Framework.")
|
| 58 |
except Exception as e:
|
| 59 |
logger.critical(f"ERRO CRÍTICO durante a inicialização: {e}", exc_info=True)
|
| 60 |
+
with gr.Blocks(theme=cinematic_theme) as demo:
|
|
|
|
| 61 |
gr.Markdown("# ERRO CRÍTICO NA INICIALIZAÇÃO")
|
| 62 |
+
gr.Markdown("Não foi possível iniciar o Aduc Framework. Verifique os logs (`aduc_log.txt`) para mais detalhes.")
|
| 63 |
gr.Textbox(value=str(e), label="Detalhes do Erro", lines=10)
|
| 64 |
demo.launch()
|
| 65 |
exit()
|
| 66 |
|
| 67 |
# --- 2. FUNÇÕES WRAPPER (UI <-> FRAMEWORK) ---
|
| 68 |
|
| 69 |
+
def run_pre_production_wrapper(prompt, num_scenes, ref_files, resolution_str, fast_mode, progress=gr.Progress(track_tqdm=True)):
|
| 70 |
"""
|
| 71 |
+
Wrapper reativo que alimenta a UI "Writer's Room".
|
|
|
|
| 72 |
"""
|
| 73 |
+
chat_history = []
|
| 74 |
+
|
| 75 |
+
# Mensagem de abertura
|
| 76 |
+
chat_history.append(("Maestro ADUC", f"Equipe, bom dia. Temos um novo projeto. A visão do cliente é: '{prompt}'"))
|
| 77 |
+
yield {writers_room_chatbot: chat_history, dna_display: None} # Limpa o DNA Display
|
| 78 |
+
time.sleep(1) # Pausa para leitura
|
| 79 |
+
|
| 80 |
if not ref_files:
|
| 81 |
raise gr.Error("Por favor, forneça pelo menos uma imagem de referência.")
|
| 82 |
|
| 83 |
target_resolution = int(resolution_str.split('x')[0])
|
|
|
|
|
|
|
| 84 |
ref_paths = [aduc.process_image_for_story(f.name, target_resolution, f"ref_processed_{i}.png") for i, f in enumerate(ref_files)]
|
| 85 |
|
| 86 |
+
params = {
|
| 87 |
+
"prompt": prompt, "num_scenes": int(num_scenes),
|
| 88 |
+
"ref_paths": ref_paths, "duration_per_fragment": 4.0, # Fixo por enquanto
|
| 89 |
+
"resolution": target_resolution, "fast_mode": fast_mode
|
| 90 |
+
}
|
|
|
|
|
|
|
| 91 |
|
| 92 |
+
final_dna = {}
|
| 93 |
+
for update in aduc.task_pre_production_v2(params, progress_callback=progress):
|
| 94 |
+
if update.get("log_type") == "conversation":
|
| 95 |
+
chat_history.append((update.get("actor"), update.get("message")))
|
| 96 |
+
else:
|
| 97 |
+
status = update.get("status", "unknown")
|
| 98 |
+
message = update.get("message", "...")
|
| 99 |
+
|
| 100 |
+
actor_map = {
|
| 101 |
+
"planning": "Planner2D",
|
| 102 |
+
"planning_complete": "Planner2D",
|
| 103 |
+
"progress": "Composer",
|
| 104 |
+
"complete": "Maestro ADUC",
|
| 105 |
+
"error": "Maestro ADUC"
|
| 106 |
+
}
|
| 107 |
+
actor = actor_map.get(status, "Sistema")
|
| 108 |
+
chat_history.append((actor, message))
|
| 109 |
|
|
|
|
| 110 |
yield {
|
| 111 |
+
writers_room_chatbot: chat_history,
|
| 112 |
dna_display: update.get("dna_snapshot", gr.skip()),
|
| 113 |
}
|
| 114 |
|
| 115 |
if status == "error":
|
| 116 |
raise gr.Error(f"Ocorreu um erro no backend: {message}")
|
| 117 |
|
| 118 |
+
if status == "complete":
|
| 119 |
+
final_dna = update.get("dna")
|
| 120 |
+
# Habilita os próximos passos
|
| 121 |
yield {
|
| 122 |
+
production_accordion: gr.update(visible=True, open=True)
|
|
|
|
|
|
|
|
|
|
| 123 |
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 124 |
|
| 125 |
+
# Salva o DNA final no state holder
|
| 126 |
yield {
|
| 127 |
+
generation_state_holder: final_dna
|
|
|
|
|
|
|
|
|
|
|
|
|
| 128 |
}
|
| 129 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 130 |
|
| 131 |
# --- 3. DEFINIÇÃO DA UI ---
|
| 132 |
with gr.Blocks(theme=cinematic_theme, css="style.css") as demo:
|
|
|
|
| 133 |
generation_state_holder = gr.State(value={})
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 134 |
|
| 135 |
+
gr.Markdown("<h1>ADUC-SDR 🎬 - A Sala de Roteiristas de IA</h1>")
|
| 136 |
+
gr.Markdown("Observe em tempo real a equipe de IAs especialistas colaborar para criar seu filme.")
|
| 137 |
+
|
| 138 |
+
with gr.Row():
|
| 139 |
+
with gr.Column(scale=2):
|
| 140 |
+
writers_room_chatbot = gr.Chatbot(
|
| 141 |
+
label="Transcrição da Sala de Operações",
|
| 142 |
+
bubble_full_width=False,
|
| 143 |
+
avatar_images={
|
| 144 |
+
"Maestro ADUC": "https://img.icons8.com/ios-filled/50/FFFFFF/magician.png",
|
| 145 |
+
"Planner2D": "https://img.icons8.com/ios-filled/50/FFFFFF/architect.png",
|
| 146 |
+
"Composer": "https://img.icons8.com/ios-filled/50/FFFFFF/supervisor.png",
|
| 147 |
+
"Llama (IA Criativa)": "https://img.icons8.com/ios-filled/50/FFFFFF/robot-2.png",
|
| 148 |
+
"Sistema": "https://img.icons8.com/ios-filled/50/FFFFFF/gears.png"
|
| 149 |
+
},
|
| 150 |
+
height=700
|
| 151 |
+
)
|
| 152 |
+
with gr.Column(scale=1):
|
| 153 |
+
with gr.Accordion("🧬 DNA da Produção (Ao Vivo)", open=True):
|
| 154 |
+
dna_display = gr.JSON(label="DNA em Construção")
|
| 155 |
+
with gr.Accordion("🎞️ Resultado Final", open=True):
|
| 156 |
+
final_video_output = gr.Video(label="Filme Concluído", interactive=False)
|
| 157 |
+
|
| 158 |
+
with gr.Accordion("📋 Briefing do Projeto (Sua Entrada)", open=True):
|
| 159 |
+
prompt_input = gr.Textbox(label="Ideia Geral do Filme", value="Um leão majestoso caminha pela savana e ruge para o sol poente.")
|
| 160 |
with gr.Row():
|
| 161 |
+
resolution_selector = gr.Radio(["512x512", "768x768"], value="512x512", label="Resolução Base")
|
| 162 |
+
num_scenes_slider = gr.Slider(minimum=2, maximum=5, value=3, step=1, label="Número de Cenas")
|
| 163 |
+
ref_image_input = gr.File(label="Imagens de Referência", file_count="multiple", file_types=["image"])
|
| 164 |
+
fast_mode_checkbox = gr.Checkbox(label="Modo Rápido (Planejamento em etapa única)", value=False)
|
| 165 |
+
start_button = gr.Button("🎬 Enviar Briefing para a Equipe de IA", variant="primary")
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 166 |
|
| 167 |
+
# Etapas 2 e 3 (ainda não conectadas, aguardando o fluxo completo)
|
| 168 |
+
with gr.Accordion("Etapa 2 & 3: Produção e Pós-Produção", open=False, visible=False) as production_accordion:
|
| 169 |
+
gr.Markdown("Após a pré-produção, os controles para gerar o vídeo final aparecerão aqui.")
|
| 170 |
+
# ... (Poderíamos adicionar os sliders de produção aqui)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 171 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 172 |
|
| 173 |
# --- 4. CONEXÕES DE EVENTOS ---
|
| 174 |
+
start_button.click(
|
|
|
|
|
|
|
|
|
|
|
|
|
| 175 |
fn=run_pre_production_wrapper,
|
| 176 |
+
inputs=[prompt_input, num_scenes_slider, ref_image_input, resolution_selector, fast_mode_checkbox],
|
| 177 |
+
outputs=[writers_room_chatbot, dna_display, generation_state_holder, production_accordion]
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 178 |
)
|
| 179 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 180 |
# --- 5. INICIALIZAÇÃO DA APLICAÇÃO ---
|
| 181 |
if __name__ == "__main__":
|
| 182 |
if os.path.exists(WORKSPACE_DIR):
|