m0saan commited on
Commit
fa745f1
·
1 Parent(s): b0cc184

dog cat classifier app

Browse files
Files changed (1) hide show
  1. app.py +26 -4
app.py CHANGED
@@ -1,7 +1,29 @@
 
 
 
 
 
 
 
1
  import gradio as gr
2
 
3
- def greet(name):
4
- return "Hello " + name + "!!!"
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
5
 
6
- iface = gr.Interface(fn=greet, inputs="text", outputs="text")
7
- iface.launch()
 
1
+ # AUTOGENERATED! DO NOT EDIT! File to edit: ../02_prod.ipynb.
2
+
3
+ # %% auto 0
4
+ __all__ = ['learn', 'categories', 'image', 'label', 'intrf', 'is_cat', 'classify_image']
5
+
6
+ # %% ../02_prod.ipynb 47
7
+ from fastai.vision.all import *
8
  import gradio as gr
9
 
10
+ # %% ../02_prod.ipynb 48
11
+ def is_cat(x): return x[0].isupper()
12
+
13
+ # %% ../02_prod.ipynb 49
14
+ learn = load_learner('model.pkl')
15
+
16
+ # %% ../02_prod.ipynb 50
17
+ categories = 'Dog', 'Cat'
18
+
19
+ def classify_image(img):
20
+ pred, idx, probs = learn.predict(img)
21
+ return dict(zip(categories, map(float, probs)))
22
+
23
+
24
+ # %% ../02_prod.ipynb 51
25
+ image = gr.inputs.Image(shape=(192, 192))
26
+ label = gr.outputs.Label()
27
 
28
+ intrf = gr.Interface(fn=classify_image, inputs=image, outputs=label)
29
+ intrf.launch(inline=False)