Spaces:
Running
Running
Update app.py
Browse files
app.py
CHANGED
|
@@ -1178,10 +1178,15 @@ class ProfessionalCartoonFilmGenerator:
|
|
| 1178 |
download_info = self.create_download_url(final_video, "final_cartoon_film")
|
| 1179 |
print(f"β
Professional cartoon film generation complete!")
|
| 1180 |
print(download_info)
|
| 1181 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1182 |
else:
|
| 1183 |
print("β οΈ Video merging failed")
|
| 1184 |
-
return None, script_data, "β οΈ Video merging failed"
|
| 1185 |
else:
|
| 1186 |
print("β No videos to merge - video generation failed")
|
| 1187 |
print("π Creating emergency fallback video...")
|
|
@@ -1196,12 +1201,12 @@ class ProfessionalCartoonFilmGenerator:
|
|
| 1196 |
download_info = self.create_download_url(emergency_video, "emergency_fallback_video")
|
| 1197 |
print(f"β
Emergency fallback video created")
|
| 1198 |
print(download_info)
|
| 1199 |
-
return emergency_video, script_data, f"β οΈ Emergency fallback video created ({file_size:.1f} MB)"
|
| 1200 |
else:
|
| 1201 |
-
return None, script_data, "β No videos generated - all methods failed"
|
| 1202 |
except Exception as e:
|
| 1203 |
print(f"β Emergency fallback also failed: {e}")
|
| 1204 |
-
return None, script_data, "β No videos generated - all methods failed"
|
| 1205 |
|
| 1206 |
except Exception as e:
|
| 1207 |
print(f"β Generation failed: {e}")
|
|
@@ -1214,7 +1219,7 @@ class ProfessionalCartoonFilmGenerator:
|
|
| 1214 |
"scenes": [],
|
| 1215 |
"style": "Error occurred during generation"
|
| 1216 |
}
|
| 1217 |
-
return None, error_info, f"β Generation failed: {str(e)}"
|
| 1218 |
|
| 1219 |
# Initialize professional generator
|
| 1220 |
generator = ProfessionalCartoonFilmGenerator()
|
|
@@ -1230,7 +1235,7 @@ def create_professional_cartoon_film(script):
|
|
| 1230 |
"scenes": [],
|
| 1231 |
"style": "Please enter a script"
|
| 1232 |
}
|
| 1233 |
-
return None, empty_response, "β Please enter a script"
|
| 1234 |
|
| 1235 |
return generator.generate_professional_cartoon_film(script)
|
| 1236 |
|
|
@@ -1321,6 +1326,21 @@ The more details you provide about characters, setting, and emotion, the better
|
|
| 1321 |
height=500
|
| 1322 |
)
|
| 1323 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1324 |
status_output = gr.Textbox(
|
| 1325 |
label="π Generation Status",
|
| 1326 |
lines=3
|
|
@@ -1335,7 +1355,7 @@ The more details you provide about characters, setting, and emotion, the better
|
|
| 1335 |
generate_btn.click(
|
| 1336 |
fn=create_professional_cartoon_film,
|
| 1337 |
inputs=[script_input],
|
| 1338 |
-
outputs=[video_output, script_details, status_output],
|
| 1339 |
show_progress=True
|
| 1340 |
)
|
| 1341 |
|
|
|
|
| 1178 |
download_info = self.create_download_url(final_video, "final_cartoon_film")
|
| 1179 |
print(f"β
Professional cartoon film generation complete!")
|
| 1180 |
print(download_info)
|
| 1181 |
+
|
| 1182 |
+
# Prepare character and background files for galleries
|
| 1183 |
+
char_files = list(character_images.values()) if character_images else []
|
| 1184 |
+
bg_files = list(background_images.values()) if background_images else []
|
| 1185 |
+
|
| 1186 |
+
return final_video, script_data, f"β
Professional cartoon film generated successfully! ({file_size:.1f} MB)", char_files, bg_files
|
| 1187 |
else:
|
| 1188 |
print("β οΈ Video merging failed")
|
| 1189 |
+
return None, script_data, "β οΈ Video merging failed", [], []
|
| 1190 |
else:
|
| 1191 |
print("β No videos to merge - video generation failed")
|
| 1192 |
print("π Creating emergency fallback video...")
|
|
|
|
| 1201 |
download_info = self.create_download_url(emergency_video, "emergency_fallback_video")
|
| 1202 |
print(f"β
Emergency fallback video created")
|
| 1203 |
print(download_info)
|
| 1204 |
+
return emergency_video, script_data, f"β οΈ Emergency fallback video created ({file_size:.1f} MB)", [], []
|
| 1205 |
else:
|
| 1206 |
+
return None, script_data, "β No videos generated - all methods failed", [], []
|
| 1207 |
except Exception as e:
|
| 1208 |
print(f"β Emergency fallback also failed: {e}")
|
| 1209 |
+
return None, script_data, "β No videos generated - all methods failed", [], []
|
| 1210 |
|
| 1211 |
except Exception as e:
|
| 1212 |
print(f"β Generation failed: {e}")
|
|
|
|
| 1219 |
"scenes": [],
|
| 1220 |
"style": "Error occurred during generation"
|
| 1221 |
}
|
| 1222 |
+
return None, error_info, f"β Generation failed: {str(e)}", [], []
|
| 1223 |
|
| 1224 |
# Initialize professional generator
|
| 1225 |
generator = ProfessionalCartoonFilmGenerator()
|
|
|
|
| 1235 |
"scenes": [],
|
| 1236 |
"style": "Please enter a script"
|
| 1237 |
}
|
| 1238 |
+
return None, empty_response, "β Please enter a script", [], []
|
| 1239 |
|
| 1240 |
return generator.generate_professional_cartoon_film(script)
|
| 1241 |
|
|
|
|
| 1326 |
height=500
|
| 1327 |
)
|
| 1328 |
|
| 1329 |
+
# Add file galleries for generated content
|
| 1330 |
+
with gr.Accordion("π Generated Files (Click to Download)", open=False):
|
| 1331 |
+
character_gallery = gr.Gallery(
|
| 1332 |
+
label="π Character Images",
|
| 1333 |
+
columns=2,
|
| 1334 |
+
height=200,
|
| 1335 |
+
allow_preview=True
|
| 1336 |
+
)
|
| 1337 |
+
background_gallery = gr.Gallery(
|
| 1338 |
+
label="ποΈ Background Images",
|
| 1339 |
+
columns=2,
|
| 1340 |
+
height=200,
|
| 1341 |
+
allow_preview=True
|
| 1342 |
+
)
|
| 1343 |
+
|
| 1344 |
status_output = gr.Textbox(
|
| 1345 |
label="π Generation Status",
|
| 1346 |
lines=3
|
|
|
|
| 1355 |
generate_btn.click(
|
| 1356 |
fn=create_professional_cartoon_film,
|
| 1357 |
inputs=[script_input],
|
| 1358 |
+
outputs=[video_output, script_details, status_output, character_gallery, background_gallery],
|
| 1359 |
show_progress=True
|
| 1360 |
)
|
| 1361 |
|