Upload 2 files
Browse files- aduc_orchestrator (9).py +199 -0
- app (1) (6).py +290 -0
aduc_orchestrator (9).py
ADDED
|
@@ -0,0 +1,199 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
# aduc_orchestrator.py
|
| 2 |
+
#
|
| 3 |
+
# Copyright (C) August 4, 2025 Carlos Rodrigues dos Santos
|
| 4 |
+
#
|
| 5 |
+
# Version: 2.2.0
|
| 6 |
+
#
|
| 7 |
+
# This file contains the core ADUC (Automated Discovery and Orchestration of Complex tasks)
|
| 8 |
+
# orchestrator, known as the "Maestro" (Γ). Its responsibility is to manage the high-level
|
| 9 |
+
# creative workflow of film production. This version is updated to reflect the final
|
| 10 |
+
# refactored project structure with `engineers` and `managers`.
|
| 11 |
+
|
| 12 |
+
import os
|
| 13 |
+
import logging
|
| 14 |
+
from typing import List, Dict, Any, Generator, Tuple
|
| 15 |
+
|
| 16 |
+
import gradio as gr
|
| 17 |
+
from PIL import Image, ImageOps
|
| 18 |
+
|
| 19 |
+
from engineers.deformes4D import Deformes4DEngine
|
| 20 |
+
from engineers.deformes2D_thinker import deformes2d_thinker_singleton
|
| 21 |
+
from engineers.deformes3D import deformes3d_engine_singleton
|
| 22 |
+
|
| 23 |
+
# The logger is configured in app.py; here we just get the instance.
|
| 24 |
+
logger = logging.getLogger(__name__)
|
| 25 |
+
|
| 26 |
+
class AducDirector:
|
| 27 |
+
"""
|
| 28 |
+
Represents the Scene Director, responsible for managing the production state.
|
| 29 |
+
Acts as the "score" for the orchestra, keeping track of all generated artifacts
|
| 30 |
+
(script, keyframes, etc.) during the creative process.
|
| 31 |
+
"""
|
| 32 |
+
def __init__(self, workspace_dir: str):
|
| 33 |
+
self.workspace_dir = workspace_dir
|
| 34 |
+
os.makedirs(self.workspace_dir, exist_ok=True)
|
| 35 |
+
self.state: Dict[str, Any] = {}
|
| 36 |
+
logger.info(f"The stage is set. Workspace at '{self.workspace_dir}'.")
|
| 37 |
+
|
| 38 |
+
def update_state(self, key: str, value: Any) -> None:
|
| 39 |
+
logger.info(f"Notating on the score: State '{key}' updated.")
|
| 40 |
+
self.state[key] = value
|
| 41 |
+
|
| 42 |
+
def get_state(self, key: str, default: Any = None) -> Any:
|
| 43 |
+
return self.state.get(key, default)
|
| 44 |
+
|
| 45 |
+
class AducOrchestrator:
|
| 46 |
+
"""
|
| 47 |
+
Implements the Maestro (Γ), the central orchestration layer of the ADUC architecture.
|
| 48 |
+
It does not execute AI tasks directly but delegates each step of the creative
|
| 49 |
+
process (scriptwriting, art direction, cinematography) to the appropriate Specialists.
|
| 50 |
+
"""
|
| 51 |
+
def __init__(self, workspace_dir: str):
|
| 52 |
+
self.director = AducDirector(workspace_dir)
|
| 53 |
+
self.editor = Deformes4DEngine(workspace_dir)
|
| 54 |
+
self.painter = deformes3d_engine_singleton
|
| 55 |
+
logger.info("ADUC Maestro is on the podium. Musicians (specialists) are ready.")
|
| 56 |
+
|
| 57 |
+
def process_image_for_story(self, image_path: str, size: int, filename: str) -> str:
|
| 58 |
+
"""
|
| 59 |
+
Pre-processes a reference image, standardizing it for use by the Specialists.
|
| 60 |
+
"""
|
| 61 |
+
img = Image.open(image_path).convert("RGB")
|
| 62 |
+
img_square = ImageOps.fit(img, (size, size), Image.Resampling.LANCZOS)
|
| 63 |
+
processed_path = os.path.join(self.director.workspace_dir, filename)
|
| 64 |
+
img_square.save(processed_path)
|
| 65 |
+
logger.info(f"Reference image processed and saved to: {processed_path}")
|
| 66 |
+
return processed_path
|
| 67 |
+
|
| 68 |
+
# --- PRE-PRODUCTION TASKS ---
|
| 69 |
+
|
| 70 |
+
def task_generate_storyboard(self, prompt: str, num_keyframes: int, ref_image_paths: List[str],
|
| 71 |
+
progress: gr.Progress) -> Tuple[List[str], str, Any]:
|
| 72 |
+
"""
|
| 73 |
+
Delegates the task of creating the storyboard to the Scriptwriter (deformes2D_thinker).
|
| 74 |
+
"""
|
| 75 |
+
logger.info(f"Act 1, Scene 1: Script. Instructing Scriptwriter to create {num_keyframes} scenes.")
|
| 76 |
+
progress(0.2, desc="Consulting AI Scriptwriter...")
|
| 77 |
+
|
| 78 |
+
storyboard = deformes2d_thinker_singleton.generate_storyboard(prompt, num_keyframes, ref_image_paths)
|
| 79 |
+
|
| 80 |
+
logger.info(f"Scriptwriter returned the score: {storyboard}")
|
| 81 |
+
self.director.update_state("storyboard", storyboard)
|
| 82 |
+
self.director.update_state("processed_ref_paths", ref_image_paths)
|
| 83 |
+
return storyboard, ref_image_paths[0], gr.update(visible=True, open=True)
|
| 84 |
+
|
| 85 |
+
def task_select_keyframes(self, storyboard: List[str], base_ref_paths: List[str],
|
| 86 |
+
pool_ref_paths: List[str]) -> List[str]:
|
| 87 |
+
"""
|
| 88 |
+
Delegates to the Photographer (deformes2D_thinker) the task of selecting keyframes.
|
| 89 |
+
"""
|
| 90 |
+
logger.info(f"Act 1, Scene 2 (Photographer Mode): Instructing Photographer to select {len(storyboard)} keyframes.")
|
| 91 |
+
selected_paths = deformes2d_thinker_singleton.select_keyframes_from_pool(storyboard, base_ref_paths, pool_ref_paths)
|
| 92 |
+
logger.info(f"Photographer selected the following scenes: {[os.path.basename(p) for p in selected_paths]}")
|
| 93 |
+
self.director.update_state("keyframes", selected_paths)
|
| 94 |
+
return selected_paths
|
| 95 |
+
|
| 96 |
+
def task_generate_keyframes(self, storyboard: List[str], initial_ref_path: str, global_prompt: str,
|
| 97 |
+
keyframe_resolution: int, progress_callback_factory=None) -> List[str]:
|
| 98 |
+
"""
|
| 99 |
+
Delegates to the Art Director (Deformes3DEngine) the task of generating keyframes.
|
| 100 |
+
"""
|
| 101 |
+
logger.info("Act 1, Scene 2 (Art Director Mode): Delegating to Art Director.")
|
| 102 |
+
general_ref_paths = self.director.get_state("processed_ref_paths", [])
|
| 103 |
+
|
| 104 |
+
final_keyframes = self.painter.generate_keyframes_from_storyboard(
|
| 105 |
+
storyboard=storyboard,
|
| 106 |
+
initial_ref_path=initial_ref_path,
|
| 107 |
+
global_prompt=global_prompt,
|
| 108 |
+
keyframe_resolution=keyframe_resolution,
|
| 109 |
+
general_ref_paths=general_ref_paths,
|
| 110 |
+
progress_callback_factory=progress_callback_factory
|
| 111 |
+
)
|
| 112 |
+
self.director.update_state("keyframes", final_keyframes)
|
| 113 |
+
logger.info("Maestro: Art Director has completed keyframe generation.")
|
| 114 |
+
return final_keyframes
|
| 115 |
+
|
| 116 |
+
# --- PRODUCTION & POST-PRODUCTION TASKS ---
|
| 117 |
+
|
| 118 |
+
def task_produce_original_movie(self, keyframes: List[str], global_prompt: str, seconds_per_fragment: float,
|
| 119 |
+
trim_percent: int, handler_strength: float,
|
| 120 |
+
destination_convergence_strength: float,
|
| 121 |
+
guidance_scale: float, stg_scale: float, inference_steps: int,
|
| 122 |
+
video_resolution: int, use_continuity_director: bool,
|
| 123 |
+
progress: gr.Progress) -> Dict[str, Any]:
|
| 124 |
+
"""
|
| 125 |
+
Delegates the production of the original master video to the Deformes4DEngine.
|
| 126 |
+
"""
|
| 127 |
+
logger.info("Maestro: Delegating production of the original movie to Deformes4DEngine.")
|
| 128 |
+
storyboard = self.director.get_state("storyboard", [])
|
| 129 |
+
|
| 130 |
+
result = self.editor.generate_original_movie(
|
| 131 |
+
keyframes=keyframes,
|
| 132 |
+
global_prompt=global_prompt,
|
| 133 |
+
storyboard=storyboard,
|
| 134 |
+
seconds_per_fragment=seconds_per_fragment,
|
| 135 |
+
trim_percent=trim_percent,
|
| 136 |
+
handler_strength=handler_strength,
|
| 137 |
+
destination_convergence_strength=destination_convergence_strength,
|
| 138 |
+
video_resolution=video_resolution,
|
| 139 |
+
use_continuity_director=use_continuity_director,
|
| 140 |
+
guidance_scale=guidance_scale,
|
| 141 |
+
stg_scale=stg_scale,
|
| 142 |
+
num_inference_steps=inference_steps,
|
| 143 |
+
progress=progress
|
| 144 |
+
)
|
| 145 |
+
|
| 146 |
+
self.director.update_state("final_video_path", result["final_path"])
|
| 147 |
+
self.director.update_state("latent_paths", result["latent_paths"])
|
| 148 |
+
logger.info("Maestro: Original movie production complete.")
|
| 149 |
+
return result
|
| 150 |
+
|
| 151 |
+
def task_run_latent_upscaler(self, latent_paths: List[str], chunk_size: int, progress: gr.Progress) -> Generator[Dict[str, Any], None, None]:
|
| 152 |
+
"""
|
| 153 |
+
Orchestrates the latent upscaling task.
|
| 154 |
+
"""
|
| 155 |
+
logger.info(f"Maestro: Delegating latent upscaling task for {len(latent_paths)} fragments.")
|
| 156 |
+
for update in self.editor.upscale_latents_and_create_video(
|
| 157 |
+
latent_paths=latent_paths,
|
| 158 |
+
chunk_size=chunk_size,
|
| 159 |
+
progress=progress
|
| 160 |
+
):
|
| 161 |
+
if "final_path" in update and update["final_path"]:
|
| 162 |
+
self.director.update_state("final_video_path", update["final_path"])
|
| 163 |
+
yield update
|
| 164 |
+
break
|
| 165 |
+
logger.info("Maestro: Latent upscaling complete.")
|
| 166 |
+
|
| 167 |
+
def task_run_hd_mastering(self, source_video_path: str, model_version: str, steps: int, prompt: str, progress: gr.Progress) -> Generator[Dict[str, Any], None, None]:
|
| 168 |
+
"""
|
| 169 |
+
Orchestrates the HD mastering task.
|
| 170 |
+
"""
|
| 171 |
+
logger.info(f"Maestro: Delegating HD mastering task using SeedVR {model_version}.")
|
| 172 |
+
for update in self.editor.master_video_hd(
|
| 173 |
+
source_video_path=source_video_path,
|
| 174 |
+
model_version=model_version,
|
| 175 |
+
steps=steps,
|
| 176 |
+
prompt=prompt,
|
| 177 |
+
progress=progress
|
| 178 |
+
):
|
| 179 |
+
if "final_path" in update and update["final_path"]:
|
| 180 |
+
self.director.update_state("final_video_path", update["final_path"])
|
| 181 |
+
yield update
|
| 182 |
+
break
|
| 183 |
+
logger.info("Maestro: HD mastering complete.")
|
| 184 |
+
|
| 185 |
+
def task_run_audio_generation(self, source_video_path: str, audio_prompt: str, progress: gr.Progress) -> Generator[Dict[str, Any], None, None]:
|
| 186 |
+
"""
|
| 187 |
+
Orchestrates the audio generation task.
|
| 188 |
+
"""
|
| 189 |
+
logger.info(f"Maestro: Delegating audio generation task.")
|
| 190 |
+
for update in self.editor.generate_audio_for_final_video(
|
| 191 |
+
source_video_path=source_video_path,
|
| 192 |
+
audio_prompt=audio_prompt,
|
| 193 |
+
progress=progress
|
| 194 |
+
):
|
| 195 |
+
if "final_path" in update and update["final_path"]:
|
| 196 |
+
self.director.update_state("final_video_path", update["final_path"])
|
| 197 |
+
yield update
|
| 198 |
+
break
|
| 199 |
+
logger.info("Maestro: Audio generation complete.")
|
app (1) (6).py
ADDED
|
@@ -0,0 +1,290 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
# app.py
|
| 2 |
+
#
|
| 3 |
+
# Copyright (C) August 4, 2025 Carlos Rodrigues dos Santos
|
| 4 |
+
#
|
| 5 |
+
# Version: 2.3.0
|
| 6 |
+
#
|
| 7 |
+
# Contact:
|
| 8 |
+
# Carlos Rodrigues dos Santos
|
| 9 |
+
# carlex22@gmail.com
|
| 10 |
+
#
|
| 11 |
+
# Related Repositories and Projects:
|
| 12 |
+
# GitHub: https://github.com/carlex22/Aduc-sdr
|
| 13 |
+
# YouTube (Results): https://m.youtube.com/channel/UC3EgoJi_Fv7yuDpvfYNtoIQ
|
| 14 |
+
#
|
| 15 |
+
# This program is free software: you can redistribute it and/or modify
|
| 16 |
+
# it under the terms of the GNU Affero General Public License as published by the
|
| 17 |
+
# Free Software Foundation, either version 3 of the License, or
|
| 18 |
+
# (at your option) any later version.
|
| 19 |
+
#
|
| 20 |
+
# This program is distributed in the hope that it will be useful,
|
| 21 |
+
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
| 22 |
+
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
| 23 |
+
# GNU Affero General Public License for more details.
|
| 24 |
+
#
|
| 25 |
+
# You should have received a copy of the GNU Affero General Public License
|
| 26 |
+
# along with this program. If not, see <https://www.gnu.org/licenses/>.
|
| 27 |
+
#
|
| 28 |
+
# PENDING PATENT NOTICE: The ADUC method and system implemented in this
|
| 29 |
+
# software is in the process of being patented. Please see NOTICE.md for details.
|
| 30 |
+
|
| 31 |
+
import gradio as gr
|
| 32 |
+
import yaml
|
| 33 |
+
import logging
|
| 34 |
+
import os
|
| 35 |
+
import sys
|
| 36 |
+
import shutil
|
| 37 |
+
import time
|
| 38 |
+
import json
|
| 39 |
+
|
| 40 |
+
from aduc_orchestrator import AducOrchestrator
|
| 41 |
+
|
| 42 |
+
# --- CUSTOM UI THEME DEFINITION ---
|
| 43 |
+
# This theme provides a professional, dark-mode look and feel, suitable for creative tools.
|
| 44 |
+
cinematic_theme = gr.themes.Base(
|
| 45 |
+
primary_hue=gr.themes.colors.indigo,
|
| 46 |
+
secondary_hue=gr.themes.colors.purple,
|
| 47 |
+
neutral_hue=gr.themes.colors.slate,
|
| 48 |
+
font=(gr.themes.GoogleFont("Inter"), "ui-sans-serif", "system-ui", "sans-serif"),
|
| 49 |
+
).set(
|
| 50 |
+
# -- Colors --
|
| 51 |
+
body_background_fill="#111827", # Slate 900
|
| 52 |
+
body_text_color="#E5E7EB", # Slate 200
|
| 53 |
+
|
| 54 |
+
# -- Buttons --
|
| 55 |
+
button_primary_background_fill="linear-gradient(90deg, #4F46E5, #8B5CF6)", # Gradient Indigo -> Purple
|
| 56 |
+
button_primary_text_color="#FFFFFF",
|
| 57 |
+
button_secondary_background_fill="#374151", # Slate 700
|
| 58 |
+
button_secondary_border_color="#4B5563",
|
| 59 |
+
button_secondary_text_color="#E5E7EB",
|
| 60 |
+
|
| 61 |
+
# -- Blocks and Containers --
|
| 62 |
+
block_background_fill="#1F2937", # Slate 800
|
| 63 |
+
block_border_width="1px",
|
| 64 |
+
block_border_color="#374151", # Slate 700
|
| 65 |
+
block_label_background_fill="#374151",
|
| 66 |
+
block_label_text_color="#E5E7EB",
|
| 67 |
+
block_title_text_color="#FFFFFF",
|
| 68 |
+
|
| 69 |
+
# -- Input Fields --
|
| 70 |
+
input_background_fill="#374151",
|
| 71 |
+
input_border_color="#4B5563",
|
| 72 |
+
input_placeholder_color="#9CA3AF",
|
| 73 |
+
|
| 74 |
+
# -- Spacing and Radius --
|
| 75 |
+
#block_radius_size="lg",
|
| 76 |
+
#spacing_size="lg",
|
| 77 |
+
#layout_gap="lg",
|
| 78 |
+
)
|
| 79 |
+
|
| 80 |
+
# --- 1. CONFIGURATION AND INITIALIZATION ---
|
| 81 |
+
LOG_FILE_PATH = "aduc_log.txt"
|
| 82 |
+
if os.path.exists(LOG_FILE_PATH):
|
| 83 |
+
os.remove(LOG_FILE_PATH)
|
| 84 |
+
|
| 85 |
+
log_format = '%(asctime)s - %(levelname)s - [%(name)s:%(funcName)s] - %(message)s'
|
| 86 |
+
root_logger = logging.getLogger()
|
| 87 |
+
root_logger.setLevel(logging.INFO)
|
| 88 |
+
root_logger.handlers.clear()
|
| 89 |
+
stream_handler = logging.StreamHandler(sys.stdout)
|
| 90 |
+
stream_handler.setLevel(logging.INFO)
|
| 91 |
+
stream_handler.setFormatter(logging.Formatter(log_format))
|
| 92 |
+
root_logger.addHandler(stream_handler)
|
| 93 |
+
file_handler = logging.FileHandler(LOG_FILE_PATH, mode='w', encoding='utf-8')
|
| 94 |
+
file_handler.setLevel(logging.INFO)
|
| 95 |
+
file_handler.setFormatter(logging.Formatter(log_format))
|
| 96 |
+
root_logger.addHandler(file_handler)
|
| 97 |
+
logger = logging.getLogger(__name__)
|
| 98 |
+
|
| 99 |
+
i18n = {}
|
| 100 |
+
try:
|
| 101 |
+
with open("i18n.json", "r", encoding="utf-8") as f: i18n = json.load(f)
|
| 102 |
+
except Exception as e:
|
| 103 |
+
logger.error(f"Error loading i18n.json: {e}")
|
| 104 |
+
i18n = {"pt": {}, "en": {}, "zh": {}}
|
| 105 |
+
if 'pt' not in i18n: i18n['pt'] = i18n.get('en', {})
|
| 106 |
+
if 'en' not in i18n: i18n['en'] = {}
|
| 107 |
+
if 'zh' not in i18n: i18n['zh'] = i18n.get('en', {})
|
| 108 |
+
|
| 109 |
+
try:
|
| 110 |
+
with open("config.yaml", 'r') as f: config = yaml.safe_load(f)
|
| 111 |
+
WORKSPACE_DIR = config['application']['workspace_dir']
|
| 112 |
+
aduc = AducOrchestrator(workspace_dir=WORKSPACE_DIR)
|
| 113 |
+
logger.info("ADUC Orchestrator and Specialists initialized successfully.")
|
| 114 |
+
except Exception as e:
|
| 115 |
+
logger.error(f"CRITICAL ERROR during initialization: {e}", exc_info=True)
|
| 116 |
+
exit()
|
| 117 |
+
|
| 118 |
+
# --- 2. UI WRAPPER FUNCTIONS ---
|
| 119 |
+
def run_pre_production_wrapper(prompt, num_keyframes, ref_files, resolution_str, duration_per_fragment, progress=gr.Progress()):
|
| 120 |
+
if not ref_files: raise gr.Error("Please provide at least one reference image.")
|
| 121 |
+
ref_paths = [aduc.process_image_for_story(f.name, 480, f"ref_processed_{i}.png") for i, f in enumerate(ref_files)]
|
| 122 |
+
progress(0.1, desc="Generating storyboard...")
|
| 123 |
+
storyboard, initial_ref_path, _ = aduc.task_generate_storyboard(prompt, num_keyframes, ref_paths, progress)
|
| 124 |
+
resolution = int(resolution_str.split('x')[0])
|
| 125 |
+
def cb_factory(scene_index, total_scenes):
|
| 126 |
+
start_time = time.time()
|
| 127 |
+
total_steps = 12
|
| 128 |
+
def callback(pipe_self, step, timestep, callback_kwargs):
|
| 129 |
+
elapsed, current_step = time.time() - start_time, step + 1
|
| 130 |
+
if current_step > 0:
|
| 131 |
+
it_per_sec = current_step / elapsed
|
| 132 |
+
eta = (total_steps - current_step) / it_per_sec if it_per_sec > 0 else 0
|
| 133 |
+
desc = f"Keyframe {scene_index}/{total_scenes}: {int((current_step/total_steps)*100)}% | {current_step}/{total_steps} [{elapsed:.0f}s<{eta:.0f}s, {it_per_sec:.2f}it/s]"
|
| 134 |
+
base_progress = 0.2 + (scene_index - 1) * (0.8 / total_scenes)
|
| 135 |
+
step_progress = (current_step / total_steps) * (0.8 / total_scenes)
|
| 136 |
+
progress(base_progress + step_progress, desc=desc)
|
| 137 |
+
return {}
|
| 138 |
+
return callback
|
| 139 |
+
final_keyframes = aduc.task_generate_keyframes(storyboard, initial_ref_path, prompt, resolution, cb_factory)
|
| 140 |
+
return gr.update(value=storyboard), gr.update(value=final_keyframes), gr.update(visible=True, open=True)
|
| 141 |
+
|
| 142 |
+
def run_pre_production_photo_wrapper(prompt, num_keyframes, ref_files, progress=gr.Progress()):
|
| 143 |
+
if not ref_files or len(ref_files) < 2: raise gr.Error("Photographer Mode requires at least 2 images: one base and one for the scene pool.")
|
| 144 |
+
base_ref_paths = [aduc.process_image_for_story(ref_files[0].name, 480, "base_ref_processed_0.png")]
|
| 145 |
+
pool_ref_paths = [aduc.process_image_for_story(f.name, 480, f"pool_ref_{i+1}.png") for i, f in enumerate(ref_files[1:])]
|
| 146 |
+
progress(0.1, desc="Generating storyboard...")
|
| 147 |
+
storyboard, _, _ = aduc.task_generate_storyboard(prompt, num_keyframes, base_ref_paths, progress)
|
| 148 |
+
progress(0.5, desc="AI Photographer is selecting the best scenes...")
|
| 149 |
+
selected_keyframes = aduc.task_select_keyframes(storyboard, base_ref_paths, pool_ref_paths)
|
| 150 |
+
return gr.update(value=storyboard), gr.update(value=selected_keyframes), gr.update(visible=True, open=True)
|
| 151 |
+
|
| 152 |
+
def run_original_production_wrapper(keyframes, prompt, duration, trim_percent, handler_strength, dest_strength, guidance_scale, stg_scale, steps, resolution, progress=gr.Progress()):
|
| 153 |
+
yield {original_video_output: gr.update(value=None, visible=True, label="🎬 Producing your original master video... Please wait."), final_video_output: gr.update(value=None, visible=True, label="🎬 Production in progress..."), step4_accordion: gr.update(visible=False)}
|
| 154 |
+
res = int(resolution.split('x')[0])
|
| 155 |
+
result = aduc.task_produce_original_movie(keyframes, prompt, duration, int(trim_percent), handler_strength, dest_strength, guidance_scale, stg_scale, int(steps), res, use_continuity_director=True, progress=progress)
|
| 156 |
+
yield {original_video_output: gr.update(value=result["final_path"], label="✅ Original Master Video"), final_video_output: gr.update(value=result["final_path"], label="Final Film (Result of the Last Step)"), step4_accordion: gr.update(visible=True, open=True), original_latents_paths_state: result["latent_paths"], original_video_path_state: result["final_path"], current_source_video_state: result["final_path"]}
|
| 157 |
+
|
| 158 |
+
def run_upscaler_wrapper(latent_paths, chunk_size, progress=gr.Progress()):
|
| 159 |
+
if not latent_paths: raise gr.Error("Cannot run Upscaler. No original latents found. Please complete Step 3 first.")
|
| 160 |
+
yield {upscaler_video_output: gr.update(value=None, visible=True, label="Upscaling latents and decoding video..."), final_video_output: gr.update(label="Post-Production in progress: Latent Upscaling...")}
|
| 161 |
+
final_path = None
|
| 162 |
+
for update in aduc.task_run_latent_upscaler(latent_paths, int(chunk_size), progress=progress): final_path = update['final_path']
|
| 163 |
+
yield {upscaler_video_output: gr.update(value=final_path, label="✅ Latent Upscale Complete"), final_video_output: gr.update(value=final_path), upscaled_video_path_state: final_path, current_source_video_state: final_path}
|
| 164 |
+
|
| 165 |
+
def run_hd_wrapper(source_video, model_version, steps, global_prompt, progress=gr.Progress()):
|
| 166 |
+
if not source_video: raise gr.Error("Cannot run HD Mastering. No source video found. Please complete a previous step first.")
|
| 167 |
+
yield {hd_video_output: gr.update(value=None, visible=True, label="Applying HD mastering... This may take a while."), final_video_output: gr.update(label="Post-Production in progress: HD Mastering...")}
|
| 168 |
+
final_path = None
|
| 169 |
+
for update in aduc.task_run_hd_mastering(source_video, model_version, int(steps), global_prompt, progress=progress): final_path = update['final_path']
|
| 170 |
+
yield {hd_video_output: gr.update(value=final_path, label="✅ HD Mastering Complete"), final_video_output: gr.update(value=final_path), hd_video_path_state: final_path, current_source_video_state: final_path}
|
| 171 |
+
|
| 172 |
+
def run_audio_wrapper(source_video, audio_prompt, global_prompt, progress=gr.Progress()):
|
| 173 |
+
if not source_video: raise gr.Error("Cannot run Audio Generation. No source video found. Please complete a previous step first.")
|
| 174 |
+
yield {audio_video_output: gr.update(value=None, visible=True, label="Generating audio and muxing..."), final_video_output: gr.update(label="Post-Production in progress: Audio Generation...")}
|
| 175 |
+
final_audio_prompt = audio_prompt if audio_prompt and audio_prompt.strip() else global_prompt
|
| 176 |
+
final_path = None
|
| 177 |
+
for update in aduc.task_run_audio_generation(source_video, final_audio_prompt, progress=progress): final_path = update['final_path']
|
| 178 |
+
yield {audio_video_output: gr.update(value=final_path, label="✅ Audio Generation Complete"), final_video_output: gr.update(value=final_path)}
|
| 179 |
+
|
| 180 |
+
def get_log_content():
|
| 181 |
+
try:
|
| 182 |
+
with open(LOG_FILE_PATH, "r", encoding="utf-8") as f: return f.read()
|
| 183 |
+
except FileNotFoundError:
|
| 184 |
+
return "Log file not yet created. Start a generation."
|
| 185 |
+
|
| 186 |
+
def update_ui_language(lang_emoji):
|
| 187 |
+
lang_code_map = {"🇧🇷": "pt", "🇺🇸": "en", "🇨🇳": "zh"}
|
| 188 |
+
lang_code = lang_code_map.get(lang_emoji, "en")
|
| 189 |
+
lang_map = i18n.get(lang_code, i18n.get('en', {}))
|
| 190 |
+
# ... This dictionary mapping will be long, so it's defined once in the main block
|
| 191 |
+
|
| 192 |
+
# --- 3. GRADIO UI DEFINITION ---
|
| 193 |
+
with gr.Blocks(theme=cinematic_theme, css="style.css") as demo:
|
| 194 |
+
default_lang = i18n.get('pt', {})
|
| 195 |
+
|
| 196 |
+
original_latents_paths_state = gr.State(value=None)
|
| 197 |
+
original_video_path_state = gr.State(value=None)
|
| 198 |
+
upscaled_video_path_state = gr.State(value=None)
|
| 199 |
+
hd_video_path_state = gr.State(value=None)
|
| 200 |
+
current_source_video_state = gr.State(value=None)
|
| 201 |
+
|
| 202 |
+
title_md = gr.Markdown(f"<h1>{default_lang.get('app_title')}</h1>")
|
| 203 |
+
subtitle_md = gr.Markdown(f"<p>{default_lang.get('app_subtitle')}</p>")
|
| 204 |
+
with gr.Row():
|
| 205 |
+
lang_selector = gr.Radio(["🇧🇷", "🇺🇸", "🇨🇳"], value="🇧🇷", label=default_lang.get('lang_selector_label'))
|
| 206 |
+
resolution_selector = gr.Radio(["480x480", "720x720", "960x960"], value="480x480", label="Base Resolution")
|
| 207 |
+
|
| 208 |
+
with gr.Accordion(default_lang.get('step1_accordion'), open=True) as step1_accordion:
|
| 209 |
+
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.")
|
| 210 |
+
ref_image_input = gr.File(label=default_lang.get('ref_images_label'), file_count="multiple", file_types=["image"])
|
| 211 |
+
with gr.Row():
|
| 212 |
+
num_keyframes_slider = gr.Slider(minimum=3, maximum=42, value=5, step=1, label=default_lang.get('keyframes_label'))
|
| 213 |
+
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)
|
| 214 |
+
with gr.Row():
|
| 215 |
+
storyboard_and_keyframes_button = gr.Button(default_lang.get('storyboard_and_keyframes_button'), variant="primary")
|
| 216 |
+
storyboard_from_photos_button = gr.Button(default_lang.get('storyboard_from_photos_button'), variant="secondary")
|
| 217 |
+
step1_mode_b_info_md = gr.Markdown(f"*{default_lang.get('step1_mode_b_info')}*")
|
| 218 |
+
storyboard_output = gr.JSON(label=default_lang.get('storyboard_output_label'))
|
| 219 |
+
keyframe_gallery = gr.Gallery(label=default_lang.get('keyframes_gallery_label'), visible=True, object_fit="contain", height="auto", type="filepath")
|
| 220 |
+
|
| 221 |
+
with gr.Accordion(default_lang.get('step3_accordion'), open=False, visible=False) as step3_accordion:
|
| 222 |
+
step3_description_md = gr.Markdown(default_lang.get('step3_description'))
|
| 223 |
+
with gr.Accordion(default_lang.get('ltx_advanced_options'), open=False) as ltx_advanced_options_accordion:
|
| 224 |
+
with gr.Accordion(default_lang.get('causality_controls_title'), open=True) as causality_accordion:
|
| 225 |
+
trim_percent_slider = gr.Slider(minimum=10, maximum=90, value=50, step=5, label=default_lang.get('trim_percent_label'), info=default_lang.get('trim_percent_info'))
|
| 226 |
+
with gr.Row():
|
| 227 |
+
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'))
|
| 228 |
+
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'))
|
| 229 |
+
with gr.Accordion(default_lang.get('ltx_pipeline_options'), open=True) as ltx_pipeline_accordion:
|
| 230 |
+
with gr.Row():
|
| 231 |
+
guidance_scale_slider = gr.Slider(minimum=1.0, maximum=10.0, value=2.0, step=0.1, label=default_lang.get('guidance_scale_label'), info=default_lang.get('guidance_scale_info'))
|
| 232 |
+
stg_scale_slider = gr.Slider(minimum=0.0, maximum=1.0, value=0.025, step=0.005, label=default_lang.get('stg_scale_label'), info=default_lang.get('stg_scale_info'))
|
| 233 |
+
inference_steps_slider = gr.Slider(minimum=10, maximum=50, value=20, step=1, label=default_lang.get('steps_label'), info=default_lang.get('steps_info'))
|
| 234 |
+
produce_original_button = gr.Button(default_lang.get('produce_original_button'), variant="primary")
|
| 235 |
+
original_video_output = gr.Video(label="Original Master Video", visible=False, interactive=False)
|
| 236 |
+
|
| 237 |
+
with gr.Accordion(default_lang.get('step4_accordion'), open=False, visible=False) as step4_accordion:
|
| 238 |
+
step4_description_md = gr.Markdown(default_lang.get('step4_description'))
|
| 239 |
+
with gr.Accordion(default_lang.get('sub_step_a_upscaler'), open=True) as sub_step_a_accordion:
|
| 240 |
+
upscaler_description_md = gr.Markdown(default_lang.get('upscaler_description'))
|
| 241 |
+
with gr.Accordion(default_lang.get('upscaler_options'), open=False) as upscaler_options_accordion:
|
| 242 |
+
upscaler_chunk_size_slider = gr.Slider(minimum=1, maximum=10, value=2, step=1, label=default_lang.get('upscaler_chunk_size_label'), info=default_lang.get('upscaler_chunk_size_info'))
|
| 243 |
+
run_upscaler_button = gr.Button(default_lang.get('run_upscaler_button'), variant="secondary")
|
| 244 |
+
upscaler_video_output = gr.Video(label="Upscaled Video", visible=False, interactive=False)
|
| 245 |
+
with gr.Accordion(default_lang.get('sub_step_b_hd'), open=True) as sub_step_b_accordion:
|
| 246 |
+
hd_description_md = gr.Markdown(default_lang.get('hd_description'))
|
| 247 |
+
with gr.Accordion(default_lang.get('hd_options'), open=False) as hd_options_accordion:
|
| 248 |
+
hd_model_radio = gr.Radio(["3B", "7B"], value="7B", label=default_lang.get('hd_model_label'))
|
| 249 |
+
hd_steps_slider = gr.Slider(minimum=20, maximum=150, value=100, step=5, label=default_lang.get('hd_steps_label'), info=default_lang.get('hd_steps_info'))
|
| 250 |
+
run_hd_button = gr.Button(default_lang.get('run_hd_button'), variant="secondary")
|
| 251 |
+
hd_video_output = gr.Video(label="HD Mastered Video", visible=False, interactive=False)
|
| 252 |
+
with gr.Accordion(default_lang.get('sub_step_c_audio'), open=True) as sub_step_c_accordion:
|
| 253 |
+
audio_description_md = gr.Markdown(default_lang.get('audio_description'))
|
| 254 |
+
with gr.Accordion(default_lang.get('audio_options'), open=False) as audio_options_accordion:
|
| 255 |
+
audio_prompt_input = gr.Textbox(label=default_lang.get('audio_prompt_label'), info=default_lang.get('audio_prompt_info'), lines=3)
|
| 256 |
+
run_audio_button = gr.Button(default_lang.get('run_audio_button'), variant="secondary")
|
| 257 |
+
audio_video_output = gr.Video(label="Video with Audio", visible=False, interactive=False)
|
| 258 |
+
|
| 259 |
+
final_video_output = gr.Video(label=default_lang.get('final_video_label'), visible=False, interactive=False)
|
| 260 |
+
with gr.Accordion(default_lang.get('log_accordion_label'), open=False) as log_accordion:
|
| 261 |
+
log_display = gr.Textbox(label=default_lang.get('log_display_label'), lines=20, interactive=False, autoscroll=True)
|
| 262 |
+
update_log_button = gr.Button(default_lang.get('update_log_button'))
|
| 263 |
+
|
| 264 |
+
# --- 4. UI EVENT CONNECTIONS ---
|
| 265 |
+
all_ui_components = [title_md, subtitle_md, lang_selector, step1_accordion, prompt_input, ref_image_input, num_keyframes_slider, duration_per_fragment_slider, storyboard_and_keyframes_button, storyboard_from_photos_button, step1_mode_b_info_md, storyboard_output, keyframe_gallery, step3_accordion, step3_description_md, produce_original_button, ltx_advanced_options_accordion, causality_accordion, trim_percent_slider, forca_guia_slider, convergencia_destino_slider, ltx_pipeline_accordion, guidance_scale_slider, stg_scale_slider, inference_steps_slider, step4_accordion, step4_description_md, sub_step_a_accordion, upscaler_description_md, upscaler_options_accordion, upscaler_chunk_size_slider, run_upscaler_button, sub_step_b_accordion, hd_description_md, hd_options_accordion, hd_model_radio, hd_steps_slider, run_hd_button, sub_step_c_accordion, audio_description_md, audio_options_accordion, audio_prompt_input, run_audio_button, final_video_output, log_accordion, log_display, update_log_button]
|
| 266 |
+
def create_lang_update_fn():
|
| 267 |
+
def update_lang(lang_emoji):
|
| 268 |
+
lang_code_map = {"🇧🇷": "pt", "🇺🇸": "en", "🇨🇳": "zh"}
|
| 269 |
+
lang_code = lang_code_map.get(lang_emoji, "en")
|
| 270 |
+
lang_map = i18n.get(lang_code, i18n.get('en', {}))
|
| 271 |
+
return [gr.update(value=f"<h1>{lang_map.get('app_title')}</h1>"),gr.update(value=f"<p>{lang_map.get('app_subtitle')}</p>"),gr.update(label=lang_map.get('lang_selector_label')),gr.update(label=lang_map.get('step1_accordion')),gr.update(label=lang_map.get('prompt_label')),gr.update(label=lang_map.get('ref_images_label')),gr.update(label=lang_map.get('keyframes_label')),gr.update(label=lang_map.get('duration_label'), info=lang_map.get('duration_info')),gr.update(value=lang_map.get('storyboard_and_keyframes_button')),gr.update(value=lang_map.get('storyboard_from_photos_button')),gr.update(value=f"*{lang_map.get('step1_mode_b_info')}*"),gr.update(label=lang_map.get('storyboard_output_label')),gr.update(label=lang_map.get('keyframes_gallery_label')),gr.update(label=lang_map.get('step3_accordion')),gr.update(value=lang_map.get('step3_description')),gr.update(value=lang_map.get('produce_original_button')),gr.update(label=lang_map.get('ltx_advanced_options')),gr.update(label=lang_map.get('causality_controls_title')),gr.update(label=lang_map.get('trim_percent_label'), info=lang_map.get('trim_percent_info')),gr.update(label=lang_map.get('forca_guia_label'), info=lang_map.get('forca_guia_info')),gr.update(label=lang_map.get('convergencia_final_label'), info=lang_map.get('convergencia_final_info')),gr.update(label=lang_map.get('ltx_pipeline_options')),gr.update(label=lang_map.get('guidance_scale_label'), info=lang_map.get('guidance_scale_info')),gr.update(label=lang_map.get('stg_scale_label'), info=lang_map.get('stg_scale_info')),gr.update(label=lang_map.get('steps_label'), info=lang_map.get('steps_info')),gr.update(label=lang_map.get('step4_accordion')),gr.update(value=lang_map.get('step4_description')),gr.update(label=lang_map.get('sub_step_a_upscaler')),gr.update(value=lang_map.get('upscaler_description')),gr.update(label=lang_map.get('upscaler_options')),gr.update(label=lang_map.get('upscaler_chunk_size_label'), info=lang_map.get('upscaler_chunk_size_info')),gr.update(value=lang_map.get('run_upscaler_button')),gr.update(label=lang_map.get('sub_step_b_hd')),gr.update(value=lang_map.get('hd_description')),gr.update(label=lang_map.get('hd_options')),gr.update(label=lang_map.get('hd_model_label')),gr.update(label=lang_map.get('hd_steps_label'), info=lang_map.get('hd_steps_info')),gr.update(value=lang_map.get('run_hd_button')),gr.update(label=lang_map.get('sub_step_c_audio')),gr.update(value=lang_map.get('audio_description')),gr.update(label=lang_map.get('audio_options')),gr.update(label=lang_map.get('audio_prompt_label'), info=lang_map.get('audio_prompt_info')),gr.update(value=lang_map.get('run_audio_button')),gr.update(label=lang_map.get('final_video_label')),gr.update(label=lang_map.get('log_accordion_label')),gr.update(label=lang_map.get('log_display_label')),gr.update(value=lang_map.get('update_log_button'))]
|
| 272 |
+
return update_lang
|
| 273 |
+
lang_selector.change(fn=create_lang_update_fn(), inputs=lang_selector, outputs=all_ui_components)
|
| 274 |
+
|
| 275 |
+
storyboard_and_keyframes_button.click(fn=run_pre_production_wrapper, inputs=[prompt_input, num_keyframes_slider, ref_image_input, resolution_selector, duration_per_fragment_slider], outputs=[storyboard_output, keyframe_gallery, step3_accordion])
|
| 276 |
+
storyboard_from_photos_button.click(fn=run_pre_production_photo_wrapper, inputs=[prompt_input, num_keyframes_slider, ref_image_input], outputs=[storyboard_output, keyframe_gallery, step3_accordion])
|
| 277 |
+
produce_original_button.click(fn=run_original_production_wrapper, inputs=[keyframe_gallery, prompt_input, duration_per_fragment_slider, trim_percent_slider, forca_guia_slider, convergencia_destino_slider, guidance_scale_slider, stg_scale_slider, inference_steps_slider, resolution_selector], outputs=[original_video_output, final_video_output, step4_accordion, original_latents_paths_state, original_video_path_state, current_source_video_state])
|
| 278 |
+
run_upscaler_button.click(fn=run_upscaler_wrapper, inputs=[original_latents_paths_state, upscaler_chunk_size_slider], outputs=[upscaler_video_output, final_video_output, upscaled_video_path_state, current_source_video_state])
|
| 279 |
+
run_hd_button.click(fn=run_hd_wrapper, inputs=[current_source_video_state, hd_model_radio, hd_steps_slider, prompt_input], outputs=[hd_video_output, final_video_output, hd_video_path_state, current_source_video_state])
|
| 280 |
+
run_audio_button.click(fn=run_audio_wrapper, inputs=[current_source_video_state, audio_prompt_input, prompt_input], outputs=[audio_video_output, final_video_output])
|
| 281 |
+
update_log_button.click(fn=get_log_content, inputs=[], outputs=[log_display])
|
| 282 |
+
|
| 283 |
+
# --- 5. APPLICATION LAUNCH ---
|
| 284 |
+
if __name__ == "__main__":
|
| 285 |
+
if os.path.exists(WORKSPACE_DIR):
|
| 286 |
+
logger.info(f"Clearing previous workspace at: {WORKSPACE_DIR}")
|
| 287 |
+
shutil.rmtree(WORKSPACE_DIR)
|
| 288 |
+
os.makedirs(WORKSPACE_DIR)
|
| 289 |
+
logger.info(f"Application started. Launching Gradio interface...")
|
| 290 |
+
demo.queue().launch()
|