Yunij commited on
Commit
49bdebc
·
1 Parent(s): e9ea2fa
Files changed (1) hide show
  1. app.py +30 -13
app.py CHANGED
@@ -1,44 +1,61 @@
1
  #!/usr/bin/env python
 
2
 
3
  # In[12]:
4
 
 
5
  import gradio as gr
6
- from fastai.vision.all import *
7
 
8
  # In[13]:
9
 
10
 
 
 
 
11
  # In[14]:
12
 
13
- learn = load_learner("model.pkl")
 
 
14
 
15
  # In[15]:
16
 
17
- categories = {"Ronaldo", "messi", "Michael Jordan", "Rafael Nadal", "Roger Federer"}
18
 
 
19
 
20
  def classify_athlete(img):
21
- pred, idx, probs = learn.predict(img)
22
- return dict(zip(categories, map(float, probs)))
23
 
24
 
25
  # In[21]:
26
 
27
- classify_athlete("cr7.jpeg")
28
 
29
- # In[24]:
 
 
 
30
 
31
- image = gr.inputs.Image(shape=(192, 192))
 
32
  label = gr.outputs.Label()
33
- examples = ["cr7.jpeg", "messi.jpeg", "michael_jordan.jpeg"]
 
 
 
34
 
35
- intf = gr.Interface(fn=classify_athlete, inputs=image, outputs=label, examples=examples)
36
- intf.launch(inline=False, share=True)
37
 
38
  # # Making and exporting a python script
39
 
40
- # In[21]:
 
 
 
41
 
42
- # Export Notebook to python Script -- nbdev --
43
 
44
  # In[ ]:
 
 
 
 
 
1
  #!/usr/bin/env python
2
+ # coding: utf-8
3
 
4
  # In[12]:
5
 
6
+
7
  import gradio as gr
8
+
9
 
10
  # In[13]:
11
 
12
 
13
+ from fastai.vision.all import *
14
+
15
+
16
  # In[14]:
17
 
18
+
19
+ learn = load_learner('model.pkl')
20
+
21
 
22
  # In[15]:
23
 
 
24
 
25
+ categories = {'Ronaldo', 'messi', 'Michael Jordan', 'Rafael Nadal', 'Roger Federer'}
26
 
27
  def classify_athlete(img):
28
+ pred,idx,probs = learn.predict(img)
29
+ return dict(zip(categories, map(float,probs)))
30
 
31
 
32
  # In[21]:
33
 
 
34
 
35
+ classify_athlete('cr7.jpeg')
36
+
37
+
38
+ # In[26]:
39
 
40
+
41
+ image = gr.inputs.Image(shape = (192,192))
42
  label = gr.outputs.Label()
43
+ examples = ['cr7.jpeg','messi.jpeg','michael_jordan.jpeg']
44
+
45
+ intf = gr.Interface(fn = classify_athlete,inputs = image, outputs = label, examples = examples)
46
+ intf.launch(inline = False)
47
 
 
 
48
 
49
  # # Making and exporting a python script
50
 
51
+ # In[34]:
52
+
53
+
54
+ get_ipython().system('jupyter nbconvert --to script app.ipynb')
55
 
 
56
 
57
  # In[ ]:
58
+
59
+
60
+
61
+