Spaces:
Runtime error
Runtime error
shrirangphadke
commited on
Update app.py
Browse files
app.py
CHANGED
@@ -1,15 +1,10 @@
|
|
1 |
import gradio as gr
|
2 |
import os
|
3 |
import torch
|
4 |
-
import spacy
|
5 |
-
from spacy import displacy
|
6 |
-
|
7 |
-
nlp = spacy.load("en_core_web_sm")
|
8 |
|
9 |
# Load model directly
|
10 |
from transformers import AutoTokenizer, AutoModelForSequenceClassification
|
11 |
|
12 |
-
|
13 |
def get_hatespeech_score(text):
|
14 |
tokenizer = AutoTokenizer.from_pretrained("unhcr/hatespeech-detection")
|
15 |
model = AutoModelForSequenceClassification.from_pretrained("unhcr/hatespeech-detection")
|
@@ -51,17 +46,12 @@ def text_analysis(text):
|
|
51 |
</html>
|
52 |
'''.format("Alpha", label_1, "Gamma", "Theta")
|
53 |
|
54 |
-
|
55 |
-
pos_tokens = []
|
56 |
-
for token in doc:
|
57 |
-
pos_tokens.extend([(token.text, token.pos_), (" ", None)])
|
58 |
-
|
59 |
-
return pos_tokens, html
|
60 |
|
61 |
demo = gr.Interface(
|
62 |
text_analysis,
|
63 |
gr.Textbox(placeholder="Enter sentence here..."),
|
64 |
-
["
|
65 |
examples=[
|
66 |
["What a beautiful morning for a walk!"],
|
67 |
["It was the best of times, it was the worst of times."],
|
|
|
1 |
import gradio as gr
|
2 |
import os
|
3 |
import torch
|
|
|
|
|
|
|
|
|
4 |
|
5 |
# Load model directly
|
6 |
from transformers import AutoTokenizer, AutoModelForSequenceClassification
|
7 |
|
|
|
8 |
def get_hatespeech_score(text):
|
9 |
tokenizer = AutoTokenizer.from_pretrained("unhcr/hatespeech-detection")
|
10 |
model = AutoModelForSequenceClassification.from_pretrained("unhcr/hatespeech-detection")
|
|
|
46 |
</html>
|
47 |
'''.format("Alpha", label_1, "Gamma", "Theta")
|
48 |
|
49 |
+
return html
|
|
|
|
|
|
|
|
|
|
|
50 |
|
51 |
demo = gr.Interface(
|
52 |
text_analysis,
|
53 |
gr.Textbox(placeholder="Enter sentence here..."),
|
54 |
+
["html"],
|
55 |
examples=[
|
56 |
["What a beautiful morning for a walk!"],
|
57 |
["It was the best of times, it was the worst of times."],
|