ndg04041 commited on
Commit
b19f251
1 Parent(s): cccd151

Create app.py

Browse files
Files changed (1) hide show
  1. app.py +15 -0
app.py ADDED
@@ -0,0 +1,15 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import gradio as gr
2
+ from transformers import pipeline
3
+
4
+ # Load the pre-trained pipeline for sentiment analysis
5
+ sentiment_analysis = pipeline('text-classification', model='distilbert-base-uncased-finetuned-sst-2-english')
6
+
7
+ # Define the function that will be called by Gradio
8
+ def analyze_sentiment(input_text):
9
+ output = sentiment_analysis(input_text)
10
+ sentiment = output[0]['label']
11
+ score = output[0]['score']
12
+ return f"Sentiment: {sentiment} (Score: {score:.2f})"
13
+
14
+ # Create the Gradio interface
15
+ gr.Interface(fn=analyze_sentiment, inputs="text", outputs="text", title="Sentiment Analysis AI").launch()