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