fsefon commited on
Commit
ce29610
·
1 Parent(s): 1076f46

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +5 -14
app.py CHANGED
@@ -1,21 +1,15 @@
1
-
2
-
3
  from fastai.vision.all import *
4
  import gradio as gr
5
 
6
- def what_ball(x): return x in ['soccer ball','basketball ball','golf ball','tennis ball','volleyball ball','Cricket ball']
7
 
8
- # %% ../app2.ipynb 3
9
- learn=load_learner('model.pkl')
10
 
11
- # %% ../app2.ipynb 5
12
- categories = ['soccer ball','basketball ball','golf ball','tennis ball','volleyball ball','Cricket ball']
13
  def classify_image(img):
14
  pred, idx, probs = learn.predict(img)
15
  return dict(zip(categories, map(float, probs)))
16
 
17
- # %% ../app2.ipynb 7
18
- image = gr.inputs.Image(shape=(192,192))
19
  label = gr.outputs.Label()
20
  examples = [
21
  'soccer_ball.jpg',
@@ -25,9 +19,6 @@ examples = [
25
  'golf_ball.jpg',
26
  'cricket_ball.jpg'
27
  ]
28
- intf = gr.Interface(fn=classify_image, inputs=image, outputs=label, examples=examples)
29
- intf.launch(inline=False)
30
- iface = gr.Interface(fn= classify_image, inputs=image, outputs=label, examples = examples, title = "Sports Ball Recognition App", description = "This app can recognize different types of sport balls.")
31
- iface.launch(inline = False)
32
 
33
- # inline = False, share = True
 
 
 
 
1
  from fastai.vision.all import *
2
  import gradio as gr
3
 
4
+ learn=load_learner('sportball.pkl')
5
 
6
+ categories = ['basketball','cricket','volleyball','soccer','tennis','golf']
 
7
 
 
 
8
  def classify_image(img):
9
  pred, idx, probs = learn.predict(img)
10
  return dict(zip(categories, map(float, probs)))
11
 
12
+ image = gr.inputs.Image(shape=(192, 192))
 
13
  label = gr.outputs.Label()
14
  examples = [
15
  'soccer_ball.jpg',
 
19
  'golf_ball.jpg',
20
  'cricket_ball.jpg'
21
  ]
 
 
 
 
22
 
23
+ intf = gr.Interface(fn=classify_image, inputs=image, outputs=label, examples=examples, title = "Sports Ball Recognition App", description = "This app can recognize different types of sport balls.")
24
+ intf.launch(inline=False)