CR7CAD commited on
Commit
cf468d0
·
verified ·
1 Parent(s): 9ec76c6

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +3 -4
app.py CHANGED
@@ -1,4 +1,4 @@
1
- # Imports - just the essentials
2
  import streamlit as st
3
  from transformers import pipeline
4
  from PIL import Image
@@ -50,13 +50,13 @@ def text2story(caption, _models):
50
  prompt = f"""<|system|>
51
  You are a story generating assistant.
52
  <|user|>
53
- Please generate a story within 100 words based on: {caption}
54
  <|assistant|>"""
55
 
56
  # Generate story with parameters tuned for brevity and coherence
57
  response = story_generator(
58
  prompt,
59
- max_new_tokens=100, # Allow enough tokens for a complete story
60
  do_sample=True,
61
  temperature=0.7, # Balanced creativity
62
  top_p=0.9, # Focus on more likely tokens
@@ -91,7 +91,6 @@ def text2audio(story_text):
91
 
92
  # Load models at startup - this happens before the app interface is displayed
93
  models = load_models()
94
- st.write("✅ Models loaded and cached!")
95
 
96
  # Streamlit app interface
97
  st.title("Image to Audio Story for Kids")
 
1
+ # Imports
2
  import streamlit as st
3
  from transformers import pipeline
4
  from PIL import Image
 
50
  prompt = f"""<|system|>
51
  You are a story generating assistant.
52
  <|user|>
53
+ Please generate a story within 100 words based on the image caption: {caption}
54
  <|assistant|>"""
55
 
56
  # Generate story with parameters tuned for brevity and coherence
57
  response = story_generator(
58
  prompt,
59
+ max_new_tokens=120, # Allow enough tokens for a complete story
60
  do_sample=True,
61
  temperature=0.7, # Balanced creativity
62
  top_p=0.9, # Focus on more likely tokens
 
91
 
92
  # Load models at startup - this happens before the app interface is displayed
93
  models = load_models()
 
94
 
95
  # Streamlit app interface
96
  st.title("Image to Audio Story for Kids")