Spaces:
Runtime error
Runtime error
Brian Sigafoos
commited on
Commit
•
835040b
1
Parent(s):
4aabb1b
Add model notebook and app.py
Browse files- .gitignore +2 -0
- .python-version +0 -1
- app.ipynb +0 -0
- app.py +17 -4
- images/ash.jpg +0 -0
- images/chestnut.jpg +0 -0
- images/ginkgo_biloba.jpg +0 -0
- images/silver_maple.jpg +0 -0
- images/tree.jpg +0 -0
- images/willow_oak.jpg +0 -0
- model.ipynb +0 -0
- model.pkl +3 -0
- requirements.txt +2 -0
.gitignore
ADDED
@@ -0,0 +1,2 @@
|
|
|
|
|
|
|
1 |
+
.ipynb_checkpoints/
|
2 |
+
trees/
|
.python-version
DELETED
@@ -1 +0,0 @@
|
|
1 |
-
3.9
|
|
|
|
app.ipynb
ADDED
The diff for this file is too large to render.
See raw diff
|
|
app.py
CHANGED
@@ -1,7 +1,20 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
import gradio as gr
|
2 |
|
3 |
-
|
4 |
-
|
|
|
|
|
|
|
|
|
5 |
|
6 |
-
|
7 |
-
|
|
|
|
|
|
1 |
+
# AUTOGENERATED! DO NOT EDIT! File to edit: app.ipynb.
|
2 |
+
|
3 |
+
# %% auto 0
|
4 |
+
__all__ = ['learn', 'categories', 'classify_image']
|
5 |
+
|
6 |
+
# %% app.ipynb 2
|
7 |
+
from fastai.vision.all import *
|
8 |
import gradio as gr
|
9 |
|
10 |
+
# %% app.ipynb 3
|
11 |
+
learn = load_learner('model.pkl')
|
12 |
+
|
13 |
+
# %% app.ipynb 7
|
14 |
+
# NOTE: Put in alphabetical order
|
15 |
+
categories = ('ash', 'chestnut', 'ginkgo biloba', 'silver maple', 'willow oak')
|
16 |
|
17 |
+
def classify_image(img):
|
18 |
+
pred, idx, probs = learn.predict(img)
|
19 |
+
# Change each probability to a float, since Gradio doesn't support Tensors or NumPy
|
20 |
+
return dict(zip(categories, map(float, probs)))
|
images/ash.jpg
ADDED
images/chestnut.jpg
ADDED
images/ginkgo_biloba.jpg
ADDED
images/silver_maple.jpg
ADDED
images/tree.jpg
ADDED
images/willow_oak.jpg
ADDED
model.ipynb
ADDED
The diff for this file is too large to render.
See raw diff
|
|
model.pkl
ADDED
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
1 |
+
version https://git-lfs.github.com/spec/v1
|
2 |
+
oid sha256:f040356bc64b3b08d0804b78d6e662e55225f73073ec7a5506dc8192bf9f8bba
|
3 |
+
size 46964477
|
requirements.txt
ADDED
@@ -0,0 +1,2 @@
|
|
|
|
|
|
|
1 |
+
fastai
|
2 |
+
scikit-image
|