kaimou0829 commited on
Commit
dbb5fcf
·
1 Parent(s): 523a8b1

cat vs dog

Browse files
Files changed (5) hide show
  1. app.py +30 -0
  2. bear.jpg +0 -0
  3. cat.jpg +0 -0
  4. dog.jpg +0 -0
  5. model.pkl +3 -0
app.py ADDED
@@ -0,0 +1,30 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ # %%
2
+ #|default_exp app
3
+
4
+ # %%
5
+ #|export
6
+ import gradio as gr
7
+ from fastai.vision.all import *
8
+
9
+ def is_cat(x): return x[0].isupper()
10
+
11
+
12
+ learn = load_learner('model.pkl')
13
+
14
+ #|export
15
+ categories = ('Dog', 'Cat')
16
+
17
+ def classify_image(im):
18
+ pred, pred_idx, probs = learn.predict(im)
19
+ return dict(zip(categories, map(float, probs)))
20
+
21
+
22
+ #|export
23
+ image = gr.Image(type="pil")
24
+ label = gr.Label(num_top_classes=2)
25
+ examples = ['dog.jpg', 'cat.jpg', 'bear.jpg']
26
+
27
+ intf = gr.Interface(fn=classify_image, inputs=image, outputs=label, examples=examples)
28
+ intf.launch(share=True, inline=False)
29
+
30
+
bear.jpg ADDED
cat.jpg ADDED
dog.jpg ADDED
model.pkl ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:07792ba7b19a43ba13fadf3cd10efa0c92929cc1c51af1bc183a4010d14963f1
3
+ size 47061419