dgwyer commited on
Commit
d910a75
1 Parent(s): 617baae
Files changed (5) hide show
  1. app.py +19 -4
  2. banana.jpg +0 -0
  3. black.png +0 -0
  4. golden.png +0 -0
  5. labrador.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 libraries
2
+ from fastai.vision.all import *
3
  import gradio as gr
4
 
5
+ # Load model
6
+ learn = load_learner('labrador.pkl')
7
 
8
+ # Define categories
9
+ categories = ('Black', 'Golden')
10
+
11
+ # Define function to classify image
12
+ def classify_image(img):
13
+ pred, idx, probs = learn.predict(img)
14
+ return dict(zip(categories, map(float, probs)))
15
+
16
+ # Define Gradio interface
17
+ image = gr.inputs.Image(shape=(192, 192))
18
+ label = gr.outputs.Label()
19
+ examples = ['black.jpg', 'golden.jpg', 'banana.jpg']
20
+
21
+ intf = gr.Interface(fn=classify_image, inputs=image, outputs=label, examples=examples)
22
+ intf.launch(inline=False)
banana.jpg ADDED
black.png ADDED
golden.png ADDED
labrador.pkl ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:04b03ebc699795f636b18abd4b8ac958abbb6cc520f550b861f0f2aafbb18f19
3
+ size 46972090