Spaces:
Sleeping
Sleeping
Add application file
Browse files- app.py +22 -0
- broccoli.jpeg +3 -0
- export.pkl +3 -0
- marijuana.jpeg +3 -0
app.py
ADDED
@@ -0,0 +1,22 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
from fastai.vision.all import *
|
2 |
+
import gradio as gr
|
3 |
+
learn = load_learner('export.pkl')
|
4 |
+
|
5 |
+
|
6 |
+
categories = ('broccoli', 'marijuana')
|
7 |
+
|
8 |
+
|
9 |
+
def classify_image(img):
|
10 |
+
pred, idx, probs = learn.predict(img)
|
11 |
+
return dict(zip(categories, map(float, probs)))
|
12 |
+
|
13 |
+
|
14 |
+
image = gr.inputs.Image(shape=(192, 192))
|
15 |
+
label = gr.outputs.Label()
|
16 |
+
|
17 |
+
examples = ['broccoli.jpeg', 'marijuana.jpeg']
|
18 |
+
|
19 |
+
intf = gr.Interface(fn=classify_image, inputs=image,
|
20 |
+
outputs=label, examples=examples)
|
21 |
+
|
22 |
+
intf.launch(inline=False)
|
broccoli.jpeg
ADDED
![]() |
Git LFS Details
|
export.pkl
ADDED
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
1 |
+
version https://git-lfs.github.com/spec/v1
|
2 |
+
oid sha256:c809988609381e050146525eb00919eff7a0faf66334e19221148ae886bb1aa6
|
3 |
+
size 46966014
|
marijuana.jpeg
ADDED
![]() |
Git LFS Details
|