Spaces:
Runtime error
Runtime error
File size: 572 Bytes
fbdb406 |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 |
from transformers import AutoTokenizer, AutoModelWithLMHead
import gradio as gr
tokenizer = AutoTokenizer.from_pretrained("mrm8488/t5-base-finetuned-emotion")
model = AutoModelWithLMHead.from_pretrained("mrm8488/t5-base-finetuned-emotion")
def get_emotion(text):
input_ids = tokenizer.encode(text + '</s>', return_tensors='pt')
output = model.generate(input_ids=input_ids,max_length=2)
dec = [tokenizer.decode(ids) for ids in output]
label = dec[0]
return label.split()[1]
iface = gr.Interface(fn=get_emotion, inputs=["textbox"], outputs="text").launch()
iface |