import streamlit as st from footer import footer import pandas as pd from io import StringIO import os from pathlib import Path Path("./tempDir").mkdir(parents=True, exist_ok=True) # Image from PIL import Image streamlit_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("./seed-1.png", width=200) with col3: st.write(' ') footer() st.markdown("

StorySeed

", unsafe_allow_html=True) st.markdown("

Plant the seed of your story with a picture.

", 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)