xota1999 commited on
Commit
beb1601
1 Parent(s): eb2628e

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +6 -10
app.py CHANGED
@@ -1,23 +1,19 @@
1
- __all__ = ['is_katy', 'learn', 'classify_image', 'categories', 'image', 'label', 'examples', 'intf']
2
-
3
- # Cell
4
  from fastai.vision.all import *
5
  import gradio as gr
6
 
7
- def is_katy(x): return x[0].isupper()
8
-
9
- # Cell
10
  learn = load_learner('model.pkl')
11
 
12
- # Cell
13
  categories = ('Katy', 'Zooey')
14
 
 
15
  def classify_image(img):
16
  pred, idx, probs = learn.predict(img)
17
- return dict(zip(categories, map(float, probs)))
18
 
19
- # Cell
20
- image = gr.Image(type="pil", image_mode="RGB", tool="editor")
21
  label = gr.Label()
22
  examples = ['katy.jpg', 'katy2.jpg', 'zooey1.jpg', 'zooey2.jpg']
23
 
 
 
 
 
1
  from fastai.vision.all import *
2
  import gradio as gr
3
 
4
+ # pretrained model
 
 
5
  learn = load_learner('model.pkl')
6
 
7
+ # The categories
8
  categories = ('Katy', 'Zooey')
9
 
10
+ # Define the prediction function
11
  def classify_image(img):
12
  pred, idx, probs = learn.predict(img)
13
+ return {categories[i]: float(probs[i]) for i in range(len(categories))}
14
 
15
+ # Gradio interface
16
+ image = gr.Image(type="pil")
17
  label = gr.Label()
18
  examples = ['katy.jpg', 'katy2.jpg', 'zooey1.jpg', 'zooey2.jpg']
19