Spaces:
Sleeping
Sleeping
Update src/streamlit_app.py
Browse files- src/streamlit_app.py +20 -6
src/streamlit_app.py
CHANGED
|
@@ -6,7 +6,7 @@ import os
|
|
| 6 |
|
| 7 |
|
| 8 |
from models.imageCaptioning import generateCaption
|
| 9 |
-
|
| 10 |
|
| 11 |
st.set_page_config(page_title="Image2Story Generator", layout="centered")
|
| 12 |
st.title("Image2Story Generator")
|
|
@@ -26,15 +26,29 @@ if uploaded_file:
|
|
| 26 |
image.save(image_path)
|
| 27 |
|
| 28 |
# st.image(image, caption="uploaded image" , use_container_width=True)
|
| 29 |
-
|
| 30 |
|
| 31 |
|
| 32 |
|
| 33 |
with st.spinner("Generating Captions..."):
|
| 34 |
captions = generateCaption(image_path)
|
| 35 |
st.success(f"The image is of : {captions}")
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 36 |
|
| 37 |
-
|
| 38 |
-
|
| 39 |
-
|
| 40 |
-
|
|
|
|
| 6 |
|
| 7 |
|
| 8 |
from models.imageCaptioning import generateCaption
|
| 9 |
+
from models.storyGeneration import generateStory
|
| 10 |
|
| 11 |
st.set_page_config(page_title="Image2Story Generator", layout="centered")
|
| 12 |
st.title("Image2Story Generator")
|
|
|
|
| 26 |
image.save(image_path)
|
| 27 |
|
| 28 |
# st.image(image, caption="uploaded image" , use_container_width=True)
|
| 29 |
+
story_style = st.sidebar.selectbox("Choose Story Style" , ["William Shakespeare" , "Leo Tolstoy", "Charles Dickens" , "Haruki Murakami" , "J.K. Rowling" , "Stephen King"])
|
| 30 |
|
| 31 |
|
| 32 |
|
| 33 |
with st.spinner("Generating Captions..."):
|
| 34 |
captions = generateCaption(image_path)
|
| 35 |
st.success(f"The image is of : {captions}")
|
| 36 |
+
|
| 37 |
+
|
| 38 |
+
story_style = st.sidebar.selectbox("Choose Story Style" , ["William Shakespeare" , "Leo Tolstoy", "Charles Dickens" , "Haruki Murakami" , "J.K. Rowling" , "Stephen King"])
|
| 39 |
+
|
| 40 |
+
prompt = f"""
|
| 41 |
+
You are a professional story writer with a deep understanding of surreal and introspective storytelling, inspired by {story_style}.
|
| 42 |
+
Write a short story based on the theme: {caption.strip()}.
|
| 43 |
+
The story should be in between 500 and 800 words, and must include:
|
| 44 |
+
- A clear beginning and ending.
|
| 45 |
+
- Subtle emotional depth and a dreamlike atmosphere.
|
| 46 |
+
- Elements typical of {story_style}'s writing style.
|
| 47 |
+
Do not include a title. Return only the story.
|
| 48 |
+
"""
|
| 49 |
+
|
| 50 |
|
| 51 |
+
with st.spinner("Generating Story..."):
|
| 52 |
+
story = generateStory(captions)
|
| 53 |
+
st.markdown("Generated Story")
|
| 54 |
+
st.write(story)
|