import gradio as gr from fastai.vision.all import * def is_cat(x): return x[0].isupper() learn_inf = load_learner('DogCat.pkl') labels = learn_inf.dls.vocab labels = ['Cat', 'Not_cat'] def predict(img): img = PILImage.create(img) pred, pred_idx, probs = learn_inf.predict(img) # Check if the prediction is "Cat" and return the appropriate string if pred == 'Cat': return "Yes, this is a cat" else: return "No, this is not a cat" title = "Is this image of a cat?" iface = gr.Interface(fn=predict, inputs=gr.inputs.Image(shape=(512,512)), outputs=gr.outputs.Label(num_top_classes=2), title=title) iface.launch()