kingsotn commited on
Commit
7179214
1 Parent(s): 7015592
Files changed (1) hide show
  1. app.py +37 -15
app.py CHANGED
@@ -1,25 +1,47 @@
1
  import streamlit as st
2
- from tranformers import pipeline
 
3
 
 
4
 
5
- pipe = pipeline(task="sentiment-analysis")
6
- st.title("Toxic Tweets Analyzer")
7
 
8
- text = st.text_area("Enter your tweet here, or submit to test the default tweets")
9
 
10
- if text == "Enter your tweet here, or submit to test the default tweets":
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
11
 
12
- data = [
13
- "PICKLE YE",
14
- "I'm nice at ping pong"
15
- "My eyes are now wide open and now realize I've been used to spread messages I don't believe in. I am distancing myself from politics and completely focusing on being creative !!!",
16
- "There are so many lonely emojis",
17
- ]
18
 
19
- st.json([pipe(d) for d in data])
20
 
21
- else:
22
- out = pipe(text)
23
- st.json(out)
24
 
25
 
 
1
  import streamlit as st
2
+ from transformers import pipeline
3
+ from PIL import Image
4
 
5
+ pipeline = pipeline(task="image-classification", model="julien-c/hotdog-not-hotdog")
6
 
7
+ st.title("Hot Dog? Or Not?")
 
8
 
9
+ file_name = st.file_uploader("Upload a hot dog candidate image")
10
 
11
+ if file_name is not None:
12
+ col1, col2 = st.columns(2)
13
+
14
+ image = Image.open(file_name)
15
+ col1.image(image, use_column_width=True)
16
+ predictions = pipeline(image)
17
+
18
+ col2.header("Probabilities")
19
+ for p in predictions:
20
+ col2.subheader(f"{ p['label'] }: { round(p['score'] * 100, 1)}%")
21
+
22
+
23
+ # import streamlit as st
24
+ # from tranformers import pipeline
25
+
26
+
27
+ # pipe = pipeline(task="sentiment-analysis")
28
+ # st.title("Toxic Tweets Analyzer")
29
+
30
+ # text = st.text_area("Enter your tweet here, or submit to test the default tweets")
31
+
32
+ # if text == "Enter your tweet here, or submit to test the default tweets":
33
 
34
+ # data = [
35
+ # "PICKLE YE",
36
+ # "I'm nice at ping pong"
37
+ # "My eyes are now wide open and now realize I've been used to spread messages I don't believe in. I am distancing myself from politics and completely focusing on being creative !!!",
38
+ # "There are so many lonely emojis",
39
+ # ]
40
 
41
+ # st.json([pipe(d) for d in data])
42
 
43
+ # else:
44
+ # out = pipe(text)
45
+ # st.json(out)
46
 
47