Rathapoom commited on
Commit
9fb9d85
·
verified ·
1 Parent(s): 0968259

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +6 -4
app.py CHANGED
@@ -1828,9 +1828,9 @@ def stitch_story(raw_story: List[dict], theme_id: str, level: str) -> Dict[str,
1828
  def generate_story_illustration(story_summary: str) -> str:
1829
  """Generate illustration for the story using DALL-E 3"""
1830
  try:
1831
- # Prepare the prompt for DALL-E
1832
  illustration_prompt = f"""
1833
- Create a children's book illustration for this story:
1834
  {story_summary}
1835
 
1836
  Style requirements:
@@ -1839,7 +1839,8 @@ def generate_story_illustration(story_summary: str) -> str:
1839
  - Storybook art style
1840
  - Clear and simple composition
1841
  - Safe for children
1842
- - No text in the image
 
1843
  """
1844
 
1845
  # Generate image
@@ -1848,7 +1849,7 @@ def generate_story_illustration(story_summary: str) -> str:
1848
  prompt=illustration_prompt,
1849
  size="1024x1024",
1850
  quality="standard",
1851
- n=1,
1852
  )
1853
 
1854
  image_url = response.data[0].url
@@ -1859,6 +1860,7 @@ def generate_story_illustration(story_summary: str) -> str:
1859
  logging.error(f"Error generating story illustration: {str(e)}")
1860
  return None
1861
 
 
1862
  def show_stitched_story(story_data: Dict[str, str]):
1863
  """Display the stitched story with translation and illustration"""
1864
  try:
 
1828
  def generate_story_illustration(story_summary: str) -> str:
1829
  """Generate illustration for the story using DALL-E 3"""
1830
  try:
1831
+ # Refined prompt for DALL-E
1832
  illustration_prompt = f"""
1833
+ Create a single, cohesive children's book cover illustration for this story:
1834
  {story_summary}
1835
 
1836
  Style requirements:
 
1839
  - Storybook art style
1840
  - Clear and simple composition
1841
  - Safe for children
1842
+ - Focus on a single, unified scene
1843
+ - No text or sub-scenes in the image
1844
  """
1845
 
1846
  # Generate image
 
1849
  prompt=illustration_prompt,
1850
  size="1024x1024",
1851
  quality="standard",
1852
+ n=1, # Ensures only one image is generated
1853
  )
1854
 
1855
  image_url = response.data[0].url
 
1860
  logging.error(f"Error generating story illustration: {str(e)}")
1861
  return None
1862
 
1863
+
1864
  def show_stitched_story(story_data: Dict[str, str]):
1865
  """Display the stitched story with translation and illustration"""
1866
  try: