ciro-c commited on
Commit
00bb16c
·
1 Parent(s): efad75f

Space launch

Browse files
Files changed (2) hide show
  1. app.py +35 -0
  2. requirements.txt +3 -0
app.py ADDED
@@ -0,0 +1,35 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import gradio as gr
2
+ from transformers import AutoModelForSequenceClassification, AutoTokenizer
3
+ import torch
4
+
5
+ model_name = "ciro-c/emobot"
6
+ model = AutoModelForSequenceClassification.from_pretrained(model_name)
7
+ tokenizer = AutoTokenizer.from_pretrained(model_name)
8
+
9
+ mapping = {
10
+ 3:'raiva',
11
+ 4:'medo',
12
+ 1:'alegria',
13
+ 2:'amor',
14
+ 0:'tristeza',
15
+ 5:'surpresa'
16
+ }
17
+
18
+ def predict(text):
19
+ inputs = tokenizer(text, return_tensors="pt")
20
+
21
+ outputs = model(**inputs)
22
+ predictions = outputs.logits
23
+
24
+ return mapping[round(predictions.item())]
25
+
26
+ iface = gr.Interface(
27
+ title="Identificador de emoções em uma frase",
28
+ 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 "
29
+ fn=predict,
30
+ inputs="text",
31
+ layout="vertical",
32
+ outputs="text",
33
+ )
34
+
35
+ iface.launch(share=True)
requirements.txt ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ gradio
2
+ transformers
3
+ torch