Practica2 / app.py
pasanzg's picture
Update app.py
c85d773
raw
history blame contribute delete
666 Bytes
from fastai.text.all import *
import gradio as gr
# Cargamos el learner
learn = load_learner('export.pkl')
# Definimos las etiquetas de nuestro modelo
labels = [0,1,2,3]
# Definimos una función que se encarga de llevar a cabo las predicciones
def predict(text):
pred,pred_idx,probs = learn.predict(text)
return {labels[i]: float(probs[i]) for i in range(len(labels))}
# Creamos la interfaz y la lanzamos.
gr.Interface(fn=predict, inputs=gr.Textbox(), outputs=gr.outputs.Label(num_top_classes=4),examples=['what do you mean ? it will help us to relax .','you know that is tempting but is really not good for our fitness .']).launch(share=False)