Imran1 commited on
Commit
08c1e77
1 Parent(s): c8964d7

Create app.py

Browse files
Files changed (1) hide show
  1. app.py +26 -0
app.py ADDED
@@ -0,0 +1,26 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ from transformers import AutoTokenizer, AutoModelForSequenceClassification
2
+
3
+ tokenizer = AutoTokenizer.from_pretrained("Imran1/sentimen_analysis_yelp")
4
+
5
+ model = AutoModelForSequenceClassification.from_pretrained("Imran1/sentimen_analysis_yelp")
6
+
7
+ from transformers import pipeline
8
+ Data= pipeline("text-classification", model=model, tokenizer=tokenizer,top_k=5)
9
+
10
+
11
+
12
+ Label=[]
13
+ Score=[]
14
+ def sentiment(text):
15
+ data = Data(text)[0]
16
+ for i in range (5):
17
+ L=data[i]["label"]
18
+ S=data[i]["score"]
19
+ Label.append(L)
20
+ Score.append(S)
21
+ return dict(zip(Label,Score))
22
+
23
+ import gradio as gr
24
+ exmp=["the food is not good.","oh I really love this food "]
25
+
26
+ gr.Interface(fn=sentiment, inputs="text", outputs="label", examples=exmp,title= "Yelp reviews").launch()