Spaces:
Runtime error
Runtime error
Rob Caamano
commited on
App 2.2
Browse files
app.py
CHANGED
@@ -8,7 +8,7 @@ from transformers import pipeline
|
|
8 |
|
9 |
st.title("Detecting Toxic Tweets")
|
10 |
|
11 |
-
demo = """
|
12 |
|
13 |
text = st.text_area("Input text", demo, height=250)
|
14 |
|
@@ -31,7 +31,13 @@ input = tokenizer(text, return_tensors="tf")
|
|
31 |
|
32 |
if st.button("Submit", type="primary"):
|
33 |
results = clf(text)[0]
|
34 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
35 |
tweet_portion = text[:50] + "..." if len(text) > 50 else text
|
36 |
|
37 |
# Create and display the table
|
|
|
8 |
|
9 |
st.title("Detecting Toxic Tweets")
|
10 |
|
11 |
+
demo = """I'm so proud of myself for accomplishing my goals today. #motivation #success"""
|
12 |
|
13 |
text = st.text_area("Input text", demo, height=250)
|
14 |
|
|
|
31 |
|
32 |
if st.button("Submit", type="primary"):
|
33 |
results = clf(text)[0]
|
34 |
+
|
35 |
+
if selected_model == "Fine-tuned Toxicity Model":
|
36 |
+
max_class = max(results, key=lambda x: x["score"])
|
37 |
+
max_class["label"] = max_class["label"].split("_")[-1] # Extract the toxicity class from the label
|
38 |
+
else:
|
39 |
+
max_class = max(results, key=lambda x: x["score"])
|
40 |
+
|
41 |
tweet_portion = text[:50] + "..." if len(text) > 50 else text
|
42 |
|
43 |
# Create and display the table
|