Ray1st commited on
Commit
0cce53f
·
verified ·
1 Parent(s): 101b135

Create app

Browse files
Files changed (1) hide show
  1. app +32 -0
app ADDED
@@ -0,0 +1,32 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+
2
+ import gradio as gr
3
+ from transformers import pipeline
4
+
5
+ sentiment_pipeline = pipeline("sentiment-analysis")
6
+
7
+ review = "I haven not enjoyed my stay !"
8
+
9
+ result = sentiment_pipeline(review)[0]
10
+ print(result)
11
+
12
+ def analyze_sentiment(review):
13
+ result = sentiment_pipeline(review)[0]
14
+ sentiment_label = result["label"]
15
+ confidence_score = round(result["score"], 2)
16
+ return sentiment_label, confidence_score
17
+
18
+ interface = gr.Interface(
19
+ fn=analyze_sentiment,
20
+ inputs=gr.Textbox(
21
+ lines=3, placeholder="Enter a review...", label="Enter the review:"
22
+ ),
23
+ outputs=[
24
+ gr.Textbox(label="Sentiment:"),
25
+ gr.Textbox(label="Confidence Score:")
26
+ ],
27
+ title="Sentiment Analysis",
28
+ description="Enter a review and get the sentiment and confidence score."
29
+ )
30
+
31
+
32
+ interface.launch()