parasmech commited on
Commit
1bef306
·
verified ·
1 Parent(s): 9a083b2

Create app.py

Browse files
Files changed (1) hide show
  1. app.py +23 -0
app.py ADDED
@@ -0,0 +1,23 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import gradio as gr
2
+ from transformers import pipeline
3
+
4
+
5
+ model = pipeline("text-classification", model="distilbert-base-uncased-finetuned-sst-2-english")
6
+
7
+ def input_text_fn(text):
8
+ result = model(text)
9
+ label = result[0]['label']
10
+ confidence = result[0]['score']
11
+ return f"Label: {label}, Confidence: {confidence:.2f}"
12
+
13
+
14
+ interface = gr.Interface(
15
+ fn=input_text_fn,
16
+ inputs="text",
17
+ outputs="text",
18
+ title="Text Classification or Sentiment Analysis",
19
+ description="Enter text to classify it as positive or negative sentiment."
20
+ )
21
+
22
+ # Launch the app
23
+ interface.launch()