Caio Braga commited on
Commit
0aa4ed9
1 Parent(s): e354dc0

add model and graddle interface

Browse files
Files changed (6) hide show
  1. .gitattributes +1 -0
  2. app.py +13 -3
  3. cat_persian.jpg +0 -0
  4. cat_siamese.jpg +0 -0
  5. cat_sphynx.jpg +0 -0
  6. cats.pkl +3 -0
.gitattributes CHANGED
@@ -33,3 +33,4 @@ saved_model/**/* filter=lfs diff=lfs merge=lfs -text
33
  *.zip filter=lfs diff=lfs merge=lfs -text
34
  *.zst filter=lfs diff=lfs merge=lfs -text
35
  *tfevents* filter=lfs diff=lfs merge=lfs -text
 
 
33
  *.zip filter=lfs diff=lfs merge=lfs -text
34
  *.zst filter=lfs diff=lfs merge=lfs -text
35
  *tfevents* filter=lfs diff=lfs merge=lfs -text
36
+ /cats.pkl filter=lfs diff=lfs merge=lfs -text
app.py CHANGED
@@ -1,7 +1,17 @@
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
  import gradio as gr
2
+ from fastbook import *
3
+ from fastai.vision.all import *
4
 
5
+ learn = load_learner("cats.pkl")
6
+ cat_breeds = ['persian', 'siamese', 'angora', 'sphynx']
7
 
8
+ def classify_image(img):
9
+ pred, idx, probs = learn.predict(img)
10
+ return dict(zip(cat_breeds, map(float, probs)))
11
+
12
+ image = gr.inputs.Image(shape=(192,192))
13
+ label = gr.outputs.Label()
14
+ examples = ['cat_siamese.jpg', 'cat_persian.jpg', 'cat_sphynx.jpg']
15
+
16
+ iface = gr.Interface(fn=classify_image, inputs=image, outputs=label, examples=examples)
17
  iface.launch()
cat_persian.jpg ADDED
cat_siamese.jpg ADDED
cat_sphynx.jpg ADDED
cats.pkl ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:a418d86e517aece09743151be117ff94fa4dd44a31e999b891dcef2e2275294d
3
+ size 46973483