omarelsayeed commited on
Commit
b6c6b81
·
1 Parent(s): f2715d2
Files changed (2) hide show
  1. app.py +19 -4
  2. bears_model.pkl +3 -0
app.py CHANGED
@@ -1,7 +1,22 @@
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 fastai.vision.all import *
3
 
4
+ def classify_img(img):
5
+ pred , idx , probs = learn.predict(img)
6
+ return dict(zip(categories , map(float , probs)))
7
 
8
+ learn = load_learner('bearsfastai/bears_model.pkl')
9
+
10
+ categories = ( 'black bear','grizzly bear' , 'teady bear')
11
+
12
+
13
+ image = gr.inputs.Image(shape=(194,194))
14
+ label = gr.outputs.Label()
15
+ examples = [
16
+ 'train_data2/teady bear/f8d8000c-1eae-43dc-a06b-58e9e242effd.jpg' ,
17
+ 'train_data2/grizzly bear/1d5e3d53-a4a9-4f19-b1cb-1bed0f95ed66.jpg',
18
+ 'train_data2/black bear/6ea1843c-f6d4-497d-a861-d66ae6b36290.jpg'
19
+ ]
20
+
21
+ intf = gr.Interface(fn = classify_img , inputs = image , outputs = label , examples = examples)
22
+ intf.launch(share = True)
bears_model.pkl ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:fb1d64e0a426824a80a2e2f59d06d0ae7f5e7e5d5f10651046218d583536aaef
3
+ size 46968801