complex11011 commited on
Commit
8d26075
·
1 Parent(s): 679c120
Files changed (5) hide show
  1. app.py +17 -4
  2. dinosaur.png +0 -0
  3. model.pkl +3 -0
  4. not_dinosaur.png +0 -0
  5. requirements.txt +1 -0
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
+ __all__ = ['learn', 'classify_image', 'categories',
2
+ 'image', 'label', 'examples', 'intf']
3
+
4
+ from fastai.vision.all import *
5
  import gradio as gr
6
 
7
+ learn = load_learner('model.pkl')
8
+
9
+ categories = ('Dinosaur', 'Not Dinosaur')
10
+
11
+ def classify_image(img):
12
+ pred, idx, probs = learn.predict(img)
13
+ return dict(zip(categories, map(float, probs)))
14
+
15
+ image = gr.inputs.Image(shape=(192, 192))
16
+ label = gr.outputs.Label()
17
+ examples = ['dinosaur.png', 'not_dinosaur.png']
18
 
19
+ intf = gr.Interface(fn=classify_image, inputs=image, outputs=label, examples=examples)
20
+ intf.launch(inline=False)
dinosaur.png ADDED
model.pkl ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:b884c6e5faf1845a654920069476749ae54ec3bba15924d5405c0213bb542746
3
+ size 46954863
not_dinosaur.png ADDED
requirements.txt ADDED
@@ -0,0 +1 @@
 
 
1
+ fastai