Khunanya commited on
Commit
4f6cd08
·
verified ·
1 Parent(s): 9671f25

Create app.py

Browse files
Files changed (1) hide show
  1. app.py +13 -0
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()