File size: 609 Bytes
406d0cc
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
import pandas as pd
from fastai.text.all import *
from datasets import load_dataset

import gradio as gr


# Cargamos el learner
learn = load_learner('export-2.pkl')

# Definimos las etiquetas de nuestro modelo
labels = learn.dls.vocab


# Definimos una función que se encarga de llevar a cabo las predicciones
def predict(text):
    #img = PILImage.create(img)
    pred,pred_idx,probs = learn.predict(text)
    return pred
    
# Creamos la interfaz y la lanzamos. 
gr.Interface(fn=predict, inputs="text", outputs="text",examples=['I will go to see him without telling him about it--.']).launch(share=False)