Update app.py
Browse files
app.py
CHANGED
|
@@ -345,24 +345,24 @@ class ImageStoryteller:
|
|
| 345 |
return story, detected_objects, scene_type
|
| 346 |
|
| 347 |
def create_story_overlay(self, image, story):
|
| 348 |
-
|
| 349 |
-
|
| 350 |
-
|
| 351 |
-
|
| 352 |
-
|
| 353 |
-
|
| 354 |
-
|
| 355 |
-
|
| 356 |
-
|
| 357 |
-
|
| 358 |
-
|
| 359 |
-
|
| 360 |
-
|
| 361 |
-
|
| 362 |
-
|
| 363 |
-
|
| 364 |
-
|
| 365 |
-
|
| 366 |
|
| 367 |
# FIXED: Added the missing method
|
| 368 |
# def create_story_overlay(self, image, story):
|
|
|
|
| 345 |
return story, detected_objects, scene_type
|
| 346 |
|
| 347 |
def create_story_overlay(self, image, story):
|
| 348 |
+
"""Create formatted text with caption and story for textbox display"""
|
| 349 |
+
|
| 350 |
+
# Generate caption (first sentence of the story)
|
| 351 |
+
caption = ""
|
| 352 |
+
sentences = story.split('. ')
|
| 353 |
+
if sentences:
|
| 354 |
+
caption = sentences[0].strip()
|
| 355 |
+
if not caption.endswith('.'):
|
| 356 |
+
caption += '.'
|
| 357 |
+
|
| 358 |
+
# Format the text with caption separated from story
|
| 359 |
+
# Using a separator line of dashes
|
| 360 |
+
separator = "─" * 40
|
| 361 |
+
|
| 362 |
+
# Format the complete text for the textbox
|
| 363 |
+
formatted_text = f"{caption}\n{separator}\n{story}"
|
| 364 |
+
|
| 365 |
+
return formatted_text
|
| 366 |
|
| 367 |
# FIXED: Added the missing method
|
| 368 |
# def create_story_overlay(self, image, story):
|