Spaces:
Runtime error
Runtime error
init
Browse files- app.py +26 -0
- categories.json +104 -0
- model.pkl +3 -0
- requirements.txt +1 -0
app.py
ADDED
@@ -0,0 +1,26 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
import gradio as gr
|
2 |
+
from fastai.vision.all import *
|
3 |
+
import json
|
4 |
+
|
5 |
+
def is_cat(x): return x[0].isupper()
|
6 |
+
|
7 |
+
|
8 |
+
learn = load_learner('model.pkl')
|
9 |
+
|
10 |
+
with open('categories.json', 'r') as f:
|
11 |
+
labels = json.load(f)
|
12 |
+
|
13 |
+
def predict(img):
|
14 |
+
img = PILImage.create(img)
|
15 |
+
pred,pred_idx,probs = learn.predict(img)
|
16 |
+
return {labels[str(i)]: float(probs[i]) for i in range(len(labels))}
|
17 |
+
|
18 |
+
|
19 |
+
title = "Predict flower species"
|
20 |
+
|
21 |
+
gr.Interface(
|
22 |
+
fn=predict,
|
23 |
+
inputs=gr.inputs.Image(shape=(512, 512)),
|
24 |
+
outputs=gr.outputs.Label(num_top_classes=len(labels)),
|
25 |
+
title=title
|
26 |
+
).launch()
|
categories.json
ADDED
@@ -0,0 +1,104 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
{
|
2 |
+
"21": "fire lily",
|
3 |
+
"3": "canterbury bells",
|
4 |
+
"45": "bolero deep blue",
|
5 |
+
"1": "pink primrose",
|
6 |
+
"34": "mexican aster",
|
7 |
+
"27": "prince of wales feathers",
|
8 |
+
"7": "moon orchid",
|
9 |
+
"16": "globe-flower",
|
10 |
+
"25": "grape hyacinth",
|
11 |
+
"26": "corn poppy",
|
12 |
+
"79": "toad lily",
|
13 |
+
"39": "siam tulip",
|
14 |
+
"24": "red ginger",
|
15 |
+
"67": "spring crocus",
|
16 |
+
"35": "alpine sea holly",
|
17 |
+
"32": "garden phlox",
|
18 |
+
"10": "globe thistle",
|
19 |
+
"6": "tiger lily",
|
20 |
+
"93": "ball moss",
|
21 |
+
"33": "love in the mist",
|
22 |
+
"9": "monkshood",
|
23 |
+
"102": "blackberry lily",
|
24 |
+
"14": "spear thistle",
|
25 |
+
"19": "balloon flower",
|
26 |
+
"100": "blanket flower",
|
27 |
+
"13": "king protea",
|
28 |
+
"49": "oxeye daisy",
|
29 |
+
"15": "yellow iris",
|
30 |
+
"61": "cautleya spicata",
|
31 |
+
"31": "carnation",
|
32 |
+
"64": "silverbush",
|
33 |
+
"68": "bearded iris",
|
34 |
+
"63": "black-eyed susan",
|
35 |
+
"69": "windflower",
|
36 |
+
"62": "japanese anemone",
|
37 |
+
"20": "giant white arum lily",
|
38 |
+
"38": "great masterwort",
|
39 |
+
"4": "sweet pea",
|
40 |
+
"86": "tree mallow",
|
41 |
+
"101": "trumpet creeper",
|
42 |
+
"42": "daffodil",
|
43 |
+
"22": "pincushion flower",
|
44 |
+
"2": "hard-leaved pocket orchid",
|
45 |
+
"54": "sunflower",
|
46 |
+
"66": "osteospermum",
|
47 |
+
"70": "tree poppy",
|
48 |
+
"85": "desert-rose",
|
49 |
+
"99": "bromelia",
|
50 |
+
"87": "magnolia",
|
51 |
+
"5": "english marigold",
|
52 |
+
"92": "bee balm",
|
53 |
+
"28": "stemless gentian",
|
54 |
+
"97": "mallow",
|
55 |
+
"57": "gaura",
|
56 |
+
"40": "lenten rose",
|
57 |
+
"47": "marigold",
|
58 |
+
"59": "orange dahlia",
|
59 |
+
"48": "buttercup",
|
60 |
+
"55": "pelargonium",
|
61 |
+
"36": "ruby-lipped cattleya",
|
62 |
+
"91": "hippeastrum",
|
63 |
+
"29": "artichoke",
|
64 |
+
"71": "gazania",
|
65 |
+
"90": "canna lily",
|
66 |
+
"18": "peruvian lily",
|
67 |
+
"98": "mexican petunia",
|
68 |
+
"8": "bird of paradise",
|
69 |
+
"30": "sweet william",
|
70 |
+
"17": "purple coneflower",
|
71 |
+
"52": "wild pansy",
|
72 |
+
"84": "columbine",
|
73 |
+
"12": "colt's foot",
|
74 |
+
"11": "snapdragon",
|
75 |
+
"96": "camellia",
|
76 |
+
"23": "fritillary",
|
77 |
+
"50": "common dandelion",
|
78 |
+
"44": "poinsettia",
|
79 |
+
"53": "primula",
|
80 |
+
"72": "azalea",
|
81 |
+
"65": "californian poppy",
|
82 |
+
"80": "anthurium",
|
83 |
+
"76": "morning glory",
|
84 |
+
"37": "cape flower",
|
85 |
+
"56": "bishop of llandaff",
|
86 |
+
"60": "pink-yellow dahlia",
|
87 |
+
"82": "clematis",
|
88 |
+
"58": "geranium",
|
89 |
+
"75": "thorn apple",
|
90 |
+
"41": "barbeton daisy",
|
91 |
+
"95": "bougainvillea",
|
92 |
+
"43": "sword lily",
|
93 |
+
"83": "hibiscus",
|
94 |
+
"78": "lotus lotus",
|
95 |
+
"88": "cyclamen",
|
96 |
+
"94": "foxglove",
|
97 |
+
"81": "frangipani",
|
98 |
+
"74": "rose",
|
99 |
+
"89": "watercress",
|
100 |
+
"73": "water lily",
|
101 |
+
"46": "wallflower",
|
102 |
+
"77": "passion flower",
|
103 |
+
"51": "petunia"
|
104 |
+
}
|
model.pkl
ADDED
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
1 |
+
version https://git-lfs.github.com/spec/v1
|
2 |
+
oid sha256:7f88e1e4171cef724f17cf9f5d7fbe308c13155ceedcfc7a95594e5ddeb4ba1b
|
3 |
+
size 47274475
|
requirements.txt
ADDED
@@ -0,0 +1 @@
|
|
|
|
|
1 |
+
fastai
|