File size: 775 Bytes
7614461
087c8b3
5e12b87
08c1e77
5e12b87
08c1e77
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
f7fcbb2
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
from transformers import AutoTokenizer, AutoModelForSequenceClassification

tokenizer = AutoTokenizer.from_pretrained("Imran1/sentimen_analysis_yelp") 

model = AutoModelForSequenceClassification.from_pretrained("Imran1/sentimen_analysis_yelp")

from transformers import pipeline
Data= pipeline("text-classification", model=model, tokenizer=tokenizer,top_k=5)



Label=[]
Score=[]
def sentiment(text):
    data = Data(text)[0]
    for i in range (5):
        L=data[i]["label"]
        S=data[i]["score"]
        Label.append(L)
        Score.append(S)
    return dict(zip(Label,Score))

import gradio as gr
exmp=["the food is not good.","oh I really love this food "]

gr.Interface(fn=sentiment, inputs="text", outputs="label", examples=exmp,title= "Yelp reviews").launch()