mhue commited on
Commit
d7973f4
·
1 Parent(s): dc5f6d2

Update app for hotdog classifier

Browse files
Files changed (1) hide show
  1. app.py +24 -2
app.py CHANGED
@@ -1,4 +1,26 @@
 
 
 
 
 
 
1
  import streamlit as st
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
2
 
3
- x = st.slider('Select a value')
4
- st.write(x, 'squared is', x * x)
 
 
1
+ # import streamlit as st
2
+
3
+ # x = st.slider('Select a value')
4
+ # st.write(x, 'squared is', x * x)
5
+
6
+
7
  import streamlit as st
8
+ from transformers import pipeline
9
+ from PIL import Image
10
+
11
+ pipeline = pipeline(task="image-classification", model="julien-c/hotdog-not-hotdog")
12
+
13
+ st.title("Hot Dog? Or Not?")
14
+
15
+ file_name = st.file_uploader("Upload a hot dog candidate image")
16
+
17
+ if file_name is not None:
18
+ col1, col2 = st.columns(2)
19
+
20
+ image = Image.open(file_name)
21
+ col1.image(image, use_column_width=True)
22
+ predictions = pipeline(image)
23
 
24
+ col2.header("Probabilities")
25
+ for p in predictions:
26
+ col2.subheader(f"{ p['label'] }: { round(p['score'] * 100, 1)}%")