StorySeed / app.py
anasrz's picture
Create app.py
3488695
raw
history blame
1.43 kB
import streamlit as st
from footer import footer
import pandas as pd
from io import StringIO
import os
# Image
from PIL import Image
streamlit_style = """
<style>
@import url('https://fonts.googleapis.com/css2?family=Montserrat:wght@300&display=swap');
html, body, [class*="css"] {
font-family: 'Montserrat', sans-serif;
}
</style>
"""
st.markdown(streamlit_style, unsafe_allow_html=True)
#@st.cache
def load_image(image_file):
img = Image.open(image_file)
return img
col1, col2, col3 = st.columns(3)
with col1:
st.write(' ')
with col2:
st.image("https://imgtr.ee/images/2023/04/24/8KrbX.png")
with col3:
st.write(' ')
footer()
st.markdown("<h1 style='text-align: center; '>StorySeed</h1>", unsafe_allow_html=True)
st.markdown("<p style='text-align: center; '>Plant the seed of your story with a picture.</p>", unsafe_allow_html=True)
image_file = st.file_uploader("Upload An Image",type=['png','jpeg','jpg'])
from model import get_story
if image_file is not None:
file_details = {"FileName":image_file.name,"FileType":image_file.type}
img = load_image(image_file)
st.image(img)
img_path = os.path.join("tempDir",image_file.name)
with open(img_path,"wb") as f:
f.write(image_file.getbuffer())
with st.spinner("File uploaded. Writing Story.."):
story = get_story(img_path)
st.success("Here's your story.. πŸŽ‰")
st.write(story)