Spaces:
Running
Running
Kingston Yip
commited on
Commit
β’
5e6cddb
1
Parent(s):
39007cc
YEEEE
Browse files- app.py +8 -2
- requirements.txt +3 -1
app.py
CHANGED
@@ -3,7 +3,8 @@ import torch
|
|
3 |
from transformers import AutoModelForSequenceClassification, pipeline, AutoTokenizer, DistilBertForSequenceClassification, DistilBertTokenizerFast
|
4 |
import pandas as pd
|
5 |
import comments
|
6 |
-
from random import
|
|
|
7 |
|
8 |
|
9 |
def predict_cyberbullying_probability(sentence, tokenizer, model):
|
@@ -65,7 +66,7 @@ def perform_default_analysis(model_name):
|
|
65 |
|
66 |
# main -->
|
67 |
st.title("Toxic Tweets Analyzer")
|
68 |
-
image = "
|
69 |
st.image(image, use_column_width=True)
|
70 |
|
71 |
labels = ['comment', 'toxic', 'severe_toxic', 'obscene', 'threat', 'insult', 'identity_hate']
|
@@ -80,12 +81,17 @@ with st.form("my_form"):
|
|
80 |
tweet = st.text_area(label="Enter Text:",value=default)
|
81 |
submitted = st.form_submit_button("Analyze textbox")
|
82 |
random = st.form_submit_button("Analyze a random πππ tweet (warning!!)")
|
|
|
83 |
|
84 |
if random:
|
85 |
tweet = comments.comments[randint(0, 354)]
|
86 |
st.write(tweet)
|
87 |
submitted = True
|
88 |
|
|
|
|
|
|
|
|
|
89 |
if submitted:
|
90 |
df = perform_cyberbullying_analysis(tweet)
|
91 |
st.table(df)
|
|
|
3 |
from transformers import AutoModelForSequenceClassification, pipeline, AutoTokenizer, DistilBertForSequenceClassification, DistilBertTokenizerFast
|
4 |
import pandas as pd
|
5 |
import comments
|
6 |
+
from random import randin
|
7 |
+
import kanye
|
8 |
|
9 |
|
10 |
def predict_cyberbullying_probability(sentence, tokenizer, model):
|
|
|
66 |
|
67 |
# main -->
|
68 |
st.title("Toxic Tweets Analyzer")
|
69 |
+
image = "kanye_loves_tweet.jpg"
|
70 |
st.image(image, use_column_width=True)
|
71 |
|
72 |
labels = ['comment', 'toxic', 'severe_toxic', 'obscene', 'threat', 'insult', 'identity_hate']
|
|
|
81 |
tweet = st.text_area(label="Enter Text:",value=default)
|
82 |
submitted = st.form_submit_button("Analyze textbox")
|
83 |
random = st.form_submit_button("Analyze a random πππ tweet (warning!!)")
|
84 |
+
kanye = st.form_submit_button("Get a ye quote π»π€π§πΆ")
|
85 |
|
86 |
if random:
|
87 |
tweet = comments.comments[randint(0, 354)]
|
88 |
st.write(tweet)
|
89 |
submitted = True
|
90 |
|
91 |
+
if kanye:
|
92 |
+
tweet = kanye.quote()
|
93 |
+
st.write(tweet)
|
94 |
+
|
95 |
if submitted:
|
96 |
df = perform_cyberbullying_analysis(tweet)
|
97 |
st.table(df)
|
requirements.txt
CHANGED
@@ -1,2 +1,4 @@
|
|
1 |
transformers
|
2 |
-
torch
|
|
|
|
|
|
1 |
transformers
|
2 |
+
torch
|
3 |
+
kanye
|
4 |
+
pandas
|