Spaces:
Sleeping
Sleeping
Create app.py
Browse files
app.py
ADDED
|
@@ -0,0 +1,13 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
import gradio as gr
|
| 2 |
+
from transformers import pipeline
|
| 3 |
+
|
| 4 |
+
# โหลดโมเดลที่ฝึกแล้ว หรือโมเดล pretrained
|
| 5 |
+
clf = pipeline("text-classification", model="distilbert-base-uncased")
|
| 6 |
+
|
| 7 |
+
def classify_text(text):
|
| 8 |
+
result = clf(text)[0]
|
| 9 |
+
return f"Label: {result['label']} (Score: {round(result['score'], 2)})"
|
| 10 |
+
|
| 11 |
+
demo = gr.Interface(fn=classify_text, inputs="text", outputs="text", title="Text Classifier")
|
| 12 |
+
|
| 13 |
+
demo.launch()
|