Team Ai
Apppublic

aditya0701/Bear_Classifier_With_Multilabel_Classification

sourceHugging Faceapache-2.0updated 3y agoView on Hugging Face
0likes
app.py48 linesDownload Raw Back to root
1# AUTOGENERATED! DO NOT EDIT! File to edit: Bear_gradio_app.ipynb.2 3# %% auto 04__all__ = ['plt', 'path', 'learn', 'image', 'label', 'examples', 'intf', 'is_Bear', 'show_predict']5 6# %% Bear_gradio_app.ipynb 17from fastai.vision.all import *8import gradio as gr9import platform10 11def is_Bear(x): return x[0].isupper()12 13# %% Bear_gradio_app.ipynb 214import pathlib15plt = platform.system()16if plt != 'Windows':17    pathlib.WindowsPath  = pathlib.PosixPath18path  = Path('images_to_test/')19 20# %% Bear_gradio_app.ipynb 421learn = load_learner('model.pkl')22 23# %% Bear_gradio_app.ipynb 624def show_predict(img):25    l = learn.predict(img)26    if l[0] == ['a','d','n','p']:27        res = 'Panda bear'28    elif l[0] == ['g','i','l','r','y','z']:29        res = 'Grizzly Bear'30    elif l[0] == ['d','e','t','y']:31        res = 'Teddy Bear'32    elif l[0] == ['a','l','o','p','r']:33        res = 'Polar Bear'34    elif l[0] == ['a','b','c','k','l']:35        res = 'Black Bear'36    else:37        res = "Not a Bear"38    return res39 40# %% Bear_gradio_app.ipynb 841image = gr.Image(shape=(192,192))42label = gr.Label()43examples = [path/'polar1.jpg', path/'griz.jpg',path/'donno.jpg',path/'black.jpg',path/'panda1.jpg',path/'images.jpg',path/'polar2.jpg',path/'many_mug.jpg']44 45intf = gr.Interface(fn=show_predict, inputs=image, outputs=label, examples=examples,46                   title = "Bear Classifier Using Multilabel Classification")47intf.launch(inline = False)48