Update aduc_framework/orchestrator.py
Browse files
aduc_framework/orchestrator.py
CHANGED
|
@@ -3,6 +3,11 @@
|
|
| 3 |
# Copyright (C) August 4, 2025 Carlos Rodrigues dos Santos
|
| 4 |
#
|
| 5 |
# Versão 3.2.0 (Com Orquestração de Pós-Produção)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 6 |
|
| 7 |
import logging
|
| 8 |
from typing import List, Dict, Any, Tuple, Callable, Optional, Generator
|
|
@@ -13,7 +18,7 @@ import shutil
|
|
| 13 |
from pathlib import Path
|
| 14 |
import time
|
| 15 |
import gc
|
| 16 |
-
import torch
|
| 17 |
|
| 18 |
# Importa componentes internos do framework
|
| 19 |
from .director import AducDirector
|
|
@@ -26,7 +31,6 @@ from .managers.mmaudio_manager import mmaudio_manager_singleton
|
|
| 26 |
from .managers.vae_manager import vae_manager_singleton
|
| 27 |
from .tools.video_encode_tool import video_encode_tool_singleton
|
| 28 |
|
| 29 |
-
|
| 30 |
logger = logging.getLogger(__name__)
|
| 31 |
|
| 32 |
ProgressCallback = Optional[Callable[[float, str], None]]
|
|
@@ -43,7 +47,7 @@ class AducOrchestrator:
|
|
| 43 |
self.editor.initialize(workspace_dir)
|
| 44 |
self.painter = deformes3d_engine_singleton
|
| 45 |
self.painter.initialize(workspace_dir)
|
| 46 |
-
self.device = 'cuda' if torch.cuda.is_available() else 'cpu'
|
| 47 |
logger.info("ADUC Maestro (Framework Core) está no pódio. Engenheiros especialistas prontos.")
|
| 48 |
|
| 49 |
def get_current_state(self) -> GenerationState:
|
|
@@ -57,7 +61,6 @@ class AducOrchestrator:
|
|
| 57 |
logger.info(f"Imagem de referência processada e salva em: {processed_path}")
|
| 58 |
return processed_path
|
| 59 |
|
| 60 |
-
# --- TAREFAS DE PRÉ-PRODUÇÃO E PRODUÇÃO (sem alterações lógicas) ---
|
| 61 |
def task_pre_production(self, params: PreProductionParams, progress_callback: ProgressCallback = None) -> Tuple[List[str], List[str], GenerationState]:
|
| 62 |
logger.info("Maestro: Iniciando tarefa de Pré-Produção.")
|
| 63 |
self.director.update_parameters("pre_producao", params)
|
|
@@ -83,8 +86,6 @@ class AducOrchestrator:
|
|
| 83 |
logger.info("Maestro: Tarefa de Produção do Filme Original concluída.")
|
| 84 |
return final_video_path, latent_paths, final_state
|
| 85 |
|
| 86 |
-
# --- TAREFAS DE PÓS-PRODUÇÃO (MOVIDAS PARA CÁ) ---
|
| 87 |
-
|
| 88 |
def task_run_latent_upscaler(self, latent_paths: List[str], chunk_size: int, progress_callback: ProgressCallback = None) -> Generator[Dict[str, Any], None, None]:
|
| 89 |
if not self.director.workspace_dir: raise RuntimeError("Orchestrator não inicializado corretamente.")
|
| 90 |
if not latent_paths:
|
|
@@ -117,7 +118,7 @@ class AducOrchestrator:
|
|
| 117 |
|
| 118 |
base_name = f"upscaled_clip_{i:04d}_{run_timestamp}"
|
| 119 |
current_clip_path = os.path.join(temp_dir, f"{base_name}.mp4")
|
| 120 |
-
self.editor.save_video_from_tensor(pixel_tensor, current_clip_path, fps=24)
|
| 121 |
final_upscaled_clip_paths.append(current_clip_path)
|
| 122 |
del pixel_tensor; gc.collect(); torch.cuda.empty_cache()
|
| 123 |
|
|
|
|
| 3 |
# Copyright (C) August 4, 2025 Carlos Rodrigues dos Santos
|
| 4 |
#
|
| 5 |
# Versão 3.2.0 (Com Orquestração de Pós-Produção)
|
| 6 |
+
#
|
| 7 |
+
# Esta versão representa a camada de orquestração do Aduc Framework.
|
| 8 |
+
# Ela é agnóstica a qualquer interface (UI ou API) e opera com
|
| 9 |
+
# tipos de dados bem definidos (Pydantic) e um estado de geração central.
|
| 10 |
+
# Agora, é responsável por inicializar os singletons e orquestrar todas as etapas.
|
| 11 |
|
| 12 |
import logging
|
| 13 |
from typing import List, Dict, Any, Tuple, Callable, Optional, Generator
|
|
|
|
| 18 |
from pathlib import Path
|
| 19 |
import time
|
| 20 |
import gc
|
| 21 |
+
import torch
|
| 22 |
|
| 23 |
# Importa componentes internos do framework
|
| 24 |
from .director import AducDirector
|
|
|
|
| 31 |
from .managers.vae_manager import vae_manager_singleton
|
| 32 |
from .tools.video_encode_tool import video_encode_tool_singleton
|
| 33 |
|
|
|
|
| 34 |
logger = logging.getLogger(__name__)
|
| 35 |
|
| 36 |
ProgressCallback = Optional[Callable[[float, str], None]]
|
|
|
|
| 47 |
self.editor.initialize(workspace_dir)
|
| 48 |
self.painter = deformes3d_engine_singleton
|
| 49 |
self.painter.initialize(workspace_dir)
|
| 50 |
+
self.device = 'cuda' if torch.cuda.is_available() else 'cpu'
|
| 51 |
logger.info("ADUC Maestro (Framework Core) está no pódio. Engenheiros especialistas prontos.")
|
| 52 |
|
| 53 |
def get_current_state(self) -> GenerationState:
|
|
|
|
| 61 |
logger.info(f"Imagem de referência processada e salva em: {processed_path}")
|
| 62 |
return processed_path
|
| 63 |
|
|
|
|
| 64 |
def task_pre_production(self, params: PreProductionParams, progress_callback: ProgressCallback = None) -> Tuple[List[str], List[str], GenerationState]:
|
| 65 |
logger.info("Maestro: Iniciando tarefa de Pré-Produção.")
|
| 66 |
self.director.update_parameters("pre_producao", params)
|
|
|
|
| 86 |
logger.info("Maestro: Tarefa de Produção do Filme Original concluída.")
|
| 87 |
return final_video_path, latent_paths, final_state
|
| 88 |
|
|
|
|
|
|
|
| 89 |
def task_run_latent_upscaler(self, latent_paths: List[str], chunk_size: int, progress_callback: ProgressCallback = None) -> Generator[Dict[str, Any], None, None]:
|
| 90 |
if not self.director.workspace_dir: raise RuntimeError("Orchestrator não inicializado corretamente.")
|
| 91 |
if not latent_paths:
|
|
|
|
| 118 |
|
| 119 |
base_name = f"upscaled_clip_{i:04d}_{run_timestamp}"
|
| 120 |
current_clip_path = os.path.join(temp_dir, f"{base_name}.mp4")
|
| 121 |
+
self.editor.save_video_from_tensor(pixel_tensor, current_clip_path, fps=24)
|
| 122 |
final_upscaled_clip_paths.append(current_clip_path)
|
| 123 |
del pixel_tensor; gc.collect(); torch.cuda.empty_cache()
|
| 124 |
|