kelvinleong commited on
Commit
95b93ce
·
1 Parent(s): a07d11d

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +22 -1
app.py CHANGED
@@ -1,3 +1,24 @@
1
  import gradio as gr
 
2
 
3
- gr.Interface.load("models/kelvinleong/KT_Roberta-Base_Class").launch()
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
  import gradio as gr
2
+ from transformers import pipeline
3
 
4
+ # Load text classification model from Hugging Face
5
+ model = pipeline("text-classification", model="distilbert-base-uncased-finetuned-sst-2-english")
6
+
7
+ def classify_text(text):
8
+ # Classify text using the loaded model
9
+ result = model(text)[0]
10
+ label = result['label']
11
+ score = result['score']
12
+ return f"Label: {label}, Score: {score}"
13
+
14
+ # Create Gradio interface
15
+ iface = gr.Interface(
16
+ fn=classify_text,
17
+ inputs=gr.inputs.Textbox(label="Enter text to classify"),
18
+ outputs="text",
19
+ title="Text Classification with Hugging Face",
20
+ description="Classify text using a pre-trained model from Hugging Face."
21
+ )
22
+
23
+ # Launch the interface
24
+ iface.launch()