ndabby commited on
Commit
e63a78d
1 Parent(s): fb13d26

uploading my other files

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