Spaces:
Sleeping
Sleeping
BramVanroy
commited on
Commit
•
0d8aa23
1
Parent(s):
5479465
Update app.py
Browse files
app.py
CHANGED
@@ -14,6 +14,11 @@ def pipe_predict(text):
|
|
14 |
|
15 |
def predict(text):
|
16 |
"""Perform text classification and generate results."""
|
|
|
|
|
|
|
|
|
|
|
17 |
outputs = pipe_predict(text)
|
18 |
# Sort outputs by label name
|
19 |
outputs = sorted(outputs, key=lambda item: item["label"])
|
|
|
14 |
|
15 |
def predict(text):
|
16 |
"""Perform text classification and generate results."""
|
17 |
+
text = text.strip()
|
18 |
+
|
19 |
+
if not text:
|
20 |
+
raise gr.Error("Text field cannot be empty!")
|
21 |
+
|
22 |
outputs = pipe_predict(text)
|
23 |
# Sort outputs by label name
|
24 |
outputs = sorted(outputs, key=lambda item: item["label"])
|