Spaces:
Build error
Build error
| # AUTOGENERATED! DO NOT EDIT! File to edit: antelopeInference.ipynb. | |
| # %% auto 0 | |
| __all__ = ['learn', 'image', 'label', 'examples', 'intf', 'classify_image'] | |
| # %% antelopeInference.ipynb 3 | |
| #Imports | |
| import numpy as np # linear algebra | |
| import pandas as pd # data processing, CSV file I/O (e.g. pd.read_csv) | |
| #hide | |
| #[ -e /content ] | |
| #pip install -Uqq fastbook | |
| # import fastbook | |
| # fastbook.setup_book() | |
| #hide | |
| # from fastbook import * | |
| # from fastai.vision.widgets import * | |
| # pip install fastai | |
| # %% antelopeInference.ipynb 4 | |
| from fastai.vision.all import * | |
| import gradio as gr | |
| # %% antelopeInference.ipynb 8 | |
| learn = load_learner('antelopeClassifier.pkl') | |
| categories = ('Eland', 'Greater Kudu', 'Hartebeest', 'Oryx', 'Defassa Waterbuck', 'Sitatunga', 'Impala ', 'The lesser Kudu', 'Grant’s Gazelle','Reedbuck','Uganda Kob','Forest duiker','Harvery’s red duiker', 'Blue duiker', 'Peter’s duiker','Black fronted duiker','Grey duiker','Oribi','Klipspringer','Guenther’s') | |
| # %% antelopeInference.ipynb 26 | |
| def classify_image(img): | |
| pred,idx,probs = learn.predict(img) | |
| return dict(zip(categories, map(float,probs))) | |
| # %% antelopeInference.ipynb 31 | |
| #create gradio interface | |
| image = gr.inputs.Image(shape=(128,128)) | |
| label = gr.outputs.Label() | |
| examples = ['antelopeA.jpeg', 'antelopeB.jpeg', 'antelopeC.jpeg'] | |
| title = "East African Antelope classifier" | |
| description = "A deep learning based image classifier that tells you what breed of antelope is in a picture" | |
| interpretation = "default" | |
| intf = gr.Interface(fn=classify_image, inputs=image, outputs=label, examples=examples, title=title, description=description, interpretation=interpretation) | |
| intf.launch(inline=False) | |