changes
Browse files- app.py +3 -4
- requirements.txt +2 -1
app.py
CHANGED
@@ -1,6 +1,7 @@
|
|
1 |
import gradio as gr
|
2 |
from transformers import AutoModelForSequenceClassification, AutoTokenizer
|
3 |
import torch
|
|
|
4 |
|
5 |
model_name = "Bittar/outputs"
|
6 |
model = AutoModelForSequenceClassification.from_pretrained(model_name)
|
@@ -17,15 +18,13 @@ def predict(text):
|
|
17 |
outputs = model(**inputs)
|
18 |
predictions = outputs.logits
|
19 |
|
20 |
-
return mapping[
|
21 |
|
22 |
iface = gr.Interface(
|
23 |
fn=predict,
|
24 |
inputs="text",
|
25 |
outputs="text",
|
26 |
-
layout="vertical"
|
27 |
-
title="Classificador de emoções em uma frase",
|
28 |
-
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"
|
29 |
)
|
30 |
|
31 |
iface.launch(share=True)
|
|
|
1 |
import gradio as gr
|
2 |
from transformers import AutoModelForSequenceClassification, AutoTokenizer
|
3 |
import torch
|
4 |
+
import numpy as np
|
5 |
|
6 |
model_name = "Bittar/outputs"
|
7 |
model = AutoModelForSequenceClassification.from_pretrained(model_name)
|
|
|
18 |
outputs = model(**inputs)
|
19 |
predictions = outputs.logits
|
20 |
|
21 |
+
return mapping[predictions.argmax()]
|
22 |
|
23 |
iface = gr.Interface(
|
24 |
fn=predict,
|
25 |
inputs="text",
|
26 |
outputs="text",
|
27 |
+
layout="vertical"
|
|
|
|
|
28 |
)
|
29 |
|
30 |
iface.launch(share=True)
|
requirements.txt
CHANGED
@@ -1,3 +1,4 @@
|
|
1 |
gradio
|
2 |
transformers
|
3 |
-
torch
|
|
|
|
1 |
gradio
|
2 |
transformers
|
3 |
+
torch
|
4 |
+
numpy
|