SeyedAli's picture
Update app.py
1f45a5d verified
raw
history blame
679 Bytes
import gradio as gr
import torch
from transformers import AutoModelForSequenceClassification,AutoTokenizer,pipeline
model = AutoModelForSequenceClassification.from_pretrained('SeyedAli/Persian-Text-Sentiment-Bert-V1')
tokenizer = AutoTokenizer.from_pretrained('SeyedAli/Persian-Text-Sentiment-Bert-V1',add_special_token=True)
def Sentiment(text):
pipline = pipeline(task="text-classification", model=model, tokenizer=tokenizer)
preds=pipline(text)
# return output
outputs = {}
for p in preds:
outputs[p["label"]] = p["score"]
return outputs
iface = gr.Interface(fn=Sentiment, inputs="text", outputs=gr.outputs.Label())
iface.launch(share=False)