rafaelcarvalhoj commited on
Commit
dbdf1b7
·
1 Parent(s): 9af05a6

Delete app.py.txt

Browse files
Files changed (1) hide show
  1. app.py.txt +0 -32
app.py.txt DELETED
@@ -1,32 +0,0 @@
1
- import gradio as gr
2
- from transformers import AutoModelForSequenceClassification, AutoTokenizer
3
- import torch
4
-
5
- model_name = "rafaelcarvalhoj/emotion-classifier"
6
- model = AutoModelForSequenceClassification.from_pretrained(model_name)
7
- tokenizer = AutoTokenizer.from_pretrained(model_name)
8
-
9
- mapping = {
10
- 0: 'anger',
11
- 1: 'joy',
12
- 2: 'fear'
13
- }
14
-
15
- def predict(text):
16
- inputs = tokenizer(text, return_tensors="pt")
17
-
18
- outputs = model(**inputs)
19
- predictions = outputs.logits
20
-
21
- return mapping[round(predictions.item())]
22
-
23
- iface = gr.Interface(
24
- fn=predict,
25
- inputs="text",
26
- outputs="text",
27
- layout="vertical",
28
- title="Classificador de emoções em uma frase",
29
- description="Este modelo analisa uma frase em inglês e diz qual sentimento mais se aproxima da frase apresentada. A frase pode ser classificada em Joy, Anger e Fear"
30
- )
31
-
32
- iface.launch(share=True)