zachwormgoor@gmail.com commited on
Commit
78a12d4
1 Parent(s): 0f4b23e

Following example from fast.ai lesson 2.

Browse files
Files changed (2) hide show
  1. app.py +35 -4
  2. model.pkl +3 -0
app.py CHANGED
@@ -1,7 +1,38 @@
 
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 fast.ai.vision.all import *
2
  import gradio as gr
3
 
4
+ # def greet(name):
5
+ # return "Hello " + name + "!!"
6
 
7
+ # iface = gr.Interface(fn=greet, inputs="text", outputs="text")
8
+ # iface.launch()
9
+
10
+
11
+
12
+
13
+ # from:
14
+ # https://course.fast.ai/Lessons/lesson2.html
15
+ # https://github.com/fastai/fastbook/blob/master/02_production.ipynb
16
+
17
+
18
+ #learn_inf = load_learner(path/'export.pkl')
19
+ #learn_inf.predict('images/grizzly.jpg')
20
+ #learn_inf.dls.vocab
21
+
22
+
23
+ # model created from: https://www.kaggle.com/code/zachwormgoor/stock-photo-recognizer
24
+ learn = load_learner('model.pkl')
25
+
26
+ categories = ('stock', 'amateur')
27
+
28
+ def classify(img):
29
+ pred,idx,probs = learn.predict(img)
30
+ return dict(zip(categories, map(float,probs)))
31
+
32
+
33
+ image = gr.inputs.Image(shape=(192, 192))
34
+ label = gr.outputs.Label()
35
+ examples = ['stock.jpg', 'amateur.jpg', 'unsure.jpg']
36
+
37
+ intf = gr.Interface(fn=classify_image, inputs=image, outputs=label, examples=examples)
38
+ intf.launch(inline=False)
model.pkl ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:880a9f0645a078cf543377f21f3385cf23a6271f680955084495c9956e3f09ae
3
+ size 46964331