Spaces:
Runtime error
Runtime error
Alex Martin
commited on
Commit
•
2939714
1
Parent(s):
2530da6
Update app.py
Browse files
app.py
CHANGED
@@ -7,23 +7,6 @@ from PIL import Image
|
|
7 |
st.markdown("Link to the app - [milestone2-app](https://huggingface.co/spaces/aim9061/sentiment-analysis)")
|
8 |
st.title("Toxic Tweets Sentiment Analysis")
|
9 |
|
10 |
-
|
11 |
-
words = "Take that, you funking cat-dragon! You smell really bad!"
|
12 |
-
text = st.text_area("Insert text for analysis below.", words)
|
13 |
-
|
14 |
-
model_list = ["aim9061/fine-tuned-toxic-tweet-dilbert", "distilbert-base-uncased-finetuned-sst-2-english", "bert-base-cased", "openai/clip-vit-base-patch32", "emilyalsentzer/Bio_ClinicalBERT",
|
15 |
-
"sentence-transformers/all-mpnet-base-v2", "facebook/bart-large-cnn", "openai/clip-vit-base-patch16", "speechbrain/spkrec-ecapa-voxceleb",
|
16 |
-
"albert-base-v2"]
|
17 |
-
model = st.selectbox("", model_list)
|
18 |
-
sub = st.write("Pick the model to use for analyzing the text!")
|
19 |
-
button = st.button("Analyze!")
|
20 |
-
pipe = pipeline("text-classification")
|
21 |
-
if(button):
|
22 |
-
if model == "aim9061/fine-tuned-toxic-tweet-dilbert":
|
23 |
-
get_cats(text)
|
24 |
-
pipe = pipeline("text-classification", model)
|
25 |
-
results = pipe(text)
|
26 |
-
st.write(results)
|
27 |
def create_dict(prob, text):
|
28 |
sorted_indices = np.argsort(prob)[-2:]
|
29 |
info = {"text": text,
|
@@ -42,6 +25,24 @@ def get_cats(text):
|
|
42 |
|
43 |
data = create_dict(prob, text)
|
44 |
st.table(data)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
45 |
|
46 |
#TODO: DOCUMENT CODE
|
47 |
|
|
|
7 |
st.markdown("Link to the app - [milestone2-app](https://huggingface.co/spaces/aim9061/sentiment-analysis)")
|
8 |
st.title("Toxic Tweets Sentiment Analysis")
|
9 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
10 |
def create_dict(prob, text):
|
11 |
sorted_indices = np.argsort(prob)[-2:]
|
12 |
info = {"text": text,
|
|
|
25 |
|
26 |
data = create_dict(prob, text)
|
27 |
st.table(data)
|
28 |
+
|
29 |
+
words = "Take that, you funking cat-dragon! You smell really bad!"
|
30 |
+
text = st.text_area("Insert text for analysis below.", words)
|
31 |
+
|
32 |
+
model_list = ["aim9061/fine-tuned-toxic-tweet-dilbert", "distilbert-base-uncased-finetuned-sst-2-english", "bert-base-cased", "openai/clip-vit-base-patch32", "emilyalsentzer/Bio_ClinicalBERT",
|
33 |
+
"sentence-transformers/all-mpnet-base-v2", "facebook/bart-large-cnn", "openai/clip-vit-base-patch16", "speechbrain/spkrec-ecapa-voxceleb",
|
34 |
+
"albert-base-v2"]
|
35 |
+
model = st.selectbox("", model_list)
|
36 |
+
sub = st.write("Pick the model to use for analyzing the text!")
|
37 |
+
button = st.button("Analyze!")
|
38 |
+
pipe = pipeline("text-classification")
|
39 |
+
if(button):
|
40 |
+
if model == "aim9061/fine-tuned-toxic-tweet-dilbert":
|
41 |
+
get_cats(text)
|
42 |
+
pipe = pipeline("text-classification", model)
|
43 |
+
results = pipe(text)
|
44 |
+
st.write(results)
|
45 |
+
|
46 |
|
47 |
#TODO: DOCUMENT CODE
|
48 |
|