First
Browse files- ui/story_interface.py +20 -18
ui/story_interface.py
CHANGED
|
@@ -3,6 +3,7 @@ import time
|
|
| 3 |
from utils.story_management import (
|
| 4 |
generate_direct_comic,
|
| 5 |
extract_comic_scenes,
|
|
|
|
| 6 |
)
|
| 7 |
from config import IMAGE_STYLES, IMAGE_STYLE_INFO, AGE_GROUPS
|
| 8 |
from datetime import datetime
|
|
@@ -17,6 +18,7 @@ def log_execution(func):
|
|
| 17 |
end_time = time.time()
|
| 18 |
end_str = datetime.fromtimestamp(end_time).strftime('%Y-%m-%d %H:%M:%S')
|
| 19 |
duration = end_time - start_time
|
|
|
|
| 20 |
|
| 21 |
return result
|
| 22 |
return wrapper
|
|
@@ -144,24 +146,24 @@ def create_quick_comic_tab() -> None:
|
|
| 144 |
"""Display a loading message while story scenes are being generated."""
|
| 145 |
return "🔄 Generating your story scenes... Please wait..."
|
| 146 |
|
| 147 |
-
|
| 148 |
-
|
| 149 |
-
|
| 150 |
-
|
| 151 |
-
|
| 152 |
-
|
| 153 |
-
|
| 154 |
-
|
| 155 |
-
|
| 156 |
-
|
| 157 |
-
|
| 158 |
-
|
| 159 |
-
|
| 160 |
-
|
| 161 |
-
|
| 162 |
-
|
| 163 |
-
|
| 164 |
-
|
| 165 |
|
| 166 |
def init_scene_viewer(comic_path: str | None) -> tuple:
|
| 167 |
"""Initialize the scene viewer with extracted scenes from the comic image."""
|
|
|
|
| 3 |
from utils.story_management import (
|
| 4 |
generate_direct_comic,
|
| 5 |
extract_comic_scenes,
|
| 6 |
+
load_narration_from_file
|
| 7 |
)
|
| 8 |
from config import IMAGE_STYLES, IMAGE_STYLE_INFO, AGE_GROUPS
|
| 9 |
from datetime import datetime
|
|
|
|
| 18 |
end_time = time.time()
|
| 19 |
end_str = datetime.fromtimestamp(end_time).strftime('%Y-%m-%d %H:%M:%S')
|
| 20 |
duration = end_time - start_time
|
| 21 |
+
|
| 22 |
|
| 23 |
return result
|
| 24 |
return wrapper
|
|
|
|
| 146 |
"""Display a loading message while story scenes are being generated."""
|
| 147 |
return "🔄 Generating your story scenes... Please wait..."
|
| 148 |
|
| 149 |
+
def generate_comic_with_length(user_prompt, comic_style, enrich_prompt, age_group, image_quality):
|
| 150 |
+
"""Wrapper that handles the fixed num_scenes value while passing the age group and image quality."""
|
| 151 |
+
comic_image, save_path_display, status_display, narration = generate_direct_comic(
|
| 152 |
+
user_prompt,
|
| 153 |
+
comic_style,
|
| 154 |
+
12,
|
| 155 |
+
enrich_prompt,
|
| 156 |
+
3,
|
| 157 |
+
age_group,
|
| 158 |
+
)
|
| 159 |
+
|
| 160 |
+
if narration and narration.strip():
|
| 161 |
+
narration_formatted = f""
|
| 162 |
+
narration_update = gr.update(visible=True, value=narration_formatted)
|
| 163 |
+
else:
|
| 164 |
+
narration_update = gr.update(visible=True, value="")
|
| 165 |
+
|
| 166 |
+
return comic_image, save_path_display, status_display, narration_update
|
| 167 |
|
| 168 |
def init_scene_viewer(comic_path: str | None) -> tuple:
|
| 169 |
"""Initialize the scene viewer with extracted scenes from the comic image."""
|