Spaces:
Runtime error
Runtime error
Rob Caamano
commited on
Update app.py
Browse files
app.py
CHANGED
|
@@ -9,11 +9,10 @@ from transformers import pipeline
|
|
| 9 |
st.title("Toxic Tweet Classifier")
|
| 10 |
|
| 11 |
demo = """Your words are like poison. They seep into my mind and make me feel worthless."""
|
|
|
|
| 12 |
|
| 13 |
-
text = ""
|
| 14 |
submit = False
|
| 15 |
model_name = ""
|
| 16 |
-
col1, col2, col3 = st.columns([2,1,1])
|
| 17 |
|
| 18 |
with st.container():
|
| 19 |
model_name = st.selectbox(
|
|
@@ -28,10 +27,6 @@ clf = pipeline(
|
|
| 28 |
"sentiment-analysis", model=model, tokenizer=tokenizer, return_all_scores=True
|
| 29 |
)
|
| 30 |
|
| 31 |
-
with col1:
|
| 32 |
-
st.subheader("Tweet")
|
| 33 |
-
text = st.text_area("Input text", demo, height=275)
|
| 34 |
-
|
| 35 |
input = tokenizer(text, return_tensors="tf")
|
| 36 |
|
| 37 |
if submit:
|
|
@@ -42,9 +37,9 @@ if submit:
|
|
| 42 |
probability = classes[max_class]
|
| 43 |
|
| 44 |
result_df = pd.DataFrame({
|
|
|
|
| 45 |
'Classification': [max_class],
|
| 46 |
-
'Probability': [probability]
|
| 47 |
-
'Toxic': ['Yes' if results['toxic'] >= 0.5 else 'No']
|
| 48 |
})
|
| 49 |
|
| 50 |
st.table(result_df)
|
|
|
|
| 9 |
st.title("Toxic Tweet Classifier")
|
| 10 |
|
| 11 |
demo = """Your words are like poison. They seep into my mind and make me feel worthless."""
|
| 12 |
+
text = st.text_area("Input text", demo, height=275)
|
| 13 |
|
|
|
|
| 14 |
submit = False
|
| 15 |
model_name = ""
|
|
|
|
| 16 |
|
| 17 |
with st.container():
|
| 18 |
model_name = st.selectbox(
|
|
|
|
| 27 |
"sentiment-analysis", model=model, tokenizer=tokenizer, return_all_scores=True
|
| 28 |
)
|
| 29 |
|
|
|
|
|
|
|
|
|
|
|
|
|
| 30 |
input = tokenizer(text, return_tensors="tf")
|
| 31 |
|
| 32 |
if submit:
|
|
|
|
| 37 |
probability = classes[max_class]
|
| 38 |
|
| 39 |
result_df = pd.DataFrame({
|
| 40 |
+
'Toxic': ['Yes' if results['toxic'] >= 0.5 else 'No'],
|
| 41 |
'Classification': [max_class],
|
| 42 |
+
'Probability': [probability]
|
|
|
|
| 43 |
})
|
| 44 |
|
| 45 |
st.table(result_df)
|