Update app.py
Browse files
app.py
CHANGED
|
@@ -1,7 +1,7 @@
|
|
| 1 |
#Uma implementação aberta e funcional da arquitetura ADUC-SDR para geração de vídeo coerente.
|
| 2 |
# Copyright (C) 4 de Agosto de 2025 Carlos Rodrigues dos Santos
|
| 3 |
#
|
| 4 |
-
#Versao: 1.5
|
| 5 |
#
|
| 6 |
# Contato:
|
| 7 |
# Carlos Rodrigues dos Santos
|
|
@@ -40,7 +40,6 @@ from aduc_orchestrator import AducOrchestrator
|
|
| 40 |
|
| 41 |
# --- 1. CONFIGURAÇÃO E INICIALIZAÇÃO ---
|
| 42 |
|
| 43 |
-
# Configuração de logging para um arquivo e para o console.
|
| 44 |
LOG_FILE_PATH = "aduc_log.txt"
|
| 45 |
if os.path.exists(LOG_FILE_PATH):
|
| 46 |
os.remove(LOG_FILE_PATH)
|
|
@@ -62,21 +61,18 @@ root_logger.addHandler(file_handler)
|
|
| 62 |
|
| 63 |
logger = logging.getLogger(__name__)
|
| 64 |
|
| 65 |
-
# Carrega os textos de internacionalização (i18n) para a UI.
|
| 66 |
i18n = {}
|
| 67 |
try:
|
| 68 |
with open("i18n.json", "r", encoding="utf-8") as f:
|
| 69 |
i18n = json.load(f)
|
| 70 |
except Exception as e:
|
| 71 |
logger.error(f"Erro ao carregar i18n.json: {e}")
|
| 72 |
-
i18n = {"pt": {}, "en": {}, "zh": {}}
|
| 73 |
|
| 74 |
-
# Garante que as chaves de idioma existam para evitar erros.
|
| 75 |
if 'pt' not in i18n: i18n['pt'] = i18n.get('en', {})
|
| 76 |
if 'en' not in i18n: i18n['en'] = {}
|
| 77 |
if 'zh' not in i18n: i18n['zh'] = i18n.get('en', {})
|
| 78 |
|
| 79 |
-
# Inicializa o Orquestrador ADUC a partir do arquivo de configuração.
|
| 80 |
try:
|
| 81 |
with open("config.yaml", 'r') as f: config = yaml.safe_load(f)
|
| 82 |
WORKSPACE_DIR = config['application']['workspace_dir']
|
|
@@ -86,7 +82,7 @@ except Exception as e:
|
|
| 86 |
logger.error(f"ERRO CRÍTICO ao inicializar: {e}", exc_info=True)
|
| 87 |
exit()
|
| 88 |
|
| 89 |
-
# --- 2. WRAPPERS DA UI
|
| 90 |
|
| 91 |
def run_mode_a_wrapper(prompt, num_keyframes, ref_files, resolution_str, duration_per_fragment, progress=gr.Progress()):
|
| 92 |
if not ref_files:
|
|
@@ -135,35 +131,28 @@ def run_mode_b_wrapper(prompt, num_keyframes, ref_files, progress=gr.Progress())
|
|
| 135 |
return gr.update(value=storyboard), gr.update(value=selected_keyframes), gr.update(visible=True, open=True)
|
| 136 |
|
| 137 |
def run_video_production_wrapper(keyframes, prompt, duration,
|
| 138 |
-
trim_percent,
|
| 139 |
-
|
| 140 |
-
video_resolution,
|
| 141 |
progress=gr.Progress()):
|
| 142 |
yield {
|
| 143 |
-
video_fragments_gallery: gr.update(value=None, visible=True),
|
| 144 |
final_video_output: gr.update(value=None, visible=True, label="🎬 Produzindo seu filme... Por favor, aguarde.")
|
| 145 |
}
|
| 146 |
|
| 147 |
resolution = int(video_resolution.split('x')[0])
|
| 148 |
-
|
| 149 |
-
video_fragments_so_far = []
|
| 150 |
final_movie_path = None
|
| 151 |
|
| 152 |
for update in aduc.task_produce_final_movie_with_feedback(
|
| 153 |
keyframes, prompt, duration,
|
| 154 |
-
int(trim_percent),
|
| 155 |
-
|
| 156 |
-
resolution,
|
| 157 |
):
|
| 158 |
-
if "
|
| 159 |
-
video_fragments_so_far.append(update["fragment_path"])
|
| 160 |
-
yield { video_fragments_gallery: gr.update(value=video_fragments_so_far), final_video_output: gr.update() }
|
| 161 |
-
elif "final_path" in update and update["final_path"]:
|
| 162 |
final_movie_path = update["final_path"]
|
| 163 |
break
|
| 164 |
|
| 165 |
yield {
|
| 166 |
-
video_fragments_gallery: gr.update(),
|
| 167 |
final_video_output: gr.update(value=final_movie_path, label="🎉 FILME COMPLETO 🎉")
|
| 168 |
}
|
| 169 |
|
|
@@ -176,34 +165,37 @@ def get_log_content():
|
|
| 176 |
|
| 177 |
def update_ui_language(lang_code):
|
| 178 |
lang_map = i18n.get(lang_code, i18n.get('en', {}))
|
| 179 |
-
# Mapeia os textos para cada componente da UI, incluindo os novos.
|
| 180 |
return {
|
| 181 |
title_md: gr.update(value=f"# {lang_map.get('app_title')}"),
|
| 182 |
subtitle_md: gr.update(value=lang_map.get('app_subtitle')),
|
| 183 |
lang_selector: gr.update(label=lang_map.get('lang_selector_label')),
|
| 184 |
step1_accordion: gr.update(label=lang_map.get('step1_accordion')),
|
| 185 |
-
prompt_input: gr.update(label=lang_map.get('prompt_label')
|
| 186 |
-
ref_image_input: gr.update(label=lang_map.get('ref_images_label')),
|
| 187 |
-
num_keyframes_slider: gr.update(label=lang_map.get('keyframes_label')
|
| 188 |
duration_per_fragment_slider: gr.update(label=lang_map.get('duration_label'), info=lang_map.get('duration_info')),
|
| 189 |
storyboard_and_keyframes_button: gr.update(value=lang_map.get('storyboard_and_keyframes_button')),
|
| 190 |
storyboard_from_photos_button: gr.update(value=lang_map.get('storyboard_from_photos_button')),
|
|
|
|
| 191 |
storyboard_output: gr.update(label=lang_map.get('storyboard_output_label')),
|
| 192 |
keyframe_gallery: gr.update(label=lang_map.get('keyframes_gallery_label')),
|
| 193 |
-
|
| 194 |
-
|
| 195 |
-
continuity_director_checkbox: gr.update(label=lang_map.get('continuity_director_label')),
|
| 196 |
produce_button: gr.update(value=lang_map.get('produce_button')),
|
| 197 |
-
video_fragments_gallery: gr.update(label=lang_map.get('video_fragments_gallery_label')),
|
| 198 |
final_video_output: gr.update(label=lang_map.get('final_movie_with_audio_label')),
|
| 199 |
log_accordion: gr.update(label=lang_map.get('log_accordion_label')),
|
| 200 |
log_display: gr.update(label=lang_map.get('log_display_label')),
|
| 201 |
update_log_button: gr.update(value=lang_map.get('update_log_button')),
|
|
|
|
|
|
|
| 202 |
trim_percent_slider: gr.update(label=lang_map.get('trim_percent_label'), info=lang_map.get('trim_percent_info')),
|
| 203 |
forca_guia_slider: gr.update(label=lang_map.get('forca_guia_label'), info=lang_map.get('forca_guia_info')),
|
| 204 |
convergencia_destino_slider: gr.update(label=lang_map.get('convergencia_final_label'), info=lang_map.get('convergencia_final_info')),
|
| 205 |
-
|
| 206 |
-
|
|
|
|
|
|
|
|
|
|
| 207 |
}
|
| 208 |
|
| 209 |
# --- 3. DEFINIÇÃO DA UI ---
|
|
@@ -215,117 +207,48 @@ with gr.Blocks(theme=gr.themes.Soft()) as demo:
|
|
| 215 |
|
| 216 |
with gr.Row():
|
| 217 |
lang_selector = gr.Radio(["pt", "en", "zh"], value="pt", label=default_lang.get('lang_selector_label'))
|
| 218 |
-
resolution_selector = gr.Radio(["480x480"], value="480x480", label="Resolução
|
| 219 |
|
| 220 |
with gr.Accordion(default_lang.get('step1_accordion'), open=True) as step1_accordion:
|
| 221 |
-
prompt_input = gr.Textbox(label=default_lang.get('prompt_label'),
|
| 222 |
-
# --- CORREÇÃO APLICADA AQUI ---
|
| 223 |
ref_image_input = gr.File(label=default_lang.get('ref_images_label'), file_count="multiple", file_types=["image"])
|
| 224 |
with gr.Row():
|
| 225 |
-
num_keyframes_slider = gr.Slider(minimum=3, maximum=42, value=5, step=1, label=default_lang.get('keyframes_label')
|
| 226 |
duration_per_fragment_slider = gr.Slider(label=default_lang.get('duration_label'), info=default_lang.get('duration_info'), minimum=2.0, maximum=10.0, value=4.0, step=0.1)
|
| 227 |
with gr.Row():
|
| 228 |
storyboard_and_keyframes_button = gr.Button(default_lang.get('storyboard_and_keyframes_button'), variant="primary")
|
| 229 |
storyboard_from_photos_button = gr.Button(default_lang.get('storyboard_from_photos_button'))
|
| 230 |
-
gr.Markdown(f"*{default_lang.get('step1_mode_b_info')}*")
|
| 231 |
storyboard_output = gr.JSON(label=default_lang.get('storyboard_output_label'))
|
| 232 |
keyframe_gallery = gr.Gallery(label=default_lang.get('keyframes_gallery_label'), visible=True, object_fit="contain", height="auto", type="filepath")
|
| 233 |
|
| 234 |
-
with gr.Accordion(default_lang.get('step3_accordion'), open=False, visible=False) as
|
| 235 |
-
|
| 236 |
-
continuity_director_checkbox = gr.Checkbox(label=default_lang.get('continuity_director_label'), value=True)
|
| 237 |
|
| 238 |
-
gr.
|
| 239 |
-
|
| 240 |
trim_percent_slider = gr.Slider(minimum=10, maximum=90, value=50, step=5,
|
| 241 |
label=default_lang.get('trim_percent_label'),
|
| 242 |
info=default_lang.get('trim_percent_info'))
|
| 243 |
-
|
| 244 |
-
|
| 245 |
-
|
| 246 |
-
|
| 247 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 248 |
|
| 249 |
produce_button = gr.Button(default_lang.get('produce_button'), variant="primary")
|
| 250 |
|
| 251 |
-
video_fragments_gallery = gr.Gallery(label=default_lang.get('video_fragments_gallery_label'), visible=False, object_fit="contain", height="auto", type="filepath")
|
| 252 |
final_video_output = gr.Video(label=default_lang.get('final_movie_with_audio_label'), visible=False)
|
| 253 |
|
| 254 |
with gr.Accordion(default_lang.get('log_accordion_label'), open=False) as log_accordion:
|
| 255 |
log_display = gr.Textbox(label=default_lang.get('log_display_label'), lines=20, interactive=False, autoscroll=True)
|
| 256 |
update_log_button = gr.Button(default_lang.get('update_log_button'))
|
| 257 |
-
|
| 258 |
-
with gr.Accordion(default_lang.get('doc_accordion_label'), open=False) as doc_accordion:
|
| 259 |
-
doc_aduc_title_md = gr.Markdown(f"### {default_lang.get('doc_aduc_title')}")
|
| 260 |
-
gr.Markdown(
|
| 261 |
-
"""
|
| 262 |
-
1. **fragmenta** solicitações acima do limite de contexto de qualquer modelo,
|
| 263 |
-
2. **escala linearmente** (processo sequencial com memória persistida),
|
| 264 |
-
3. **distribui** sub-tarefas a **especialistas** (modelos/ferramentas heterogêneos), e
|
| 265 |
-
4. **realimenta** a próxima etapa com avaliação do que foi feito/esperado (LLM diretor).
|
| 266 |
-
|
| 267 |
-
Não é um modelo; é uma **camada orquestradora** plugável antes do input de modelos existentes (texto, imagem, áudio, vídeo), usando *tokens universais* e a tecnologia atual.
|
| 268 |
-
"""
|
| 269 |
-
)
|
| 270 |
-
gr.Markdown("---")
|
| 271 |
-
gr.Markdown(f"### O Esquema Matemático do Paradigma (Revisado)")
|
| 272 |
-
gr.Markdown(
|
| 273 |
-
"""
|
| 274 |
-
#### **FÓRMULA 1: O FRAGMENTO INICIAL (Gênesis, `i=1`)**
|
| 275 |
-
*Define a criação do primeiro clipe, estabelecendo o estado inicial do movimento a partir de âncoras geométricas estáticas.*
|
| 276 |
-
|
| 277 |
-
**Planejamento:** `P_1 = Γ( K_1, K_2, P_geral )`
|
| 278 |
-
|
| 279 |
-
**Execução:** `V_1 = Ψ( { (K_1, F_start, ω_1), (K_2, F_end, ω_2) }, P_1 )`
|
| 280 |
-
|
| 281 |
-
---
|
| 282 |
-
#### **FÓRMULA 2: A CADEIA CAUSAL COM DÉJÀ-VU (Momentum, `i > 1`)**
|
| 283 |
-
*O coração da arquitetura. Define como a inércia, a trajetória original e o destino futuro são combinados para garantir uma continuidade fluida.*
|
| 284 |
-
|
| 285 |
-
**Destilação:**
|
| 286 |
-
- `C_(i-1) = Δ_eco( V'_(i-1) )`
|
| 287 |
-
- `D_(i-1) = Δ_dejavu( V_(i-1) )`
|
| 288 |
-
|
| 289 |
-
**Planejamento Adaptativo:** `P_i = Γ( C_(i-1), D_(i-1), K_(i+1), P_geral, H_(i-1), prompt_humano )`
|
| 290 |
-
|
| 291 |
-
**Execução:** `V_i = Ψ( { (C_(i-1), F_start, 1.0), (D_(i-1), F_mid, ω_dejavu), (K_(i+1), F_end, ω_dest) }, P_i )`
|
| 292 |
-
"""
|
| 293 |
-
)
|
| 294 |
-
gr.Markdown("---")
|
| 295 |
-
gr.Markdown(f"### Componentes (Léxico da Arquitetura):")
|
| 296 |
-
gr.Markdown(
|
| 297 |
-
"""
|
| 298 |
-
- **`V_i`**: Fragmento de Vídeo.
|
| 299 |
-
- **`K_i`**: Âncora Geométrica (Keyframe).
|
| 300 |
-
- **`C_i`**: **Contexto Causal Cinético** (O "Eco" / Vetor de Inércia).
|
| 301 |
-
- **`D_i`**: **Contexto Causal de Trajetória** (O "Déjà-Vu" / Âncora de Caminho).
|
| 302 |
-
- **`P_i`**: Prompt Sintetizado (A Intenção da IA).
|
| 303 |
-
- **`H_i`**: Histórico Narrativo (A Memória Semântica).
|
| 304 |
-
- **`Γ`**: **Oráculo de Síntese Adaptativo** (O Cineasta / LLM Diretor).
|
| 305 |
-
- **`Ψ`**: Motor de Geração (A Câmera / Especialista).
|
| 306 |
-
- **`Δ`**: Mecanismo de Destilação (O Editor / Orquestrador).
|
| 307 |
-
- **`ω`**: **Peso de Convergência** (A Força da Âncora).
|
| 308 |
-
"""
|
| 309 |
-
)
|
| 310 |
-
gr.Markdown("---")
|
| 311 |
-
gr.Markdown(f"### Análise da Inovação:")
|
| 312 |
-
gr.Markdown(
|
| 313 |
-
"""
|
| 314 |
-
A introdução de **pesos de convergência (`ω`)** ajustáveis e a distinção entre **Contexto Cinético (`C`)** e **Contexto de Trajetória (`D`)** são inovações cruciais. Elas transformam os keyframes de "destinos rígidos" em "horizontes de eventos sugeridos". O **Planejamento Adaptativo (`Γ`)** garante que a intenção humana seja reinterpretada à luz do estado atual da narrativa, permitindo que a IA não apenas siga instruções, mas que **conte uma história coerente**. O resultado é um sistema que mantém a continuidade física e semântica, permitindo que cada reinício de fragmento seja sutilmente diferente, mantendo a narrativa viva.
|
| 315 |
-
"""
|
| 316 |
-
)
|
| 317 |
-
gr.Markdown("---")
|
| 318 |
-
gr.Markdown(f"### Contato / Contact")
|
| 319 |
-
gr.Markdown(
|
| 320 |
-
"""
|
| 321 |
-
- **Author / Autor:** Carlos Rodrigues dos Santos
|
| 322 |
-
- **Email:** carlex22@gmail.com
|
| 323 |
-
- **GitHub:** [https://github.com/carlex22/Aduc-sdr](https://github.com/carlex22/Aduc-sdr)
|
| 324 |
-
- **Hugging Face Spaces:**
|
| 325 |
-
- [Ltx-SuperTime-60Secondos](https://huggingface.co/spaces/Carlexx/Ltx-SuperTime-60Secondos/)
|
| 326 |
-
- [Novinho](https://huggingface.co/spaces/Carlexxx/Novinho/)
|
| 327 |
-
"""
|
| 328 |
-
)
|
| 329 |
|
| 330 |
# --- 4. CONEXÕES DA UI ---
|
| 331 |
all_ui_components = list(update_ui_language('pt').keys())
|
|
@@ -334,32 +257,27 @@ A introdução de **pesos de convergência (`ω`)** ajustáveis e a distinção
|
|
| 334 |
storyboard_and_keyframes_button.click(
|
| 335 |
fn=run_mode_a_wrapper,
|
| 336 |
inputs=[prompt_input, num_keyframes_slider, ref_image_input, resolution_selector, duration_per_fragment_slider],
|
| 337 |
-
outputs=[storyboard_output, keyframe_gallery,
|
| 338 |
)
|
| 339 |
|
| 340 |
storyboard_from_photos_button.click(
|
| 341 |
fn=run_mode_b_wrapper,
|
| 342 |
inputs=[prompt_input, num_keyframes_slider, ref_image_input],
|
| 343 |
-
outputs=[storyboard_output, keyframe_gallery,
|
| 344 |
)
|
| 345 |
|
| 346 |
produce_button.click(
|
| 347 |
fn=run_video_production_wrapper,
|
| 348 |
inputs=[
|
| 349 |
keyframe_gallery, prompt_input, duration_per_fragment_slider,
|
| 350 |
-
trim_percent_slider,
|
| 351 |
-
|
| 352 |
-
|
| 353 |
-
resolution_selector, continuity_director_checkbox
|
| 354 |
],
|
| 355 |
-
outputs=[
|
| 356 |
)
|
| 357 |
|
| 358 |
-
update_log_button.click(
|
| 359 |
-
fn=get_log_content,
|
| 360 |
-
inputs=[],
|
| 361 |
-
outputs=[log_display]
|
| 362 |
-
)
|
| 363 |
|
| 364 |
# --- 5. INICIALIZAÇÃO DA APLICAÇÃO ---
|
| 365 |
if __name__ == "__main__":
|
|
|
|
| 1 |
#Uma implementação aberta e funcional da arquitetura ADUC-SDR para geração de vídeo coerente.
|
| 2 |
# Copyright (C) 4 de Agosto de 2025 Carlos Rodrigues dos Santos
|
| 3 |
#
|
| 4 |
+
#Versao: 1.5.1
|
| 5 |
#
|
| 6 |
# Contato:
|
| 7 |
# Carlos Rodrigues dos Santos
|
|
|
|
| 40 |
|
| 41 |
# --- 1. CONFIGURAÇÃO E INICIALIZAÇÃO ---
|
| 42 |
|
|
|
|
| 43 |
LOG_FILE_PATH = "aduc_log.txt"
|
| 44 |
if os.path.exists(LOG_FILE_PATH):
|
| 45 |
os.remove(LOG_FILE_PATH)
|
|
|
|
| 61 |
|
| 62 |
logger = logging.getLogger(__name__)
|
| 63 |
|
|
|
|
| 64 |
i18n = {}
|
| 65 |
try:
|
| 66 |
with open("i18n.json", "r", encoding="utf-8") as f:
|
| 67 |
i18n = json.load(f)
|
| 68 |
except Exception as e:
|
| 69 |
logger.error(f"Erro ao carregar i18n.json: {e}")
|
| 70 |
+
i18n = {"pt": {}, "en": {}, "zh": {}}
|
| 71 |
|
|
|
|
| 72 |
if 'pt' not in i18n: i18n['pt'] = i18n.get('en', {})
|
| 73 |
if 'en' not in i18n: i18n['en'] = {}
|
| 74 |
if 'zh' not in i18n: i18n['zh'] = i18n.get('en', {})
|
| 75 |
|
|
|
|
| 76 |
try:
|
| 77 |
with open("config.yaml", 'r') as f: config = yaml.safe_load(f)
|
| 78 |
WORKSPACE_DIR = config['application']['workspace_dir']
|
|
|
|
| 82 |
logger.error(f"ERRO CRÍTICO ao inicializar: {e}", exc_info=True)
|
| 83 |
exit()
|
| 84 |
|
| 85 |
+
# --- 2. WRAPPERS DA UI ---
|
| 86 |
|
| 87 |
def run_mode_a_wrapper(prompt, num_keyframes, ref_files, resolution_str, duration_per_fragment, progress=gr.Progress()):
|
| 88 |
if not ref_files:
|
|
|
|
| 131 |
return gr.update(value=storyboard), gr.update(value=selected_keyframes), gr.update(visible=True, open=True)
|
| 132 |
|
| 133 |
def run_video_production_wrapper(keyframes, prompt, duration,
|
| 134 |
+
trim_percent, handler_strength, destination_convergence_strength,
|
| 135 |
+
use_upscaler, use_refiner, use_hd, use_audio,
|
| 136 |
+
video_resolution,
|
| 137 |
progress=gr.Progress()):
|
| 138 |
yield {
|
|
|
|
| 139 |
final_video_output: gr.update(value=None, visible=True, label="🎬 Produzindo seu filme... Por favor, aguarde.")
|
| 140 |
}
|
| 141 |
|
| 142 |
resolution = int(video_resolution.split('x')[0])
|
|
|
|
|
|
|
| 143 |
final_movie_path = None
|
| 144 |
|
| 145 |
for update in aduc.task_produce_final_movie_with_feedback(
|
| 146 |
keyframes, prompt, duration,
|
| 147 |
+
int(trim_percent), handler_strength, destination_convergence_strength,
|
| 148 |
+
use_upscaler, use_refiner, use_hd, use_audio,
|
| 149 |
+
resolution, use_continuity_director=True, progress=progress
|
| 150 |
):
|
| 151 |
+
if "final_path" in update and update["final_path"]:
|
|
|
|
|
|
|
|
|
|
| 152 |
final_movie_path = update["final_path"]
|
| 153 |
break
|
| 154 |
|
| 155 |
yield {
|
|
|
|
| 156 |
final_video_output: gr.update(value=final_movie_path, label="🎉 FILME COMPLETO 🎉")
|
| 157 |
}
|
| 158 |
|
|
|
|
| 165 |
|
| 166 |
def update_ui_language(lang_code):
|
| 167 |
lang_map = i18n.get(lang_code, i18n.get('en', {}))
|
|
|
|
| 168 |
return {
|
| 169 |
title_md: gr.update(value=f"# {lang_map.get('app_title')}"),
|
| 170 |
subtitle_md: gr.update(value=lang_map.get('app_subtitle')),
|
| 171 |
lang_selector: gr.update(label=lang_map.get('lang_selector_label')),
|
| 172 |
step1_accordion: gr.update(label=lang_map.get('step1_accordion')),
|
| 173 |
+
prompt_input: gr.update(label=lang_map.get('prompt_label')),
|
| 174 |
+
ref_image_input: gr.update(label=lang_map.get('ref_images_label')),
|
| 175 |
+
num_keyframes_slider: gr.update(label=lang_map.get('keyframes_label')),
|
| 176 |
duration_per_fragment_slider: gr.update(label=lang_map.get('duration_label'), info=lang_map.get('duration_info')),
|
| 177 |
storyboard_and_keyframes_button: gr.update(value=lang_map.get('storyboard_and_keyframes_button')),
|
| 178 |
storyboard_from_photos_button: gr.update(value=lang_map.get('storyboard_from_photos_button')),
|
| 179 |
+
step1_mode_b_info_md: gr.update(value=f"*{lang_map.get('step1_mode_b_info')}*"),
|
| 180 |
storyboard_output: gr.update(label=lang_map.get('storyboard_output_label')),
|
| 181 |
keyframe_gallery: gr.update(label=lang_map.get('keyframes_gallery_label')),
|
| 182 |
+
step2_accordion: gr.update(label=lang_map.get('step3_accordion')),
|
| 183 |
+
step2_description_md: gr.update(value=lang_map.get('step3_description')),
|
|
|
|
| 184 |
produce_button: gr.update(value=lang_map.get('produce_button')),
|
|
|
|
| 185 |
final_video_output: gr.update(label=lang_map.get('final_movie_with_audio_label')),
|
| 186 |
log_accordion: gr.update(label=lang_map.get('log_accordion_label')),
|
| 187 |
log_display: gr.update(label=lang_map.get('log_display_label')),
|
| 188 |
update_log_button: gr.update(value=lang_map.get('update_log_button')),
|
| 189 |
+
advanced_options_accordion: gr.update(label=lang_map.get('advanced_options_accordion')),
|
| 190 |
+
causality_controls_title_md: gr.update(value=f"**{lang_map.get('causality_controls_title')}**"),
|
| 191 |
trim_percent_slider: gr.update(label=lang_map.get('trim_percent_label'), info=lang_map.get('trim_percent_info')),
|
| 192 |
forca_guia_slider: gr.update(label=lang_map.get('forca_guia_label'), info=lang_map.get('forca_guia_info')),
|
| 193 |
convergencia_destino_slider: gr.update(label=lang_map.get('convergencia_final_label'), info=lang_map.get('convergencia_final_info')),
|
| 194 |
+
post_production_controls_title_md: gr.update(value=f"**{lang_map.get('post_production_controls_title')}**"),
|
| 195 |
+
use_upscaler_checkbox: gr.update(label=lang_map.get('use_upscaler_label')),
|
| 196 |
+
use_refiner_checkbox: gr.update(label=lang_map.get('use_refiner_label')),
|
| 197 |
+
use_hd_checkbox: gr.update(label=lang_map.get('use_hd_label')),
|
| 198 |
+
use_audio_checkbox: gr.update(label=lang_map.get('use_audio_label')),
|
| 199 |
}
|
| 200 |
|
| 201 |
# --- 3. DEFINIÇÃO DA UI ---
|
|
|
|
| 207 |
|
| 208 |
with gr.Row():
|
| 209 |
lang_selector = gr.Radio(["pt", "en", "zh"], value="pt", label=default_lang.get('lang_selector_label'))
|
| 210 |
+
resolution_selector = gr.Radio(["480x480"], value="480x480", label="Resolução Base")
|
| 211 |
|
| 212 |
with gr.Accordion(default_lang.get('step1_accordion'), open=True) as step1_accordion:
|
| 213 |
+
prompt_input = gr.Textbox(label=default_lang.get('prompt_label'), value="A majestic lion walks across the savanna, sits down, and then roars at the setting sun.")
|
|
|
|
| 214 |
ref_image_input = gr.File(label=default_lang.get('ref_images_label'), file_count="multiple", file_types=["image"])
|
| 215 |
with gr.Row():
|
| 216 |
+
num_keyframes_slider = gr.Slider(minimum=3, maximum=42, value=5, step=1, label=default_lang.get('keyframes_label'))
|
| 217 |
duration_per_fragment_slider = gr.Slider(label=default_lang.get('duration_label'), info=default_lang.get('duration_info'), minimum=2.0, maximum=10.0, value=4.0, step=0.1)
|
| 218 |
with gr.Row():
|
| 219 |
storyboard_and_keyframes_button = gr.Button(default_lang.get('storyboard_and_keyframes_button'), variant="primary")
|
| 220 |
storyboard_from_photos_button = gr.Button(default_lang.get('storyboard_from_photos_button'))
|
| 221 |
+
step1_mode_b_info_md = gr.Markdown(f"*{default_lang.get('step1_mode_b_info')}*")
|
| 222 |
storyboard_output = gr.JSON(label=default_lang.get('storyboard_output_label'))
|
| 223 |
keyframe_gallery = gr.Gallery(label=default_lang.get('keyframes_gallery_label'), visible=True, object_fit="contain", height="auto", type="filepath")
|
| 224 |
|
| 225 |
+
with gr.Accordion(default_lang.get('step3_accordion'), open=False, visible=False) as step2_accordion:
|
| 226 |
+
step2_description_md = gr.Markdown(default_lang.get('step3_description'))
|
|
|
|
| 227 |
|
| 228 |
+
with gr.Accordion(default_lang.get('advanced_options_accordion'), open=True) as advanced_options_accordion:
|
| 229 |
+
causality_controls_title_md = gr.Markdown(f"**{default_lang.get('causality_controls_title')}**")
|
| 230 |
trim_percent_slider = gr.Slider(minimum=10, maximum=90, value=50, step=5,
|
| 231 |
label=default_lang.get('trim_percent_label'),
|
| 232 |
info=default_lang.get('trim_percent_info'))
|
| 233 |
+
with gr.Row():
|
| 234 |
+
forca_guia_slider = gr.Slider(label=default_lang.get('forca_guia_label'), minimum=0.0, maximum=1.0, value=0.5, step=0.05, info=default_lang.get('forca_guia_info'))
|
| 235 |
+
convergencia_destino_slider = gr.Slider(label=default_lang.get('convergencia_final_label'), minimum=0.0, maximum=1.0, value=0.75, step=0.05, info=default_lang.get('convergencia_final_info'))
|
| 236 |
+
|
| 237 |
+
gr.Markdown("---")
|
| 238 |
+
post_production_controls_title_md = gr.Markdown(f"**{default_lang.get('post_production_controls_title')}**")
|
| 239 |
+
with gr.Row():
|
| 240 |
+
use_upscaler_checkbox = gr.Checkbox(label=default_lang.get('use_upscaler_label'), value=True)
|
| 241 |
+
use_refiner_checkbox = gr.Checkbox(label=default_lang.get('use_refiner_label'), value=True)
|
| 242 |
+
use_hd_checkbox = gr.Checkbox(label=default_lang.get('use_hd_label'), value=True)
|
| 243 |
+
use_audio_checkbox = gr.Checkbox(label=default_lang.get('use_audio_label'), value=False, interactive=False)
|
| 244 |
|
| 245 |
produce_button = gr.Button(default_lang.get('produce_button'), variant="primary")
|
| 246 |
|
|
|
|
| 247 |
final_video_output = gr.Video(label=default_lang.get('final_movie_with_audio_label'), visible=False)
|
| 248 |
|
| 249 |
with gr.Accordion(default_lang.get('log_accordion_label'), open=False) as log_accordion:
|
| 250 |
log_display = gr.Textbox(label=default_lang.get('log_display_label'), lines=20, interactive=False, autoscroll=True)
|
| 251 |
update_log_button = gr.Button(default_lang.get('update_log_button'))
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 252 |
|
| 253 |
# --- 4. CONEXÕES DA UI ---
|
| 254 |
all_ui_components = list(update_ui_language('pt').keys())
|
|
|
|
| 257 |
storyboard_and_keyframes_button.click(
|
| 258 |
fn=run_mode_a_wrapper,
|
| 259 |
inputs=[prompt_input, num_keyframes_slider, ref_image_input, resolution_selector, duration_per_fragment_slider],
|
| 260 |
+
outputs=[storyboard_output, keyframe_gallery, step2_accordion]
|
| 261 |
)
|
| 262 |
|
| 263 |
storyboard_from_photos_button.click(
|
| 264 |
fn=run_mode_b_wrapper,
|
| 265 |
inputs=[prompt_input, num_keyframes_slider, ref_image_input],
|
| 266 |
+
outputs=[storyboard_output, keyframe_gallery, step2_accordion]
|
| 267 |
)
|
| 268 |
|
| 269 |
produce_button.click(
|
| 270 |
fn=run_video_production_wrapper,
|
| 271 |
inputs=[
|
| 272 |
keyframe_gallery, prompt_input, duration_per_fragment_slider,
|
| 273 |
+
trim_percent_slider, forca_guia_slider, convergencia_destino_slider,
|
| 274 |
+
use_upscaler_checkbox, use_refiner_checkbox, use_hd_checkbox, use_audio_checkbox,
|
| 275 |
+
resolution_selector
|
|
|
|
| 276 |
],
|
| 277 |
+
outputs=[final_video_output]
|
| 278 |
)
|
| 279 |
|
| 280 |
+
update_log_button.click(fn=get_log_content, inputs=[], outputs=[log_display])
|
|
|
|
|
|
|
|
|
|
|
|
|
| 281 |
|
| 282 |
# --- 5. INICIALIZAÇÃO DA APLICAÇÃO ---
|
| 283 |
if __name__ == "__main__":
|