Yunij commited on
Commit
2c40cc9
·
1 Parent(s): 45f20be
Files changed (1) hide show
  1. app.py +44 -4
app.py CHANGED
@@ -1,7 +1,47 @@
 
 
 
 
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
+ #!/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[16]:
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)
37
+
38
+ # # Making and exporting a python script
39
+
40
+ # In[18]:
41
+
42
+ # Export Notebook to python Script -- nbdev --
43
+ from notebook2script import convert_notebook
44
 
45
+ convert_notebook("app.ipynb", "app.py")
 
46
 
47
+ # In[ ]: