ThiSecur commited on
Commit
4641849
·
verified ·
1 Parent(s): 2e44fa1

Create app.py

Browse files
Files changed (1) hide show
  1. app.py +19 -0
app.py ADDED
@@ -0,0 +1,19 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ from transformers import pipeline
2
+ import gradio as gr
3
+
4
+ # Load the model from Hugging Face
5
+ classifier = pipeline("sentiment-analysis")
6
+
7
+ # Define the function to make predictions
8
+ def predict(text):
9
+ result = classifier(text)[0]
10
+ return f"{result['label']} ({result['score']:.2f})"
11
+
12
+ # Create the Gradio interface
13
+ gr.Interface(
14
+ fn=predict,
15
+ inputs=gr.Textbox(label="Enter Text"),
16
+ outputs=gr.Label(label="Sentiment"),
17
+ title="Sentiment Analysis with DistilBERT",
18
+ description="Classify text as positive or negative.",
19
+ ).launch()