from fastai.text.all import * import gradio as gr # Cargamos el learner learn = load_learner('export (2).pkl') # Definimos las etiquetas de nuestro modelo labels = ['0','1','2','3', '4', '5'] # Definimos una funciĆ³n que se encarga de llevar a cabo las predicciones def predict(sentence): pred,pred_idx,probs = learn.predict(sentence) return {labels[i]: float(probs[i]) for i in range(len(labels))} # Creamos la interfaz y la lanzamos. gr.Interface(fn=predict, inputs=gr.inputs.Textbox(lines=1), outputs=gr.outputs.Label(num_top_classes=3), examples=['I feel so happy today','i feel selfish and spoiled'], description='0 = sadness || 1 = joy || 2 = love || 3 = anger || 4 = fear || 5 = surprise').launch(share=False)