from huggingface_hub import from_pretrained_fastai import gradio as gr from fastai.vision.all import * # repo_id = "YOUR_USERNAME/YOUR_LEARNER_NAME" repo_id = "mapecim/ClasificadorTexto" learner = from_pretrained_fastai(repo_id) # Definimos una función que se encarga de llevar a cabo las predicciones def predict(text): pred,pred_idx,probs = learner.predict(text) if (pred == "0"): return "Negative" elif (pred == "1"): return "Positive" else: return "Error" # Creamos la interfaz y la lanzamos. gr.Interface(fn=predict, inputs="text", outputs="label", examples=["I loved that movie", "I hated that movie"]).launch()