anasrz commited on
Commit
3488695
1 Parent(s): 61c7beb

Create app.py

Browse files
Files changed (1) hide show
  1. app.py +56 -0
app.py ADDED
@@ -0,0 +1,56 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import streamlit as st
2
+ from footer import footer
3
+ import pandas as pd
4
+ from io import StringIO
5
+
6
+
7
+ import os
8
+
9
+ # Image
10
+ from PIL import Image
11
+
12
+ streamlit_style = """
13
+ <style>
14
+ @import url('https://fonts.googleapis.com/css2?family=Montserrat:wght@300&display=swap');
15
+
16
+ html, body, [class*="css"] {
17
+ font-family: 'Montserrat', sans-serif;
18
+ }
19
+ </style>
20
+ """
21
+ st.markdown(streamlit_style, unsafe_allow_html=True)
22
+
23
+ #@st.cache
24
+ def load_image(image_file):
25
+ img = Image.open(image_file)
26
+ return img
27
+
28
+ col1, col2, col3 = st.columns(3)
29
+
30
+ with col1:
31
+ st.write(' ')
32
+
33
+ with col2:
34
+ st.image("https://imgtr.ee/images/2023/04/24/8KrbX.png")
35
+
36
+ with col3:
37
+ st.write(' ')
38
+ footer()
39
+ st.markdown("<h1 style='text-align: center; '>StorySeed</h1>", unsafe_allow_html=True)
40
+ st.markdown("<p style='text-align: center; '>Plant the seed of your story with a picture.</p>", unsafe_allow_html=True)
41
+ image_file = st.file_uploader("Upload An Image",type=['png','jpeg','jpg'])
42
+
43
+ from model import get_story
44
+
45
+
46
+ if image_file is not None:
47
+ file_details = {"FileName":image_file.name,"FileType":image_file.type}
48
+ img = load_image(image_file)
49
+ st.image(img)
50
+ img_path = os.path.join("tempDir",image_file.name)
51
+ with open(img_path,"wb") as f:
52
+ f.write(image_file.getbuffer())
53
+ with st.spinner("File uploaded. Writing Story.."):
54
+ story = get_story(img_path)
55
+ st.success("Here's your story.. 🎉")
56
+ st.write(story)