Gregoryjr commited on
Update app.py
Browse files
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", "
|
| 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 |
-
|
| 15 |
-
|
| 16 |
-
|
| 17 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 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 |
|