Gregoryjr
commited on
Update app.py
Browse files
app.py
CHANGED
|
@@ -1,32 +1,20 @@
|
|
| 1 |
import streamlit as st
|
| 2 |
from transformers import pipeline
|
|
|
|
| 3 |
st.title("Milestone #2 v2")
|
| 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=
|
| 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 = classifier(text)
|
| 27 |
-
|
| 28 |
-
|
| 29 |
st.write(f"Score: {result[0]['score']*100:.2f}% confidence")
|
| 30 |
-
|
| 31 |
-
|
| 32 |
-
|
|
|
|
| 1 |
import streamlit as st
|
| 2 |
from transformers import pipeline
|
| 3 |
+
|
| 4 |
st.title("Milestone #2 v2")
|
| 5 |
text = st.text_input("write a statement")
|
|
|
|
| 6 |
|
| 7 |
options = ["zero-shot-classification", "cardiffnlp/twitter-roberta-base-offensive", "nill3"]
|
| 8 |
model = st.selectbox("Select an option", options)
|
| 9 |
|
|
|
|
|
|
|
| 10 |
con = st.button("submit")
|
| 11 |
if con:
|
| 12 |
if model == "zero-shot-classification":
|
| 13 |
classifier = pipeline(model)
|
| 14 |
+
res = classifier(text, candidate_labels=["offensive"])
|
|
|
|
| 15 |
st.write(res)
|
| 16 |
|
| 17 |
if model == "cardiffnlp/twitter-roberta-base-offensive":
|
|
|
|
|
|
|
| 18 |
classifier = pipeline('text-classification', model='cardiffnlp/twitter-roberta-base-offensive', tokenizer='cardiffnlp/twitter-roberta-base-offensive')
|
|
|
|
|
|
|
| 19 |
result = classifier(text)
|
|
|
|
|
|
|
| 20 |
st.write(f"Score: {result[0]['score']*100:.2f}% confidence")
|
|
|
|
|
|
|
|
|