Spaces:
Runtime error
Runtime error
Create app.py
Browse files
app.py
ADDED
|
@@ -0,0 +1,22 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
from huggingface_hub import from_pretrained_fastai
|
| 2 |
+
from fastai.text.all import *
|
| 3 |
+
import gradio as gr
|
| 4 |
+
|
| 5 |
+
repo_id = "Unax14/entregable3"
|
| 6 |
+
|
| 7 |
+
learner = from_pretrained_fastai(repo_id)
|
| 8 |
+
labels = learner.dls.vocab
|
| 9 |
+
|
| 10 |
+
|
| 11 |
+
def predict(text):
|
| 12 |
+
pred, pred_idx, probs = learner.predict(text)
|
| 13 |
+
return {labels[i]: float(probs[i]) for i in range(len(labels))}
|
| 14 |
+
|
| 15 |
+
|
| 16 |
+
gr.Interface(
|
| 17 |
+
fn=predict,
|
| 18 |
+
inputs=gr.Textbox(lines=3, placeholder="Escribe una frase que exprese un sentimiento..."),
|
| 19 |
+
outputs=gr.Label(num_top_classes=3),
|
| 20 |
+
title="Clasificador de emociones",
|
| 21 |
+
description="Introduce la frase:"
|
| 22 |
+
).launch()
|