Update app.py
Browse files
app.py
CHANGED
|
@@ -2,22 +2,17 @@ from huggingface_hub import from_pretrained_fastai
|
|
| 2 |
import gradio as gr
|
| 3 |
from fastai.text.all import *
|
| 4 |
|
| 5 |
-
|
| 6 |
-
|
| 7 |
# repo_id = "YOUR_USERNAME/YOUR_LEARNER_NAME"
|
| 8 |
-
repo_id = 'Katowise/
|
| 9 |
|
| 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 |
-
|
| 16 |
-
pred,pred_idx,probs = learner.predict(text)
|
| 17 |
-
print('ENTRO AQU脥')
|
| 18 |
return {labels[i]: float(probs[i]) for i in range(len(labels))}
|
| 19 |
|
| 20 |
-
# Creamos la interfaz y la lanzamos.
|
| 21 |
-
gr.Interface(fn=predict, inputs=gr.inputs.Textbox(lines=1), outputs=gr.outputs.Label(num_top_classes=1))
|
| 22 |
-
|
| 23 |
-
#
|
|
|
|
| 2 |
import gradio as gr
|
| 3 |
from fastai.text.all import *
|
| 4 |
|
|
|
|
|
|
|
| 5 |
# repo_id = "YOUR_USERNAME/YOUR_LEARNER_NAME"
|
| 6 |
+
repo_id = 'Katowise/nlp'
|
| 7 |
|
| 8 |
learner = from_pretrained_fastai(repo_id)
|
| 9 |
labels = learner.dls.vocab
|
| 10 |
|
| 11 |
# Definimos una funci贸n que se encarga de llevar a cabo las predicciones
|
| 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 |
+
# Creamos la interfaz y la lanzamos.
|
| 17 |
+
iface = gr.Interface(fn=predict, inputs=gr.inputs.Textbox(lines=1), outputs=gr.outputs.Label(num_top_classes=1))
|
| 18 |
+
iface.launch(share=False)
|
|
|