from fastai.vision.all import * import gradio as gr # Cargamos el learner learn = load_learner('export.pkl') # Definimos las etiquetas de nuestro modelo labels = ['World','Sports','Business ','Sci/Tech'] # 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=['the Ukraine war still holds surprises','Rafa Nadal has won Roland Garros', 'Benchmarks likewise rose in Tokyo, Seoul and Sydney. Shanghai declined. Oil prices remained near $120 per barrel.','What experts told me to do after my positive COVID-19 at-home test']).launch(share=False)