Initial commit
Browse files- .gitattributes +1 -0
- .gitignore +1 -0
- README.md +3 -3
- app.py +9 -0
- bird.jpg +0 -0
- bird_classifier.py +42 -0
- model.pkl +3 -0
- requirements.txt +1 -0
.gitattributes
CHANGED
@@ -29,3 +29,4 @@ saved_model/**/* filter=lfs diff=lfs merge=lfs -text
|
|
29 |
*.zip filter=lfs diff=lfs merge=lfs -text
|
30 |
*.zst filter=lfs diff=lfs merge=lfs -text
|
31 |
*tfevents* filter=lfs diff=lfs merge=lfs -text
|
|
29 |
*.zip filter=lfs diff=lfs merge=lfs -text
|
30 |
*.zst filter=lfs diff=lfs merge=lfs -text
|
31 |
*tfevents* filter=lfs diff=lfs merge=lfs -text
|
32 |
+
model.pkl filter=lfs diff=lfs merge=lfs -text
|
.gitignore
ADDED
@@ -0,0 +1 @@
|
|
|
1 |
+
.history/**
|
README.md
CHANGED
@@ -1,8 +1,8 @@
|
|
1 |
---
|
2 |
title: Bird
|
3 |
-
emoji:
|
4 |
-
colorFrom:
|
5 |
-
colorTo:
|
6 |
sdk: gradio
|
7 |
sdk_version: 3.3.1
|
8 |
app_file: app.py
|
1 |
---
|
2 |
title: Bird
|
3 |
+
emoji: 🏢
|
4 |
+
colorFrom: red
|
5 |
+
colorTo: purple
|
6 |
sdk: gradio
|
7 |
sdk_version: 3.3.1
|
8 |
app_file: app.py
|
app.py
ADDED
@@ -0,0 +1,9 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
from bird_classifier import *
|
2 |
+
import gradio as gr
|
3 |
+
|
4 |
+
iface = gr.Interface(fn=classify_image,
|
5 |
+
inputs=gr.Image(shape=(256,256)),
|
6 |
+
outputs=gr.Label(),
|
7 |
+
examples=['bird.jpg'])
|
8 |
+
|
9 |
+
iface.launch(share=False)
|
bird.jpg
ADDED
bird_classifier.py
ADDED
@@ -0,0 +1,42 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
# ---
|
2 |
+
# jupyter:
|
3 |
+
# jupytext:
|
4 |
+
# cell_metadata_filter: -all
|
5 |
+
# custom_cell_magics: kql
|
6 |
+
# text_representation:
|
7 |
+
# extension: .py
|
8 |
+
# format_name: percent
|
9 |
+
# format_version: '1.3'
|
10 |
+
# jupytext_version: 1.11.2
|
11 |
+
# kernelspec:
|
12 |
+
# display_name: Python 3.9.14 64-bit
|
13 |
+
# language: python
|
14 |
+
# name: python3
|
15 |
+
# ---
|
16 |
+
|
17 |
+
# %%
|
18 |
+
from fastai.vision.all import *
|
19 |
+
|
20 |
+
# %%
|
21 |
+
learn = load_learner("model.pkl")
|
22 |
+
|
23 |
+
# %%
|
24 |
+
categories = ("Bird", "Forest")
|
25 |
+
|
26 |
+
# %%
|
27 |
+
def classify_image(img):
|
28 |
+
pred,idx,probs = learn.predict(img)
|
29 |
+
print(probs)
|
30 |
+
print(*map(float,probs))
|
31 |
+
print(*zip(categories, map(float,probs)))
|
32 |
+
print(dict(zip(categories, map(float,probs))))
|
33 |
+
return dict(zip(categories, map(float,probs)))
|
34 |
+
|
35 |
+
# %% [markdown]
|
36 |
+
#
|
37 |
+
# im = PILImage.create("bird.jpg")
|
38 |
+
# im.to_thumb(256, 256)
|
39 |
+
# im
|
40 |
+
|
41 |
+
# %% [markdown]
|
42 |
+
# classify_image(im)
|
model.pkl
ADDED
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
1 |
+
version https://git-lfs.github.com/spec/v1
|
2 |
+
oid sha256:93ffba4b49318812ed7d8763a4ffc607634f8d2ba94a573ec4a82190e9c73a4f
|
3 |
+
size 46959791
|
requirements.txt
ADDED
@@ -0,0 +1 @@
|
|
|
1 |
+
fastai
|