Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
|
@@ -6,7 +6,17 @@ clf = pipeline("text-classification", model="distilbert-base-uncased")
|
|
| 6 |
|
| 7 |
def classify_text(text):
|
| 8 |
result = clf(text)[0]
|
| 9 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 10 |
|
| 11 |
demo = gr.Interface(fn=classify_text, inputs="text", outputs="text", title="Text Classifier")
|
| 12 |
|
|
|
|
| 6 |
|
| 7 |
def classify_text(text):
|
| 8 |
result = clf(text)[0]
|
| 9 |
+
label = result['label']
|
| 10 |
+
score = round(result['score'], 2)
|
| 11 |
+
|
| 12 |
+
# เปลี่ยนชื่อ label ให้เข้าใจง่าย
|
| 13 |
+
if label == "LABEL_1":
|
| 14 |
+
label_name = "ความคิดเห็นเชิงบวก 😀"
|
| 15 |
+
else:
|
| 16 |
+
label_name = "ความคิดเห็นเชิงลบ 😞"
|
| 17 |
+
|
| 18 |
+
return f"{label_name} (ความมั่นใจ: {score})"
|
| 19 |
+
|
| 20 |
|
| 21 |
demo = gr.Interface(fn=classify_text, inputs="text", outputs="text", title="Text Classifier")
|
| 22 |
|