billydsi commited on
Commit
69070dc
1 Parent(s): 9ceae55

Upload app.py

Browse files

New working app

Files changed (1) hide show
  1. app.py +25 -5
app.py CHANGED
@@ -1,8 +1,28 @@
1
  import streamlit as st
 
2
 
3
- picture = st.camera_input("Take a picture")
 
 
 
 
 
 
 
4
 
5
- if picture:
6
- st.image(picture)
7
-
8
-
 
 
 
 
 
 
 
 
 
 
 
 
 
1
  import streamlit as st
2
+ from fastai.vision.all import *
3
 
4
+ st.set_page_config(
5
+ page_title="IG PIC?",
6
+ menu_items={
7
+ 'About': "# Help decide whether I can use this picture on Instagram or not using face attractiveness measure ;)"
8
+ }
9
+ )
10
+ st.title('Can I use it as an Instagram Picture?')
11
+ st.header('Upload your IG Picture')
12
 
13
+ uploaded_file = st.file_uploader("Upload your image", type=["jpg","png","jpeg"], help = "Upload single jpg or png image")
14
+ learner = load_learner("model_1.pkl")
15
+ if uploaded_file is not None:
16
+ image = PILImage.create(uploaded_file)
17
+ col1, col2 = st.columns(2)
18
+ col1.image(image)
19
+ attractive,id, probs = learner.predict(image)
20
+ id = int(id)
21
+ probs = np.array(probs)
22
+ if id == 0:
23
+ col2.subheader('Instagram Picture')
24
+ col2.metric(label="", value= int(probs[0] * 100), delta="+")
25
+ else:
26
+ col2.subheader('Not an Instagram Picture')
27
+ col2.metric(label="", value=int(probs[1] * 100), delta="-")
28
+