peterbonnesoeur commited on
Commit
b3c78e6
β€’
1 Parent(s): 0f2990a

Added basic pose estimation

Browse files
Files changed (1) hide show
  1. app.py +19 -9
app.py CHANGED
@@ -4,20 +4,18 @@ import gradio as gr
4
  import openpifpaf
5
  import numpy as np
6
 
7
-
8
- predictor_animal = openpifpaf.Predictor(checkpoint='shufflenetv2k30-animalpose')
9
- predictor_whole_body = openpifpaf.Predictor(checkpoint='shufflenetv2k16-wholebody')
10
  predictor_vehicle = openpifpaf.Predictor(checkpoint='shufflenetv2k16-apollo-24')
11
 
12
 
13
  def inference(img, ver):
14
-
15
- if ver == 'whole-body':
 
16
  predictor = predictor_whole_body
17
  elif ver == 'vehicles':
18
  predictor = predictor_vehicle
19
- elif ver == 'animal':
20
- predictor = predictor_animal
21
  else:
22
  raise ValueError('invalid version')
23
 
@@ -34,6 +32,18 @@ title = "Openpifpaf"
34
  description = "Gradio demo for openpifpaf. To use it, simply upload your image, or click one of the examples to load them. Read more at the links below. Please use a cropped portrait picture for best results similar to the examples below"
35
  article = "<p style='text-align: center'><a href='https://github.com/openpifpaf/openpifpaf' target='_blank'>Github Repo Openpifpaf</a> | <a href='https://github.com/peterbonnesoeur' target='_blank'>Github Repo peterbonnesoeur</a></p>"
36
 
37
- examples=[ ['bill.png', 'whole-body'], ['vehicles.jpg', 'vehicles'], ['apolloscape.jpeg', 'vehicles'], ['dalmatian.jpg', 'animal'], ['elon.png','whole-body'], ['billie.png','whole-body']]
38
- gr.Interface(inference, [gr.inputs.Image(type="pil"),gr.inputs.Radio(['pose','whole-body', 'vehicles', 'animal'], type="value", default='whole-body', label='version')
 
 
 
 
 
 
 
 
 
 
 
 
39
  ], gr.outputs.Image(type="pil"),title=title,description=description,article=article,enable_queue=True,examples=examples).launch()
 
4
  import openpifpaf
5
  import numpy as np
6
 
7
+ predictor_pose = openpifpaf.Predictor(checkpoint='shufflenetv2k30')
8
+ predictor_whole_body = openpifpaf.Predictor(checkpoint='shufflenetv2k30-wholebody')
 
9
  predictor_vehicle = openpifpaf.Predictor(checkpoint='shufflenetv2k16-apollo-24')
10
 
11
 
12
  def inference(img, ver):
13
+ if ver == 'pose':
14
+ predictor = predictor_pose
15
+ elif ver == 'whole-body':
16
  predictor = predictor_whole_body
17
  elif ver == 'vehicles':
18
  predictor = predictor_vehicle
 
 
19
  else:
20
  raise ValueError('invalid version')
21
 
 
32
  description = "Gradio demo for openpifpaf. To use it, simply upload your image, or click one of the examples to load them. Read more at the links below. Please use a cropped portrait picture for best results similar to the examples below"
33
  article = "<p style='text-align: center'><a href='https://github.com/openpifpaf/openpifpaf' target='_blank'>Github Repo Openpifpaf</a> | <a href='https://github.com/peterbonnesoeur' target='_blank'>Github Repo peterbonnesoeur</a></p>"
34
 
35
+ with open("article.html", "r", encoding='utf-8') as f:
36
+ article= f.read()
37
+
38
+ examples=[
39
+ ['basketball.jpg','whole-body'],
40
+ ['meeting.jpeg','whole-body'],
41
+ ['crowd.jpg','pose'],
42
+ ['elon.png','whole-body'],
43
+ ['billie.png','whole-body'],
44
+ ['india-vehicles.jpeg', 'vehicles'],
45
+ ['russia-vehicles.jpg', 'vehicles'],
46
+ ['paris-vehicles.jpg', 'vehicles'],
47
+ ]
48
+ gr.Interface(inference, [gr.inputs.Image(type="pil"),gr.inputs.Radio(['pose', 'whole-body', 'vehicles'], type="value", default='pose', label='version')
49
  ], gr.outputs.Image(type="pil"),title=title,description=description,article=article,enable_queue=True,examples=examples).launch()