from huggingface_hub import from_pretrained_fastai import gradio as gr from fastai.vision.all import * repo_id = "saruizn/entregable3" learner = from_pretrained_fastai(repo_id) #labels = learner.dls.vocab labels = ['Actualidad','Deportes','Negocios','Ciencia/tecnologĂ­a'] def predict(txt): pred,pred_idx,probs = learner.predict(txt) return {labels[i]: float(probs[i]) for i in range(len(labels))} ejemploActualidad="An Elusive Peace in Najaf The standoff is driven by Moqtada Sadr's political ambitions. But how good is his poker game?" ejemploDeportes="Rathbone is #39;like Gregan #39; AUSTRALIAN coach Eddie Jones rates winger Clyde Rathbone a potential successor to Wallaby captain George Gregan as the pair reach Test career milestones tonight against South Africa in Durban. " ejemploNegocios="Kmart #39;s store sales might cost jobs Report: Retailer could terminate as many as 1,200 positions stemming from stores sold to Home Depot. " ejemploCiencia="RealNetworks Doesn #39;t Rock NEW YORK - It #39;s never a smart move to pick a public fight with Apple Computer, and it #39;s doubly unwise if that fight involves the iPod in some way. " # Creamos la interfaz y la lanzamos. gr.Interface(fn=predict, inputs="text", outputs=gr.outputs.Label(num_top_classes=3),examples=[ejemploActualidad,ejemploDeportes,ejemploNegocios,ejemploCiencia]).launch(share=False)