marcmaniez commited on
Commit
f89c808
·
1 Parent(s): 492e76d

Detect bears

Browse files
Files changed (6) hide show
  1. .gitignore +1 -0
  2. app.py +17 -4
  3. black.jpg +0 -0
  4. compress.py +6 -0
  5. grizzly.jpg +0 -0
  6. teddy.jpg +0 -0
.gitignore ADDED
@@ -0,0 +1 @@
 
 
1
+ bears_model.pkl
app.py CHANGED
@@ -1,7 +1,20 @@
 
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
+ from fastai.vision.all import *
2
  import gradio as gr
3
+ from huggingface_hub import from_pretrained_fastai
4
 
5
+ learn = from_pretrained_fastai("marcmaniez/bears")
 
6
 
7
+ # learn = load_learner('bears_model.pkl')
8
+
9
+ categories = ('grizzly', 'black', 'teddy')
10
+
11
+ def classify_image(img):
12
+ pred, idx, probs = learn.predict(img)
13
+ return dict(zip(categories, map(float, probs)))
14
+
15
+ img = gr.inputs.Image(shape=(192, 192))
16
+ label = gr.outputs.Label()
17
+ examples = ['grizzly.jpg', 'brown.jpg', 'teddy.jpg']
18
+
19
+ intf = gr.Interface(fn=classify_image, inputs=image, outputs=label, examples=examples)
20
+ intf.launch(inline=False)
black.jpg ADDED
compress.py ADDED
@@ -0,0 +1,6 @@
 
 
 
 
 
 
 
1
+ import bz2file as bz2
2
+ from fastai.vision.all import *
3
+ from huggingface_hub import push_to_hub_fastai
4
+
5
+ learn = load_learner('bears_model.pkl')
6
+ push_to_hub_fastai(learner=learn, repo_id="marcmaniez/bears")
grizzly.jpg ADDED
teddy.jpg ADDED