practica7 / app.py
blancamartin's picture
Create app.py
406d0cc
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)