Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
|
@@ -6,18 +6,17 @@ from fastai.text.all import *
|
|
| 6 |
# Carga el learner desde HuggingFace
|
| 7 |
learner = from_pretrained_fastai("paquinon/entregable3")
|
| 8 |
|
| 9 |
-
|
|
|
|
| 10 |
|
| 11 |
-
# Funci贸n para predecir etiqueta y probabilidades
|
| 12 |
def predict(text):
|
| 13 |
pred, pred_idx, probs = learner.predict(text)
|
| 14 |
return {labels[i]: float(probs[i]) for i in range(len(labels))}
|
| 15 |
|
| 16 |
-
# Interfaz Gradio
|
| 17 |
gr.Interface(
|
| 18 |
-
fn=predict,
|
| 19 |
-
inputs=gr.Textbox(lines=4, placeholder="Escribe el texto aqu铆..."),
|
| 20 |
outputs=gr.Label(num_top_classes=len(labels)),
|
| 21 |
-
title="Clasificador de
|
| 22 |
-
description="Introduce un texto para predecir su
|
| 23 |
).launch(share=False)
|
|
|
|
| 6 |
# Carga el learner desde HuggingFace
|
| 7 |
learner = from_pretrained_fastai("paquinon/entregable3")
|
| 8 |
|
| 9 |
+
learner = from_pretrained_fastai(repo_id)
|
| 10 |
+
labels = learner.dls.vocab
|
| 11 |
|
|
|
|
| 12 |
def predict(text):
|
| 13 |
pred, pred_idx, probs = learner.predict(text)
|
| 14 |
return {labels[i]: float(probs[i]) for i in range(len(labels))}
|
| 15 |
|
|
|
|
| 16 |
gr.Interface(
|
| 17 |
+
fn=predict,
|
| 18 |
+
inputs=gr.Textbox(lines=4, placeholder="Escribe el texto aqu铆..."),
|
| 19 |
outputs=gr.Label(num_top_classes=len(labels)),
|
| 20 |
+
title="Clasificador de opniones de peliculas",
|
| 21 |
+
description="Introduce un texto para predecir su opinion."
|
| 22 |
).launch(share=False)
|