init 2
Browse files- app.py +18 -0
- cat.jpg +0 -0
- dog.jpg +0 -0
- dunno.jpeg +0 -0
- model.pkl +3 -0
app.py
ADDED
@@ -0,0 +1,18 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
import gradio as gr
|
2 |
+
from fastai.vision.all import *
|
3 |
+
|
4 |
+
def is_cat(x):
|
5 |
+
return x[0].isupper()
|
6 |
+
|
7 |
+
learner = load_learner('model.pkl')
|
8 |
+
|
9 |
+
categories = ('Dog', 'Cat')
|
10 |
+
def classify_image(img):
|
11 |
+
pred, idx, probs = learner.predict(img)
|
12 |
+
return dict(zip(categories, map(float, probs)))
|
13 |
+
|
14 |
+
image = gr.inputs.Image(shape=(192,192))
|
15 |
+
label = gr.outputs.Label()
|
16 |
+
examples = ['dog.jpg', 'cat.jpg', 'dunno.jpeg']
|
17 |
+
intf = gr.Interface(fn=classify_image, inputs=image, outputs=label, examples=examples)
|
18 |
+
intf.launch(inline=False)
|
cat.jpg
ADDED
dog.jpg
ADDED
dunno.jpeg
ADDED
model.pkl
ADDED
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
1 |
+
version https://git-lfs.github.com/spec/v1
|
2 |
+
oid sha256:90409477cb91672f91d9cb24713f729ed65bc8bc5d95d3c1f92f22a34e18e7bf
|
3 |
+
size 47061291
|