Spaces:
Build error
Build error
burakgorduk
commited on
Commit
•
3d514fa
1
Parent(s):
2674c1a
Upload 2 files
Browse files
app.py
ADDED
@@ -0,0 +1,22 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
from fastai.vision.all import *
|
2 |
+
import gradio as gr
|
3 |
+
import pathlib
|
4 |
+
|
5 |
+
plt = platform.system()
|
6 |
+
if plt == 'Linux': pathlib.WindowsPath = pathlib.PosixPath
|
7 |
+
|
8 |
+
file = open('model.pkl', 'rb')
|
9 |
+
temp = pickle.load(file)
|
10 |
+
file.close()
|
11 |
+
|
12 |
+
infer = temp['model']
|
13 |
+
data_map = [f'{item["name"]} ({item["botanical_name"]})' for item in temp['map']]
|
14 |
+
|
15 |
+
def classify(img):
|
16 |
+
_, _, probs = infer.predict(img)
|
17 |
+
return dict(map(lambda x: (data_map[int(infer.dls.vocab[x[0]])], float(x[1])), enumerate(probs)))
|
18 |
+
|
19 |
+
image = gr.inputs.Image(shape=(224, 224))
|
20 |
+
label = gr.outputs.Label(num_top_classes=3)
|
21 |
+
iface = gr.Interface(fn=classify, title='Indoor Plant Classifier', inputs=image, outputs=label)
|
22 |
+
iface.launch()
|
model.pkl
ADDED
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
1 |
+
version https://git-lfs.github.com/spec/v1
|
2 |
+
oid sha256:eba9ccb36ff60c1b977aff8346d5f13eae20ff851e23e76af42bea6531111569
|
3 |
+
size 355617495
|