pip install toml from huggingface_hub import from_pretrained_fastai import gradio as gr from fastai.vision.all import * repo_id = "laaraap/anomaly-detection-using-autoencoders" learner = from_pretrained_fastai(repo_id) labels = learner.dls.vocab # Definimos una funciĆ³n que se encarga de llevar a cabo las predicciones def predict(img): #img = PILImage.create(img) pred = learner.predict(img) mse = np.mean((img - pred) ** 2) thresh = 0.02767541486024857 if mse >= thresh: label = 'anomaly' else: label = 'not anomaly' return label # Creamos la interfaz y la lanzamos. gr.Interface(fn=predict, inputs=gr.inputs.Image(shape=(128, 128)), outputs=label, examples=['uno.png','tres.png']).launch(share=False)