Yelp-reviews / app.py
Imran1's picture
Update app.py
5e12b87
raw
history blame
No virus
775 Bytes
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()