Spaces:
Running
Running
Update app.py
Browse files
app.py
CHANGED
|
@@ -50,6 +50,7 @@ class ProfessionalCartoonFilmGenerator:
|
|
| 50 |
self.script_model = None
|
| 51 |
self.script_tokenizer = None
|
| 52 |
|
|
|
|
| 53 |
def load_models(self):
|
| 54 |
"""Load ZeroGPU-compatible models for professional generation"""
|
| 55 |
try:
|
|
@@ -393,6 +394,7 @@ class ProfessionalCartoonFilmGenerator:
|
|
| 393 |
}
|
| 394 |
return palettes.get(mood, "balanced warm and cool tones")
|
| 395 |
|
|
|
|
| 396 |
def generate_professional_character_images(self, characters: List[Dict]) -> Dict[str, str]:
|
| 397 |
"""Generate professional character images with consistency (ZeroGPU compatible)"""
|
| 398 |
character_images = {}
|
|
@@ -472,6 +474,7 @@ class ProfessionalCartoonFilmGenerator:
|
|
| 472 |
|
| 473 |
return character_images
|
| 474 |
|
|
|
|
| 475 |
def generate_cinematic_backgrounds(self, scenes: List[Dict], color_palette: str) -> Dict[int, str]:
|
| 476 |
"""Generate professional cinematic backgrounds for each scene (ZeroGPU compatible)"""
|
| 477 |
background_images = {}
|
|
@@ -671,6 +674,7 @@ class ProfessionalCartoonFilmGenerator:
|
|
| 671 |
traceback.print_exc()
|
| 672 |
return False
|
| 673 |
|
|
|
|
| 674 |
def generate_professional_videos(self, scenes: List[Dict], character_images: Dict, background_images: Dict) -> List[str]:
|
| 675 |
"""Generate professional videos using Open-Sora 2.0"""
|
| 676 |
scene_videos = []
|
|
@@ -725,7 +729,7 @@ class ProfessionalCartoonFilmGenerator:
|
|
| 725 |
print(f"β Error in scene {scene_num}: {e}")
|
| 726 |
# Create fallback video
|
| 727 |
if scene_num in background_images:
|
| 728 |
-
print(f"
|
| 729 |
try:
|
| 730 |
video_path = self._create_professional_static_video(scene, background_images)
|
| 731 |
if video_path and os.path.exists(video_path):
|
|
@@ -1125,6 +1129,7 @@ class ProfessionalCartoonFilmGenerator:
|
|
| 1125 |
print(f"β Video merging failed: {e}")
|
| 1126 |
return None
|
| 1127 |
|
|
|
|
| 1128 |
def generate_professional_cartoon_film(self, script: str) -> tuple:
|
| 1129 |
"""Main function to generate professional-quality cartoon film (ZeroGPU compatible)"""
|
| 1130 |
try:
|
|
@@ -1400,6 +1405,7 @@ class ProfessionalCartoonFilmGenerator:
|
|
| 1400 |
# Initialize professional generator
|
| 1401 |
generator = ProfessionalCartoonFilmGenerator()
|
| 1402 |
|
|
|
|
| 1403 |
def create_professional_cartoon_film(script):
|
| 1404 |
"""Gradio interface function for professional generation (ZeroGPU compatible)"""
|
| 1405 |
if not script.strip():
|
|
|
|
| 50 |
self.script_model = None
|
| 51 |
self.script_tokenizer = None
|
| 52 |
|
| 53 |
+
@spaces.GPU
|
| 54 |
def load_models(self):
|
| 55 |
"""Load ZeroGPU-compatible models for professional generation"""
|
| 56 |
try:
|
|
|
|
| 394 |
}
|
| 395 |
return palettes.get(mood, "balanced warm and cool tones")
|
| 396 |
|
| 397 |
+
@spaces.GPU
|
| 398 |
def generate_professional_character_images(self, characters: List[Dict]) -> Dict[str, str]:
|
| 399 |
"""Generate professional character images with consistency (ZeroGPU compatible)"""
|
| 400 |
character_images = {}
|
|
|
|
| 474 |
|
| 475 |
return character_images
|
| 476 |
|
| 477 |
+
@spaces.GPU
|
| 478 |
def generate_cinematic_backgrounds(self, scenes: List[Dict], color_palette: str) -> Dict[int, str]:
|
| 479 |
"""Generate professional cinematic backgrounds for each scene (ZeroGPU compatible)"""
|
| 480 |
background_images = {}
|
|
|
|
| 674 |
traceback.print_exc()
|
| 675 |
return False
|
| 676 |
|
| 677 |
+
@spaces.GPU
|
| 678 |
def generate_professional_videos(self, scenes: List[Dict], character_images: Dict, background_images: Dict) -> List[str]:
|
| 679 |
"""Generate professional videos using Open-Sora 2.0"""
|
| 680 |
scene_videos = []
|
|
|
|
| 729 |
print(f"β Error in scene {scene_num}: {e}")
|
| 730 |
# Create fallback video
|
| 731 |
if scene_num in background_images:
|
| 732 |
+
print(f"π Creating emergency fallback for scene {scene_num}...")
|
| 733 |
try:
|
| 734 |
video_path = self._create_professional_static_video(scene, background_images)
|
| 735 |
if video_path and os.path.exists(video_path):
|
|
|
|
| 1129 |
print(f"β Video merging failed: {e}")
|
| 1130 |
return None
|
| 1131 |
|
| 1132 |
+
@spaces.GPU
|
| 1133 |
def generate_professional_cartoon_film(self, script: str) -> tuple:
|
| 1134 |
"""Main function to generate professional-quality cartoon film (ZeroGPU compatible)"""
|
| 1135 |
try:
|
|
|
|
| 1405 |
# Initialize professional generator
|
| 1406 |
generator = ProfessionalCartoonFilmGenerator()
|
| 1407 |
|
| 1408 |
+
@spaces.GPU
|
| 1409 |
def create_professional_cartoon_film(script):
|
| 1410 |
"""Gradio interface function for professional generation (ZeroGPU compatible)"""
|
| 1411 |
if not script.strip():
|