varun3dec commited on
Commit
41a47b1
1 Parent(s): bdc46c8

Upload app.py

Browse files
Files changed (1) hide show
  1. app.py +23 -0
app.py ADDED
@@ -0,0 +1,23 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ from fastai.vision.all import *
2
+ from huggingface_hub import push_to_hub_fastai, from_pretrained_fastai
3
+ import gradio as gr
4
+
5
+ def is_cat(x): return x[0].isupper()
6
+
7
+ # Cell
8
+ learn = from_pretrained_fastai("fastai/cat_or_dog")
9
+
10
+ # Cell
11
+ categories = ('Dog', 'Cat')
12
+
13
+ def classify_image(img):
14
+ pred,idx,probs = learn.predict(img)
15
+ return dict(zip(categories, map(float,probs)))
16
+
17
+ # Cell
18
+ image = gr.inputs.Image(shape=(192, 192))
19
+ label = gr.outputs.Label()
20
+ examples = ['dog.jpg', 'cat.jpg', 'dunno.jpg']
21
+
22
+ intf = gr.Interface(fn=classify_image, inputs=image, outputs=label, examples=examples)
23
+ intf.launch()