Gregoryjr commited on
Commit
a2a9b24
·
unverified ·
1 Parent(s): bd063dc

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +19 -5
app.py CHANGED
@@ -4,15 +4,29 @@ st.title("Milestone #2 v2")
4
  text = st.text_input("write a statement")
5
  import streamlit as st
6
 
7
- options = ["zero-shot-classification", "nill", "nill3"]
8
  model = st.selectbox("Select an option", options)
9
 
10
  ##model = st.write("You selected:", selected_option)
11
 
12
  con = st.button("submit")
13
  if con:
14
- classifier = pipeline(model)
15
- res = classifier(text, candidate_labels= ["offensive"],)
16
- print(res)
17
- st.write(res)
 
 
 
 
 
 
 
 
 
 
 
 
 
 
18
 
 
4
  text = st.text_input("write a statement")
5
  import streamlit as st
6
 
7
+ options = ["zero-shot-classification", "cardiffnlp/twitter-roberta-base-offensive", "nill3"]
8
  model = st.selectbox("Select an option", options)
9
 
10
  ##model = st.write("You selected:", selected_option)
11
 
12
  con = st.button("submit")
13
  if con:
14
+ if model == "zero-shot-classification":
15
+ classifier = pipeline(model)
16
+ res = classifier(text, candidate_labels= ["offensive"],)
17
+ print(res)
18
+ st.write(res)
19
+
20
+ if model == "cardiffnlp/twitter-roberta-base-offensive":
21
+
22
+
23
+ classifier = pipeline('text-classification', model='cardiffnlp/twitter-roberta-base-offensive', tokenizer='cardiffnlp/twitter-roberta-base-offensive')
24
+
25
+
26
+ result = offensive_classifier(text)
27
+
28
+
29
+ print(f" score {result[0]['score']*100:.2f}% confidence.")
30
+
31
+
32