File size: 1,487 Bytes
3488695
 
 
 
 
 
 
 
24fb9e3
 
3488695
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
36649a6
3488695
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
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 = """
			<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("./seed-1.png", width=200)

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)