achyutha11/basic_cat_classifier
0
1 2__all__ = ['is_cat', 'learn', 'classify_image', 'categories', 'image', 'label', 'examples', 'intf']3 4# Cell5from fastai.vision.all import *6import gradio as gr7 8def is_cat(x):9 return x[0].isupper()10 11# Cell12learn = load_learner("cat_classifier_model.pkl")13 14# Cell15categories = ("Dog", "Cat")16 17def classify_img(img):18 pred, index, probs = learn.predict(img)19 return dict(zip(categories, map(float, probs)))20 21# Cell22image = gr.inputs.Image(shape=(192, 192))23label = gr.outputs.Label()24examples = ['KOA_Nassau_2697x1517.jpg', 'beautiful-smooth-haired-red-cat-lies-on-the-sofa-royalty-free-image-1678488026.jpg']25 26intf = gr.Interface(fn=classify_img, inputs=image, outputs=label, examples=examples)27intf.launch(inline=False)28 