chuckma commited on
Commit
3b11161
1 Parent(s): 6040ccf

add image file

Browse files
Files changed (5) hide show
  1. .gitattributes +2 -0
  2. app.py +27 -2
  3. cat.jpg +3 -0
  4. cos.png +3 -0
  5. dog.jpg +3 -0
.gitattributes CHANGED
@@ -32,3 +32,5 @@ saved_model/**/* filter=lfs diff=lfs merge=lfs -text
32
  *.zip filter=lfs diff=lfs merge=lfs -text
33
  *.zst filter=lfs diff=lfs merge=lfs -text
34
  *tfevents* filter=lfs diff=lfs merge=lfs -text
 
 
 
32
  *.zip filter=lfs diff=lfs merge=lfs -text
33
  *.zst filter=lfs diff=lfs merge=lfs -text
34
  *tfevents* filter=lfs diff=lfs merge=lfs -text
35
+ *.jpg filter=lfs diff=lfs merge=lfs -text
36
+ *.png filter=lfs diff=lfs merge=lfs -text
app.py CHANGED
@@ -1,3 +1,28 @@
 
 
 
 
 
 
 
 
 
 
1
  import gradio as gr
2
- def greet (name): return f"Hello {name}!"
3
- gr.Interface(fn=greet, inputs="text", outputs="text"). launch()
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ # import gradio as gr
2
+ # def greet (name): return f"Hello {name}!"
3
+ # gr.Interface(fn=greet, inputs="text", outputs="text"). launch()
4
+
5
+ _all_ = ['is_cat', 'learn', 'classify_image'
6
+ , 'categories',
7
+ 'image',
8
+ 'label', 'examples', 'intf']
9
+ # Cell
10
+ from fastai.vision.al1 import *
11
  import gradio as gr
12
+ def is_cat(x): return x[0].isupper()
13
+ # Cell
14
+ learn = load_learner('model.pkl')
15
+ # Cell
16
+ categories = ('Dog', 'Cat')
17
+ format_float = lambda x: "{:.10f}".format(float(x))
18
+
19
+ def classify_image(img):
20
+ pred,idx,probs = learn.predict(img)
21
+ return dict (zip(categories, map (format_float,probs)))
22
+
23
+ image = gr.inputs.Image(shape=(192, 192))
24
+ label = gr.outputs.Label()
25
+ examples = ['dog.jpg'
26
+ , 'cat.jpg', 'cos.png']
27
+ intf = gr.Interface(fn=classify_image, inputs=image, outputs=label, examples=examples)
28
+ intf.launch (inline=False)
cat.jpg ADDED

Git LFS Details

  • SHA256: b82e7d63489c47793a8d015d3bf24b316f931bfecc1f2a10b17849c3ff46349f
  • Pointer size: 132 Bytes
  • Size of remote file: 4.3 MB
cos.png ADDED

Git LFS Details

  • SHA256: e681c47434542ebb81d155ff333f4c74bee61741c92a58c0fbe017d01257edff
  • Pointer size: 130 Bytes
  • Size of remote file: 51.1 kB
dog.jpg ADDED

Git LFS Details

  • SHA256: fbb389241aef7e29ef0ce6e8c5af55cc00e721ea8965b9c3f3c868650e58dc2e
  • Pointer size: 132 Bytes
  • Size of remote file: 1.59 MB