File size: 893 Bytes
7f8de92
 
bd063dc
1188df8
0f64e73
 
a2a9b24
b1b5dc2
0f64e73
b1b5dc2
0f64e73
854d0de
 
a2a9b24
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
71af36e
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
import streamlit as st
from transformers import pipeline 
st.title("Milestone #2 v2")
text = st.text_input("write a statement")
import streamlit as st

options = ["zero-shot-classification", "cardiffnlp/twitter-roberta-base-offensive", "nill3"]
model = st.selectbox("Select an option", options)

##model = st.write("You selected:", selected_option)

con = st.button("submit")
if con:
  if model == "zero-shot-classification":
    classifier = pipeline(model)
    res = classifier(text, candidate_labels= ["offensive"],)
    print(res)
    st.write(res)
  
  if model == "cardiffnlp/twitter-roberta-base-offensive":
    

    classifier = pipeline('text-classification', model='cardiffnlp/twitter-roberta-base-offensive', tokenizer='cardiffnlp/twitter-roberta-base-offensive')


    result = offensive_classifier(text)

    
    print(f" score {result[0]['score']*100:.2f}% confidence.")