from huggingface_hub import from_pretrained_fastai from fastai.text.all import * import gradio as gr # Cargamos el learner learner = from_pretrained_fastai('DavidVarona/review') # Definimos las etiquetas de nuestro modelo labels = ['0','1'] example1 = "This film is the worst I have seen in my whole life." example2 = "Really interesting. I liked it a lot." example3 = "I didn't like the ending,." # Definimos una función que se encarga de llevar a cabo las predicciones def predict(text): pred,pred_idx, probs = learner.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.Label(),examples=[example1,example2,example3]).launch(share=False)