Spaces:
Running
Running
clear crash fix
Browse files
app.py
CHANGED
@@ -36,8 +36,18 @@ st = SentenceTokenizer(vocabulary, maxlen)
|
|
36 |
model = torchmoji_emojis(model_path)
|
37 |
|
38 |
def predict(deepmoji_analysis, emoji_count):
|
|
|
|
|
|
|
|
|
39 |
return_label = {}
|
|
|
40 |
tokenized, _, _ = st.tokenize_sentences([deepmoji_analysis])
|
|
|
|
|
|
|
|
|
|
|
41 |
prob = model(tokenized)
|
42 |
|
43 |
for prob in [prob]:
|
@@ -58,11 +68,15 @@ def predict(deepmoji_analysis, emoji_count):
|
|
58 |
label_prob = t_prob[ind]
|
59 |
return_label[label_name] = label_prob
|
60 |
|
|
|
|
|
|
|
|
|
61 |
return return_label
|
62 |
|
63 |
input_textbox = gr.Textbox(
|
64 |
label="English Text",
|
65 |
-
info="ignores: emojis,
|
66 |
lines=1,
|
67 |
value="This is the shit!",
|
68 |
autofocus=True
|
|
|
36 |
model = torchmoji_emojis(model_path)
|
37 |
|
38 |
def predict(deepmoji_analysis, emoji_count):
|
39 |
+
if deepmoji_analysis.trim() == '':
|
40 |
+
# dotted face emoji
|
41 |
+
return {"🫥":1}
|
42 |
+
|
43 |
return_label = {}
|
44 |
+
# tokenize input text
|
45 |
tokenized, _, _ = st.tokenize_sentences([deepmoji_analysis])
|
46 |
+
|
47 |
+
if len(tokenized) == 0:
|
48 |
+
# dotted face emoji
|
49 |
+
return {"🫥":1}
|
50 |
+
|
51 |
prob = model(tokenized)
|
52 |
|
53 |
for prob in [prob]:
|
|
|
68 |
label_prob = t_prob[ind]
|
69 |
return_label[label_name] = label_prob
|
70 |
|
71 |
+
if len(return_label) == 0:
|
72 |
+
# dotted face emoji
|
73 |
+
return {"🫥":1}
|
74 |
+
|
75 |
return return_label
|
76 |
|
77 |
input_textbox = gr.Textbox(
|
78 |
label="English Text",
|
79 |
+
info="ignores: emojis, emoticons, numbers, URLs",
|
80 |
lines=1,
|
81 |
value="This is the shit!",
|
82 |
autofocus=True
|