SeyedAli's picture
Update app.py
c4cc2f7
raw
history blame
656 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')
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)