Spaces:
Sleeping
Sleeping
Phoebe
commited on
Commit
·
8da8510
1
Parent(s):
03106b9
app and model
Browse files- app.py +18 -0
- export.pkl +3 -0
- requirements.txt +2 -0
app.py
ADDED
@@ -0,0 +1,18 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
from fastai.vision.all import *
|
2 |
+
import gradio as gr
|
3 |
+
|
4 |
+
def is_cat(x): return x[0].isupper()
|
5 |
+
|
6 |
+
learn = load_learner('export.pkl')
|
7 |
+
|
8 |
+
categories = ('apple','banana','beetroot','bell pepper','cabbage','capsicum','carrot','cauliflower','chili pepper','corn','cucumber','eggplant','garlic','ginger','grapes','jalepeno','kiwi','lemon','lettuce','mango','onion','orange','paprika','pear','peas','pineapple','pomegranate','potato','raddish','soy beans','spinach','sweetcorn','sweetpotato','tomato','turnip','watermelon')
|
9 |
+
|
10 |
+
def classify_images(img):
|
11 |
+
pred, idx, probs = learn.predict(img)
|
12 |
+
return dict(zip(categories, map(float, probs)))
|
13 |
+
|
14 |
+
image = gr.Image(type="pil")
|
15 |
+
label = gr.Label()
|
16 |
+
|
17 |
+
intf = gr.Interface(fn=classify_images, inputs=image, outputs=label)
|
18 |
+
intf.launch(inline=False)
|
export.pkl
ADDED
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
1 |
+
version https://git-lfs.github.com/spec/v1
|
2 |
+
oid sha256:79b5e58a7b90b10b68b7215e2b499f469210cab3dec8d8620c864964df4df86d
|
3 |
+
size 47092164
|
requirements.txt
ADDED
@@ -0,0 +1,2 @@
|
|
|
|
|
|
|
1 |
+
fastai
|
2 |
+
scikit-image
|