Update app.py
Browse files
app.py
CHANGED
|
@@ -7,13 +7,13 @@ from fastai.text.all import *
|
|
| 7 |
repo_id = "inigo99/rotten_tomatoes-classification"
|
| 8 |
|
| 9 |
learner = from_pretrained_fastai(repo_id)
|
|
|
|
| 10 |
|
| 11 |
# Definimos una función que se encarga de llevar a cabo las predicciones
|
| 12 |
def predict(text):
|
| 13 |
-
|
| 14 |
-
|
| 15 |
-
return pred
|
| 16 |
|
| 17 |
# Creamos la interfaz y la lanzamos.
|
| 18 |
-
gr.Interface(fn=predict, inputs=gr.inputs.Textbox(), outputs=
|
| 19 |
|
|
|
|
| 7 |
repo_id = "inigo99/rotten_tomatoes-classification"
|
| 8 |
|
| 9 |
learner = from_pretrained_fastai(repo_id)
|
| 10 |
+
labels = learner.dls.vocab
|
| 11 |
|
| 12 |
# Definimos una función que se encarga de llevar a cabo las predicciones
|
| 13 |
def predict(text):
|
| 14 |
+
pred, pred_idx,probs = learner.predict(text)
|
| 15 |
+
return {labels[i]: float(probs[i]) for i in range(len(labels))}
|
|
|
|
| 16 |
|
| 17 |
# Creamos la interfaz y la lanzamos.
|
| 18 |
+
gr.Interface(fn=predict, inputs=gr.inputs.Textbox(), outputs=gr.outputs.Label(num_top_classes=2)).launch(share=False)
|
| 19 |
|