Adesola commited on
Commit
a309064
·
verified ·
1 Parent(s): 8aebbef

Create app.py

Browse files

A Sentimental analysis that gives positive, negative and neutral response

Files changed (1) hide show
  1. app.py +43 -0
app.py ADDED
@@ -0,0 +1,43 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ from transformers import pipeline
2
+
3
+ import gradio as gr
4
+
5
+
6
+
7
+ # Load sentiment analysis pipeline
8
+
9
+ # classifier_pipeline = pipeline("text-classification", model="tabularisai/multilingual-sentiment-analysis")
10
+
11
+ classifier_pipeline = ("sentiment-analysis")
12
+
13
+
14
+
15
+ # Define classification function
16
+
17
+ def classify_text(text):
18
+
19
+ output = classifier_pipeline(text)
20
+
21
+ return output[0] # Extract the first result from the list
22
+
23
+
24
+
25
+ # Define Gradio interface
26
+
27
+ interface = gr.Interface(
28
+
29
+ fn=classify_text,
30
+
31
+ inputs=gr.Textbox(label="Enter sentence here"),
32
+
33
+ outputs=gr.Label(),
34
+
35
+ examples=["I am hungry", "I love this product!", "This is the worst experience ever."]
36
+
37
+ )
38
+
39
+
40
+
41
+ # Launch the interface
42
+
43
+ interface.launch()