Dan Biagini commited on
Commit
9f50c5e
·
1 Parent(s): c0a33cd

add descriptive text for app

Browse files
Files changed (1) hide show
  1. app.py +13 -3
app.py CHANGED
@@ -3,11 +3,20 @@ from fastai.vision.all import *
3
  from os import listdir
4
  import random
5
 
 
 
 
 
 
 
 
 
 
6
  learn = load_learner('hockey_model.pkl')
7
 
8
  categories = ('Hockey Goalie', 'Hockey Player', "Hockey Referee")
9
- image = gr.inputs.Image(shape=(192, 192))
10
- label = gr.outputs.Label()
11
  skater_example = 'assets/skaters/' + random.choice(listdir('assets/skaters'))
12
  ref_example = 'assets/referees/' + random.choice(listdir('assets/referees'))
13
  goalie_example = 'assets/goalies/' + random.choice(listdir('assets/goalies'))
@@ -17,5 +26,6 @@ def classify_image(img):
17
  return dict(zip(categories, map(float, prob)))
18
 
19
  iface = gr.Interface(fn=classify_image, inputs=image, outputs=label, theme=gr.themes.Glass(),
20
- examples=[skater_example, ref_example, goalie_example])
 
21
  iface.launch(share=False, debug=True)
 
3
  from os import listdir
4
  import random
5
 
6
+ title = "Who Am I? (Hockey Edition)"
7
+
8
+ desc = """This app uses a 'neural network' (a type of machine learning model) to classify
9
+ an image as containing a hockey player, a hockey goalie or a hockey referee."""
10
+
11
+ art = """I built this model using about 50 hockey related images found on the web and in my own collection. I started with a pretrained `resnet18` model (resnet18 is trained on `imagenet`, a very large dataset with millions of images)
12
+ and then performed `fine tuning` of this using python and the `fast.ai` library.
13
+ The total training time for this was about 5 minutes on a basic GPU. It's impressive how accurate this quick / small model can be!"""
14
+
15
  learn = load_learner('hockey_model.pkl')
16
 
17
  categories = ('Hockey Goalie', 'Hockey Player', "Hockey Referee")
18
+ image = gr.Image(shape=(192, 192))
19
+ label = gr.Label()
20
  skater_example = 'assets/skaters/' + random.choice(listdir('assets/skaters'))
21
  ref_example = 'assets/referees/' + random.choice(listdir('assets/referees'))
22
  goalie_example = 'assets/goalies/' + random.choice(listdir('assets/goalies'))
 
26
  return dict(zip(categories, map(float, prob)))
27
 
28
  iface = gr.Interface(fn=classify_image, inputs=image, outputs=label, theme=gr.themes.Glass(),
29
+ examples=[skater_example, ref_example, goalie_example], title=title,
30
+ description=desc, article=art)
31
  iface.launch(share=False, debug=True)