Spaces:
Sleeping
Sleeping
File size: 796 Bytes
d0b03cb a61d522 d0b03cb | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 | from fastai.vision.all import *
import gradio as gr
# Cargamos el learner
learn = load_learner('export.pkl')
# Definimos las etiquetas de nuestro modelo
labels = ['Negative','Neutral','Positive']
# 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=3),examples=['Some hate humanity, but I love humanity so much.','I have this old 2006 BusinessWeek framed as a reminder. The “risky bet” that Wall Street disliked was AWS, which generated revenue of more than $62 billion last year.']).launch(share=False) |