Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
@@ -10,10 +10,13 @@ repo_id = "mabakaik/clasificadorTexto"
|
|
10 |
learner = from_pretrained_fastai(repo_id)
|
11 |
labels = learner.dls.vocab
|
12 |
|
|
|
|
|
|
|
13 |
# Definimos una funci贸n que se encarga de llevar a cabo las predicciones
|
14 |
def predict(text):
|
15 |
pred, pred_idx, probs = learner.predict(text)
|
16 |
-
return {labels[i]: float(probs[i]) for i in range(len(labels))}
|
17 |
|
18 |
# Creamos la interfaz y la lanzamos.
|
19 |
gr.Interface(fn=predict, inputs=gr.inputs.Textbox(lines=5, placeholder="Introduce tu texto aqu铆..."),
|
|
|
10 |
learner = from_pretrained_fastai(repo_id)
|
11 |
labels = learner.dls.vocab
|
12 |
|
13 |
+
if isinstance(labels, list) and all(isinstance(label, list) for label in labels):
|
14 |
+
labels = [item for sublist in labels for item in sublist]
|
15 |
+
|
16 |
# Definimos una funci贸n que se encarga de llevar a cabo las predicciones
|
17 |
def predict(text):
|
18 |
pred, pred_idx, probs = learner.predict(text)
|
19 |
+
return {str(labels[i]): float(probs[i]) for i in range(len(labels))}
|
20 |
|
21 |
# Creamos la interfaz y la lanzamos.
|
22 |
gr.Interface(fn=predict, inputs=gr.inputs.Textbox(lines=5, placeholder="Introduce tu texto aqu铆..."),
|