Update deformes4D_engine.py
Browse files- deformes4D_engine.py +120 -263
deformes4D_engine.py
CHANGED
|
@@ -1,282 +1,139 @@
|
|
| 1 |
-
#
|
| 2 |
# Copyright (C) 4 de Agosto de 2025 Carlos Rodrigues dos Santos
|
| 3 |
#
|
| 4 |
-
#
|
| 5 |
-
#
|
| 6 |
-
#
|
| 7 |
-
#
|
| 8 |
-
# This file is part of the ADUC-SDR project. It contains the core logic for
|
| 9 |
-
# video fragment generation, latent manipulation, and dynamic editing,
|
| 10 |
-
# governed by the ADUC orchestrator.
|
| 11 |
-
# This component is licensed under the GNU Affero General Public License v3.0.
|
| 12 |
|
| 13 |
import os
|
| 14 |
import time
|
| 15 |
-
import
|
| 16 |
-
import numpy as np
|
| 17 |
-
import torch
|
| 18 |
import logging
|
| 19 |
-
from PIL import Image, ImageOps
|
| 20 |
-
from dataclasses import dataclass
|
| 21 |
import gradio as gr
|
|
|
|
| 22 |
import subprocess
|
| 23 |
-
import
|
| 24 |
-
import
|
| 25 |
|
| 26 |
-
from
|
| 27 |
from ltx_manager_helpers import ltx_manager_singleton
|
| 28 |
-
from
|
| 29 |
-
from
|
| 30 |
-
from ltx_video.models.autoencoders.vae_encode import vae_encode, vae_decode
|
| 31 |
|
|
|
|
| 32 |
logger = logging.getLogger(__name__)
|
| 33 |
|
| 34 |
-
|
| 35 |
-
|
| 36 |
-
latent_tensor: torch.Tensor
|
| 37 |
-
media_frame_number: int
|
| 38 |
-
conditioning_strength: float
|
| 39 |
-
|
| 40 |
-
class Deformes4DEngine:
|
| 41 |
-
def __init__(self, ltx_manager, workspace_dir="deformes_workspace"):
|
| 42 |
-
self.ltx_manager = ltx_manager
|
| 43 |
self.workspace_dir = workspace_dir
|
| 44 |
-
self.
|
| 45 |
-
self.
|
| 46 |
-
logger.info("
|
| 47 |
-
|
| 48 |
-
|
| 49 |
-
|
| 50 |
-
|
| 51 |
-
|
| 52 |
-
|
| 53 |
-
|
| 54 |
-
|
| 55 |
-
|
| 56 |
-
|
| 57 |
-
|
| 58 |
-
|
| 59 |
-
|
| 60 |
-
|
| 61 |
-
|
| 62 |
-
|
| 63 |
-
|
| 64 |
-
|
| 65 |
-
|
| 66 |
-
|
| 67 |
-
|
| 68 |
-
|
| 69 |
-
|
| 70 |
-
|
| 71 |
-
|
| 72 |
-
|
| 73 |
-
|
| 74 |
-
|
| 75 |
-
def save_video_from_tensor(self, video_tensor: torch.Tensor, path: str, fps: int = 24):
|
| 76 |
-
if video_tensor is None or video_tensor.ndim != 5 or video_tensor.shape[2] == 0: return
|
| 77 |
-
video_tensor = video_tensor.squeeze(0).permute(1, 2, 3, 0)
|
| 78 |
-
video_tensor = (video_tensor.clamp(-1, 1) + 1) / 2.0
|
| 79 |
-
video_np = (video_tensor.detach().cpu().float().numpy() * 255).astype(np.uint8)
|
| 80 |
-
with imageio.get_writer(path, fps=fps, codec='libx264', quality=8) as writer:
|
| 81 |
-
for frame in video_np: writer.append_data(frame)
|
| 82 |
-
logger.info(f"VÃdeo salvo em: {path}")
|
| 83 |
-
|
| 84 |
-
def _preprocess_image_for_latent_conversion(self, image: Image.Image, target_resolution: tuple) -> Image.Image:
|
| 85 |
-
if image.size != target_resolution:
|
| 86 |
-
logger.info(f" - AÇÃO: Redimensionando imagem de {image.size} para {target_resolution} antes da conversão para latente.")
|
| 87 |
-
return ImageOps.fit(image, target_resolution, Image.Resampling.LANCZOS)
|
| 88 |
-
return image
|
| 89 |
-
|
| 90 |
-
def pil_to_latent(self, pil_image: Image.Image) -> torch.Tensor:
|
| 91 |
-
image_np = np.array(pil_image).astype(np.float32) / 255.0
|
| 92 |
-
tensor = torch.from_numpy(image_np).permute(2, 0, 1).unsqueeze(0).unsqueeze(2)
|
| 93 |
-
tensor = (tensor * 2.0) - 1.0
|
| 94 |
-
return self.pixels_to_latents(tensor)
|
| 95 |
|
| 96 |
-
|
| 97 |
-
|
| 98 |
-
|
| 99 |
-
|
| 100 |
-
|
| 101 |
-
|
| 102 |
-
|
| 103 |
-
|
| 104 |
-
|
| 105 |
-
|
| 106 |
-
|
| 107 |
-
|
| 108 |
-
|
| 109 |
-
|
| 110 |
-
|
| 111 |
-
|
| 112 |
-
|
| 113 |
-
|
| 114 |
-
|
| 115 |
-
|
| 116 |
-
|
| 117 |
-
|
| 118 |
-
|
| 119 |
-
|
| 120 |
-
|
| 121 |
-
|
| 122 |
-
|
| 123 |
-
|
| 124 |
-
|
| 125 |
-
|
| 126 |
-
'conditioning_items_data': conditioning_items
|
| 127 |
-
}
|
| 128 |
-
new_full_latents, _ = self.ltx_manager.generate_latent_fragment(**final_ltx_params)
|
| 129 |
-
return new_full_latents
|
| 130 |
-
|
| 131 |
-
def concatenate_videos_ffmpeg(self, video_paths: list[str], output_path: str) -> str:
|
| 132 |
-
if not video_paths:
|
| 133 |
-
raise gr.Error("Nenhum fragmento de vÃdeo para montar.")
|
| 134 |
-
list_file_path = os.path.join(self.workspace_dir, "concat_list.txt")
|
| 135 |
-
with open(list_file_path, 'w', encoding='utf-8') as f:
|
| 136 |
-
for path in video_paths:
|
| 137 |
-
f.write(f"file '{os.path.abspath(path)}'\n")
|
| 138 |
-
cmd_list = ['ffmpeg', '-y', '-f', 'concat', '-safe', '0', '-i', list_file_path, '-c', 'copy', output_path]
|
| 139 |
-
logger.info("Executando concatenação FFmpeg...")
|
| 140 |
-
try:
|
| 141 |
-
subprocess.run(cmd_list, check=True, capture_output=True, text=True)
|
| 142 |
-
except subprocess.CalledProcessError as e:
|
| 143 |
-
logger.error(f"Erro no FFmpeg: {e.stderr}")
|
| 144 |
-
raise gr.Error(f"Falha na montagem final do vÃdeo. Detalhes: {e.stderr}")
|
| 145 |
-
return output_path
|
| 146 |
-
|
| 147 |
-
def generate_full_movie(self,
|
| 148 |
-
keyframes: list,
|
| 149 |
-
global_prompt: str,
|
| 150 |
-
storyboard: list,
|
| 151 |
-
seconds_per_fragment: float,
|
| 152 |
-
overlap_percent: int,
|
| 153 |
-
echo_frames: int,
|
| 154 |
-
handler_strength: float,
|
| 155 |
-
destination_convergence_strength: float,
|
| 156 |
-
video_resolution: int,
|
| 157 |
-
use_continuity_director: bool,
|
| 158 |
-
progress: gr.Progress = gr.Progress()):
|
| 159 |
|
| 160 |
-
|
| 161 |
-
"guidance_scale": 1.0,
|
| 162 |
-
"stg_scale": 0.0,
|
| 163 |
-
"rescaling_scale": 0.15,
|
| 164 |
-
"num_inference_steps": 7,
|
| 165 |
-
}
|
| 166 |
-
|
| 167 |
-
keyframe_paths = [item[0] if isinstance(item, tuple) else item for item in keyframes]
|
| 168 |
-
video_clips_paths, story_history, audio_history = [], "", "This is the beginning of the film."
|
| 169 |
-
target_resolution_tuple = (video_resolution, video_resolution)
|
| 170 |
-
n_trim_latents = self._quantize_to_multiple(int(seconds_per_fragment * 24 * (overlap_percent / 100.0)), 8)
|
| 171 |
-
#echo_frames = 8
|
| 172 |
|
| 173 |
-
|
| 174 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 175 |
|
| 176 |
-
|
| 177 |
-
|
| 178 |
-
|
| 179 |
-
|
| 180 |
-
|
| 181 |
-
|
| 182 |
-
|
| 183 |
-
|
| 184 |
-
|
| 185 |
-
|
| 186 |
-
transition_type = "start"
|
| 187 |
-
motion_prompt = gemini_singleton.get_initial_motion_prompt(
|
| 188 |
-
global_prompt, start_keyframe_path, destination_keyframe_path, present_scene_desc
|
| 189 |
-
)
|
| 190 |
-
else:
|
| 191 |
-
past_keyframe_path = keyframe_paths[i-1]
|
| 192 |
-
past_scene_desc = storyboard[i-1]
|
| 193 |
-
future_scene_desc = storyboard[i+1] if (i+1) < len(storyboard) else "A cena final."
|
| 194 |
-
decision = gemini_singleton.get_cinematic_decision(
|
| 195 |
-
global_prompt=global_prompt, story_history=story_history,
|
| 196 |
-
past_keyframe_path=past_keyframe_path, present_keyframe_path=start_keyframe_path,
|
| 197 |
-
future_keyframe_path=destination_keyframe_path, past_scene_desc=past_scene_desc,
|
| 198 |
-
present_scene_desc=present_scene_desc, future_scene_desc=future_scene_desc
|
| 199 |
-
)
|
| 200 |
-
transition_type, motion_prompt = decision["transition_type"], decision["motion_prompt"]
|
| 201 |
-
|
| 202 |
-
story_history += f"\n- Ato {i+1} ({transition_type}): {motion_prompt}"
|
| 203 |
-
|
| 204 |
-
if use_continuity_director: # Assume-se que este checkbox controla os diretores de vÃdeo e som
|
| 205 |
-
if is_first_fragment:
|
| 206 |
-
audio_prompt = gemini_singleton.get_sound_director_prompt(
|
| 207 |
-
audio_history=audio_history,
|
| 208 |
-
past_keyframe_path=start_keyframe_path, present_keyframe_path=start_keyframe_path,
|
| 209 |
-
future_keyframe_path=destination_keyframe_path, present_scene_desc=present_scene_desc,
|
| 210 |
-
motion_prompt=motion_prompt, future_scene_desc=storyboard[i+1] if (i+1) < len(storyboard) else "The final scene."
|
| 211 |
-
)
|
| 212 |
-
else:
|
| 213 |
-
audio_prompt = gemini_singleton.get_sound_director_prompt(
|
| 214 |
-
audio_history=audio_history, past_keyframe_path=keyframe_paths[i-1],
|
| 215 |
-
present_keyframe_path=start_keyframe_path, future_keyframe_path=destination_keyframe_path,
|
| 216 |
-
present_scene_desc=present_scene_desc, motion_prompt=motion_prompt,
|
| 217 |
-
future_scene_desc=storyboard[i+1] if (i+1) < len(storyboard) else "The final scene."
|
| 218 |
-
)
|
| 219 |
-
else:
|
| 220 |
-
audio_prompt = present_scene_desc # Fallback para o prompt da cena se o diretor de som estiver desligado
|
| 221 |
-
|
| 222 |
-
audio_history = audio_prompt
|
| 223 |
-
|
| 224 |
-
conditioning_items = []
|
| 225 |
-
current_ltx_params = {**base_ltx_params, "handler_strength": handler_strength, "motion_prompt": motion_prompt}
|
| 226 |
-
total_frames_to_generate = self._quantize_to_multiple(int(seconds_per_fragment * 24), 8) + 1
|
| 227 |
-
|
| 228 |
-
if is_first_fragment:
|
| 229 |
-
img_start = self._preprocess_image_for_latent_conversion(Image.open(start_keyframe_path).convert("RGB"), target_resolution_tuple)
|
| 230 |
-
start_latent = self.pil_to_latent(img_start)
|
| 231 |
-
conditioning_items.append(LatentConditioningItem(start_latent, 0, 1.0))
|
| 232 |
-
if transition_type != "cut":
|
| 233 |
-
img_dest = self._preprocess_image_for_latent_conversion(Image.open(destination_keyframe_path).convert("RGB"), target_resolution_tuple)
|
| 234 |
-
destination_latent = self.pil_to_latent(img_dest)
|
| 235 |
-
conditioning_items.append(LatentConditioningItem(destination_latent, total_frames_to_generate - 1, destination_convergence_strength))
|
| 236 |
-
else:
|
| 237 |
-
previous_latents = self.load_latent_tensor(previous_latents_path)
|
| 238 |
-
handler_latent = previous_latents[:, :, -1:, :, :]
|
| 239 |
-
trimmed_for_echo = previous_latents[:, :, :-n_trim_latents, :, :] if n_trim_latents > 0 and previous_latents.shape[2] > n_trim_latents else previous_latents
|
| 240 |
-
echo_latents = trimmed_for_echo[:, :, -echo_frames:, :, :]
|
| 241 |
-
handler_frame_position = n_trim_latents + echo_frames
|
| 242 |
-
|
| 243 |
-
|
| 244 |
-
conditioning_items.append(LatentConditioningItem(echo_latents, 0, 1.0))
|
| 245 |
-
conditioning_items.append(LatentConditioningItem(handler_latent, handler_frame_position, handler_strength))
|
| 246 |
-
del previous_latents, handler_latent, trimmed_for_echo, echo_latents; gc.collect()
|
| 247 |
-
if transition_type == "continuous":
|
| 248 |
-
img_dest = self._preprocess_image_for_latent_conversion(Image.open(destination_keyframe_path).convert("RGB"), target_resolution_tuple)
|
| 249 |
-
destination_latent = self.pil_to_latent(img_dest)
|
| 250 |
-
conditioning_items.append(LatentConditioningItem(destination_latent, total_frames_to_generate - 1, destination_convergence_strength))
|
| 251 |
-
|
| 252 |
-
new_full_latents = self._generate_latent_tensor_internal(conditioning_items, current_ltx_params, target_resolution_tuple, total_frames_to_generate)
|
| 253 |
-
|
| 254 |
-
base_name = f"fragment_{i}_{int(time.time())}"
|
| 255 |
-
new_full_latents_path = os.path.join(self.workspace_dir, f"{base_name}_full.pt")
|
| 256 |
-
self.save_latent_tensor(new_full_latents, new_full_latents_path)
|
| 257 |
-
|
| 258 |
-
previous_latents_path = new_full_latents_path
|
| 259 |
-
|
| 260 |
-
# LÓGICA DE CORTE REMOVIDA - Usamos o tensor completo.
|
| 261 |
-
latents_for_video = new_full_latents
|
| 262 |
-
|
| 263 |
-
video_with_audio_path = self._generate_video_and_audio_from_latents(latents_for_video, audio_prompt, base_name)
|
| 264 |
-
video_clips_paths.append(video_with_audio_path)
|
| 265 |
-
|
| 266 |
-
|
| 267 |
-
if transition_type == "cut":
|
| 268 |
-
previous_latents_path = None
|
| 269 |
-
|
| 270 |
-
|
| 271 |
-
yield {"fragment_path": video_with_audio_path}
|
| 272 |
-
|
| 273 |
-
final_movie_path = os.path.join(self.workspace_dir, f"final_movie_{int(time.time())}.mp4")
|
| 274 |
-
self.concatenate_videos_ffmpeg(video_clips_paths, final_movie_path)
|
| 275 |
|
| 276 |
-
logger.info(
|
| 277 |
-
|
| 278 |
-
|
| 279 |
-
|
| 280 |
-
|
| 281 |
-
|
| 282 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
# aduc_orchestrator.py
|
| 2 |
# Copyright (C) 4 de Agosto de 2025 Carlos Rodrigues dos Santos
|
| 3 |
#
|
| 4 |
+
# Este programa é software livre: você pode redistribuí-lo e/ou modificá-lo
|
| 5 |
+
# sob os termos da Licença Pública Geral Affero GNU...
|
| 6 |
+
# AVISO DE PATENTE PENDENTE: Consulte NOTICE.md.
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 7 |
|
| 8 |
import os
|
| 9 |
import time
|
| 10 |
+
import shutil
|
|
|
|
|
|
|
| 11 |
import logging
|
|
|
|
|
|
|
| 12 |
import gradio as gr
|
| 13 |
+
from PIL import Image, ImageOps
|
| 14 |
import subprocess
|
| 15 |
+
from pathlib import Path
|
| 16 |
+
import json
|
| 17 |
|
| 18 |
+
from deformes4D_engine import Deformes4DEngine
|
| 19 |
from ltx_manager_helpers import ltx_manager_singleton
|
| 20 |
+
from gemini_helpers import gemini_singleton
|
| 21 |
+
from image_specialist import image_specialist_singleton
|
|
|
|
| 22 |
|
| 23 |
+
# Configuração de logging centralizada deve ser feita no app.py
|
| 24 |
logger = logging.getLogger(__name__)
|
| 25 |
|
| 26 |
+
class AducDirector:
|
| 27 |
+
def __init__(self, workspace_dir):
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 28 |
self.workspace_dir = workspace_dir
|
| 29 |
+
os.makedirs(self.workspace_dir, exist_ok=True)
|
| 30 |
+
self.state = {}
|
| 31 |
+
logger.info(f"O palco está pronto. Workspace em '{self.workspace_dir}'.")
|
| 32 |
+
|
| 33 |
+
def reset(self):
|
| 34 |
+
os.makedirs(self.workspace_dir, exist_ok=True)
|
| 35 |
+
self.state = {}
|
| 36 |
+
logger.info("Partitura limpa. Estado do Diretor reiniciado.")
|
| 37 |
+
|
| 38 |
+
def update_state(self, key, value):
|
| 39 |
+
log_value = value if not isinstance(value, (dict, list)) and not hasattr(value, 'shape') else f"Objeto complexo"
|
| 40 |
+
logger.info(f"Anotando na partitura: Estado '{key}' atualizado.")
|
| 41 |
+
self.state[key] = value
|
| 42 |
+
|
| 43 |
+
def get_state(self, key, default=None):
|
| 44 |
+
return self.state.get(key, default)
|
| 45 |
+
|
| 46 |
+
class AducOrchestrator:
|
| 47 |
+
def __init__(self, workspace_dir: str):
|
| 48 |
+
self.director = AducDirector(workspace_dir)
|
| 49 |
+
self.editor = Deformes4DEngine(ltx_manager_singleton, workspace_dir)
|
| 50 |
+
self.painter = image_specialist_singleton
|
| 51 |
+
logger.info("Maestro ADUC está no pódio. Músicos (especialistas) prontos.")
|
| 52 |
+
|
| 53 |
+
def process_image_for_story(self, image_path: str, size: int, filename: str = None) -> str:
|
| 54 |
+
"""
|
| 55 |
+
Pré-processa uma imagem de referência: converte para RGB, redimensiona para um
|
| 56 |
+
quadrado e salva no diretório de trabalho.
|
| 57 |
+
"""
|
| 58 |
+
img = Image.open(image_path).convert("RGB")
|
| 59 |
+
img_square = ImageOps.fit(img, (size, size), Image.Resampling.LANCZOS)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 60 |
|
| 61 |
+
if filename:
|
| 62 |
+
processed_path = os.path.join(self.director.workspace_dir, filename)
|
| 63 |
+
else:
|
| 64 |
+
processed_path = os.path.join(self.director.workspace_dir, f"ref_processed_{int(time.time()*1000)}.png")
|
| 65 |
+
|
| 66 |
+
img_square.save(processed_path)
|
| 67 |
+
logger.info(f"Imagem de referência processada e salva em: {processed_path}")
|
| 68 |
+
return processed_path
|
| 69 |
+
|
| 70 |
+
def task_generate_storyboard(self, prompt, num_keyframes, processed_ref_image_paths, progress):
|
| 71 |
+
logger.info(f"Ato 1, Cena 1: Roteiro. Instruindo o Roteirista (Gemini) a criar {num_keyframes} cenas a partir de: '{prompt}'")
|
| 72 |
+
progress(0.2, desc="Consultando Roteirista IA (Gemini)...")
|
| 73 |
+
storyboard = gemini_singleton.generate_storyboard(prompt, num_keyframes, processed_ref_image_paths)
|
| 74 |
+
logger.info(f"Roteirista retornou a partitura: {storyboard}")
|
| 75 |
+
self.director.update_state("storyboard", storyboard)
|
| 76 |
+
self.director.update_state("processed_ref_paths", processed_ref_image_paths)
|
| 77 |
+
return storyboard, processed_ref_image_paths[0], gr.update(visible=True, open=True)
|
| 78 |
+
|
| 79 |
+
def task_select_keyframes(self, storyboard, base_ref_paths, pool_ref_paths):
|
| 80 |
+
logger.info(f"Ato 1, Cena 2 (Alternativa): Fotografia. Instruindo o Editor (Gemini) a selecionar {len(storyboard)} keyframes de um banco de {len(pool_ref_paths)} imagens.")
|
| 81 |
+
selected_paths = gemini_singleton.select_keyframes_from_pool(storyboard, base_ref_paths, pool_ref_paths)
|
| 82 |
+
logger.info(f"Editor selecionou as seguintes cenas: {[os.path.basename(p) for p in selected_paths]}")
|
| 83 |
+
self.director.update_state("keyframes", selected_paths)
|
| 84 |
+
return selected_paths
|
| 85 |
+
|
| 86 |
+
def task_generate_keyframes(self, storyboard, initial_ref_path, global_prompt, keyframe_resolution, progress_callback_factory=None):
|
| 87 |
+
"""
|
| 88 |
+
Delega a tarefa de geração de keyframes para o ImageSpecialist.
|
| 89 |
+
"""
|
| 90 |
+
logger.info(f"Ato 1, Cena 2: Direção de Arte. Delegando ao Especialista de Imagem.")
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 91 |
|
| 92 |
+
general_ref_paths = self.director.get_state("processed_ref_paths", [])
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 93 |
|
| 94 |
+
final_keyframes = self.painter.generate_keyframes_from_storyboard(
|
| 95 |
+
storyboard=storyboard,
|
| 96 |
+
initial_ref_path=initial_ref_path,
|
| 97 |
+
global_prompt=global_prompt,
|
| 98 |
+
keyframe_resolution=int(keyframe_resolution),
|
| 99 |
+
general_ref_paths=general_ref_paths,
|
| 100 |
+
progress_callback_factory=progress_callback_factory
|
| 101 |
+
)
|
| 102 |
|
| 103 |
+
self.director.update_state("keyframes", final_keyframes)
|
| 104 |
+
logger.info("Maestro: Especialista de Imagem concluiu a geração dos keyframes.")
|
| 105 |
+
return final_keyframes
|
| 106 |
+
|
| 107 |
+
def task_produce_final_movie_with_feedback(self, keyframes, global_prompt, seconds_per_fragment,
|
| 108 |
+
overlap_percent, echo_frames,
|
| 109 |
+
handler_strength,
|
| 110 |
+
destination_convergence_strength,
|
| 111 |
+
video_resolution, use_continuity_director,
|
| 112 |
+
use_cinematographer, progress):
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 113 |
|
| 114 |
+
logger.info("AducOrchestrator: Delegando a produção do filme completo ao Deformes4DEngine.")
|
| 115 |
+
storyboard = self.director.get_state("storyboard", [])
|
| 116 |
+
|
| 117 |
+
# --- CORREÇÃO AQUI ---
|
| 118 |
+
for update in self.editor.generate_full_movie(
|
| 119 |
+
keyframes=keyframes,
|
| 120 |
+
global_prompt=global_prompt,
|
| 121 |
+
storyboard=storyboard,
|
| 122 |
+
seconds_per_fragment=seconds_per_fragment,
|
| 123 |
+
overlap_percent=overlap_percent,
|
| 124 |
+
echo_frames=echo_frames,
|
| 125 |
+
handler_strength=handler_strength,
|
| 126 |
+
destination_convergence_strength=destination_convergence_strength,
|
| 127 |
+
video_resolution=video_resolution,
|
| 128 |
+
use_continuity_director=use_continuity_director,
|
| 129 |
+
progress=progress # <-- ADICIONADO o argumento 'progress'
|
| 130 |
+
):
|
| 131 |
+
if "fragment_path" in update and update["fragment_path"]:
|
| 132 |
+
yield {"fragment_path": update["fragment_path"]}
|
| 133 |
+
elif "final_path" in update and update["final_path"]:
|
| 134 |
+
final_movie_path = update["final_path"]
|
| 135 |
+
self.director.update_state("final_video_path", final_movie_path)
|
| 136 |
+
yield {"final_path": final_movie_path}
|
| 137 |
+
break
|
| 138 |
+
|
| 139 |
+
logger.info("AducOrchestrator: Produção do filme concluída e estado do diretor atualizado.")
|