mdkhalid commited on
Commit
862f7ad
·
1 Parent(s): 4164d65

Upload 8 files

Browse files
Files changed (8) hide show
  1. .gitattributes +1 -0
  2. app.py +52 -4
  3. birdclassifiermodel.pkl +3 -0
  4. config +6 -0
  5. description +1 -0
  6. dog.jpeg +0 -0
  7. dog.jpg +3 -0
  8. elephant.jpeg +0 -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
+ dog.jpg filter=lfs diff=lfs merge=lfs -text
app.py CHANGED
@@ -1,7 +1,55 @@
 
 
 
 
 
 
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
+ # %%
2
+ pip install -Uqq fastbook
3
+
4
+ # %%
5
+ #|export
6
+ from fastai.vision.all import *
7
  import gradio as gr
8
 
9
+ def is_bird(x): return x[0].isupper()
10
+
11
+ # %%
12
+ im = PILImage.create('dog.jpg')
13
+ im.thumbnail((192,192))
14
+ im
15
+
16
+ # %%
17
+ import pathlib
18
+ temp = pathlib.PosixPath
19
+ pathlib.PosixPath = pathlib.WindowsPath
20
+
21
+ # %%
22
+ #|export
23
+ learn = load_learner('birdclassifiermodel.pkl')
24
+
25
+ # %%
26
+ learn.predict(im)
27
+
28
+ # %%
29
+ #|export
30
+ categories = ('bird','not a bird')
31
+
32
+ def classify_image(img):
33
+ pred,idx,probs = learn.predict(img)
34
+ return dict(zip(categories, map(float,probs)))
35
+
36
+
37
+ # %%
38
+ classify_image(im)
39
+
40
+ # %%
41
+ #|export
42
+ image = gr.inputs.Image(shape =(192,192))
43
+ label = gr.outputs.Label()
44
+ examples = ['dog.jpg', 'elephant.jpeg', 'dog.jpeg']
45
+
46
+ intf = gr.Interface(fn =classify_image, inputs=image, outputs=label, examples = examples)
47
+ intf.launch(inline=False)
48
+
49
+ # %%
50
+
51
+
52
+ # %% [markdown]
53
+ #
54
+
55
 
 
 
birdclassifiermodel.pkl ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:c3ed195db4e8ae52a2ab0e16dc33e4f0dfa5eb7624b089953ec8fca7de294f07
3
+ size 46954863
config ADDED
@@ -0,0 +1,6 @@
 
 
 
 
 
 
 
1
+ [core]
2
+ repositoryformatversion = 0
3
+ filemode = false
4
+ bare = true
5
+ symlinks = false
6
+ ignorecase = true
description ADDED
@@ -0,0 +1 @@
 
 
1
+ Unnamed repository; edit this file 'description' to name the repository.
dog.jpeg ADDED
dog.jpg ADDED

Git LFS Details

  • SHA256: 5151ddd18ef9ec9d2537e25ee787f933e4ad484ddded5f70ae354a561fde0a5e
  • Pointer size: 132 Bytes
  • Size of remote file: 3.05 MB
elephant.jpeg ADDED