from fastai.vision.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(string): print(learn.predict(string)) pred,pred_idx,probs = learn.predict(string) 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=['it was so annoying to watch the president','I am so glad to see you'], title="Natural Language Model to classify the feelings of a message", description="This model has been trained with messages obtained from Twitter. Its purpose is to classify the possible feelings that a message might express. The labels obtained have the following meaning:\n 0: anger\n 1: joy\n 2: optimism\n 3: sadness").launch(share=False)