Spaces:
Build error
Build error
Rubanza Silver
commited on
Commit
·
15f6601
1
Parent(s):
ad65079
Add application files
Browse files- antelopeA.jpeg +0 -0
- antelopeB.jpeg +0 -0
- antelopeC.jpeg +0 -0
- antelopeClassifier.pkl +3 -0
- app.py +47 -0
- requirements.txt +4 -0
antelopeA.jpeg
ADDED
|
antelopeB.jpeg
ADDED
|
antelopeC.jpeg
ADDED
|
antelopeClassifier.pkl
ADDED
|
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
version https://git-lfs.github.com/spec/v1
|
| 2 |
+
oid sha256:5fc1f1326b6f9e729437e175d734b6477608c474f58ccab16837c12436c472fa
|
| 3 |
+
size 47372647
|
app.py
ADDED
|
@@ -0,0 +1,47 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
# AUTOGENERATED! DO NOT EDIT! File to edit: antelopeInference.ipynb.
|
| 2 |
+
|
| 3 |
+
# %% auto 0
|
| 4 |
+
__all__ = ['learn', 'image', 'label', 'examples', 'intf', 'classify_image']
|
| 5 |
+
|
| 6 |
+
# %% antelopeInference.ipynb 3
|
| 7 |
+
#Imports
|
| 8 |
+
|
| 9 |
+
import numpy as np # linear algebra
|
| 10 |
+
import pandas as pd # data processing, CSV file I/O (e.g. pd.read_csv)
|
| 11 |
+
|
| 12 |
+
#hide
|
| 13 |
+
#[ -e /content ]
|
| 14 |
+
#pip install -Uqq fastbook
|
| 15 |
+
|
| 16 |
+
# import fastbook
|
| 17 |
+
# fastbook.setup_book()
|
| 18 |
+
|
| 19 |
+
#hide
|
| 20 |
+
# from fastbook import *
|
| 21 |
+
# from fastai.vision.widgets import *
|
| 22 |
+
|
| 23 |
+
# pip install fastai
|
| 24 |
+
|
| 25 |
+
|
| 26 |
+
# %% antelopeInference.ipynb 4
|
| 27 |
+
from fastai.vision.all import *
|
| 28 |
+
import gradio as gr
|
| 29 |
+
|
| 30 |
+
# %% antelopeInference.ipynb 8
|
| 31 |
+
learn = load_learner('antelopeClassifier.pkl')
|
| 32 |
+
|
| 33 |
+
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')
|
| 34 |
+
|
| 35 |
+
# %% antelopeInference.ipynb 26
|
| 36 |
+
def classify_image(img):
|
| 37 |
+
pred,idx,probs = learn.predict(img)
|
| 38 |
+
return dict(zip(categories, map(float,probs)))
|
| 39 |
+
|
| 40 |
+
# %% antelopeInference.ipynb 31
|
| 41 |
+
#create gradio interface
|
| 42 |
+
image = gr.inputs.Image(shape=(128,128))
|
| 43 |
+
label = gr.outputs.Label()
|
| 44 |
+
examples = ['antelopeA.jpeg', 'antelopeB.jpeg', 'antelopeC.jpeg']
|
| 45 |
+
|
| 46 |
+
intf = gr.Interface(fn=classify_image, inputs=image, outputs=label, examples=examples )
|
| 47 |
+
intf.launch(inline=False)
|
requirements.txt
ADDED
|
@@ -0,0 +1,4 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
torch
|
| 2 |
+
fastai
|
| 3 |
+
numpy
|
| 4 |
+
pandas
|