Spaces:
Runtime error
Runtime error
File size: 1,005 Bytes
00bb16c 758feb9 00bb16c 6416ff3 00bb16c 6416ff3 00bb16c |
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 27 28 29 30 31 32 33 34 35 36 37 |
import gradio as gr
from transformers import AutoModelForSequenceClassification, AutoTokenizer
import torch
model_name = "ciro-c/emobot"
model = AutoModelForSequenceClassification.from_pretrained(model_name)
tokenizer = AutoTokenizer.from_pretrained(model_name)
mapping = {
3:'raiva',
4:'medo',
1:'alegria',
2:'amor',
0:'tristeza',
5:'surpresa'
}
def predict(text):
inputs = tokenizer(text, return_tensors="pt")
outputs = model(**inputs)
predictions = outputs.logits
result = predictions.item()
result = max(result, 0)
result = min(result, 5)
return mapping[round(result)]
iface = gr.Interface(
title="Identificador de emoções em uma frase",
description="Esse modelo foi treinado com o objetivo de identificar a emoção de uma frase escrita em inglês. Ele identifica 6 emoções raiva, medo, alegria , amor, tristeza e surpresa ",
fn=predict,
inputs="text",
layout="vertical",
outputs="text"
)
iface.launch(share=True) |