federico commited on
Commit
ccd2946
β€’
1 Parent(s): a6779d1

added flag to not plot kpts

Browse files
Files changed (2) hide show
  1. .gitignore +1 -0
  2. app.py +20 -11
.gitignore ADDED
@@ -0,0 +1 @@
 
 
1
+ /LAEO_demo_data/
app.py CHANGED
@@ -25,7 +25,7 @@ def load_image(camera, ):
25
  return False, None
26
 
27
 
28
- def demo_play(img, laeo=True, rgb=False):
29
  # webcam in use
30
 
31
  # gpus = tf.config.list_physical_devices('GPU')
@@ -69,8 +69,9 @@ def demo_play(img, laeo=True, rgb=False):
69
  'center_xy': [tdx, tdy]
70
  })
71
 
72
- for i in range(len(det)):
73
- img = draw_key_points_pose(img, kpt[i])
 
74
 
75
  # call LAEO
76
  clip_uncertainty = 0.5
@@ -118,27 +119,35 @@ if __name__=='__main__':
118
 
119
  print("Num GPUs Available: ", len(tf.config.list_physical_devices('GPU')))
120
 
 
 
 
 
 
 
121
  demo_webcam = gr.Interface(
122
- fn=demo_play,
123
  inputs=[gr.Image(source="webcam"), # with no streaming-> acquire images
124
  gr.Checkbox(value=True, label="LAEO", info="Compute and display LAEO"),
125
  gr.Checkbox(value=False, label="rgb", info="Display output on W/B image"),
 
126
  ],
127
- outputs="image",
128
- live=True,
129
- title="Head Pose Estimation and LAEO",
130
  description="This is a demo developed by Federico Figari T. at MaLGa Lab, University of Genoa, Italy. You can choose to have only the Head Pose Estimation or also the LAEO computation (more than 1 person should be in the image). You need to take a picture and the algorithm will calculate the Head Pose and will be showed as an arrow on your face. LAEO, instead is showed colouring the arrow in green.",
131
  )
132
 
133
  demo_upload = gr.Interface(
134
- fn=demo_play,
135
  inputs=[gr.Image(source="upload", ), # with no streaming-> acquire images
136
  gr.Checkbox(value=True, label="LAEO", info="Compute and display LAEO"),
137
  gr.Checkbox(value=False, label="rgb", info="Display output on W/B image"),
 
138
  ],
139
- outputs="image",
140
- live=True,
141
- title="Head Pose Estimation and LAEO",
142
  description="This is a demo developed by Federico Figari T. at MaLGa Lab, University of Genoa, Italy. You can choose to have only the Head Pose Estimation or also the LAEO computation (more than 1 person should be in the image). You need to upload an image and the algorithm will calculate the Head Pose and will be showed as an arrow on your face. LAEO, instead is showed colouring the arrow in green.",
143
  examples=[["LAEO_demo_data/examples/1.jpg"], ["LAEO_demo_data/examples/20.jpg"]]
144
  )
 
25
  return False, None
26
 
27
 
28
+ def demo_play(img, laeo=True, rgb=False, show_keypoints=True):
29
  # webcam in use
30
 
31
  # gpus = tf.config.list_physical_devices('GPU')
 
69
  'center_xy': [tdx, tdy]
70
  })
71
 
72
+ if show_keypoints:
73
+ for i in range(len(det)):
74
+ img = draw_key_points_pose(img, kpt[i])
75
 
76
  # call LAEO
77
  clip_uncertainty = 0.5
 
119
 
120
  print("Num GPUs Available: ", len(tf.config.list_physical_devices('GPU')))
121
 
122
+ function_to_call = demo_play
123
+ outputs = "image"
124
+ live = True
125
+ title = "Head Pose Estimation and LAEO"
126
+
127
+
128
  demo_webcam = gr.Interface(
129
+ fn=function_to_call,
130
  inputs=[gr.Image(source="webcam"), # with no streaming-> acquire images
131
  gr.Checkbox(value=True, label="LAEO", info="Compute and display LAEO"),
132
  gr.Checkbox(value=False, label="rgb", info="Display output on W/B image"),
133
+ gr.Checkbox(value=True, label="show_keypoints", info="Display keypoints on image"),
134
  ],
135
+ outputs=outputs,
136
+ live=live,
137
+ title=title,
138
  description="This is a demo developed by Federico Figari T. at MaLGa Lab, University of Genoa, Italy. You can choose to have only the Head Pose Estimation or also the LAEO computation (more than 1 person should be in the image). You need to take a picture and the algorithm will calculate the Head Pose and will be showed as an arrow on your face. LAEO, instead is showed colouring the arrow in green.",
139
  )
140
 
141
  demo_upload = gr.Interface(
142
+ fn=function_to_call,
143
  inputs=[gr.Image(source="upload", ), # with no streaming-> acquire images
144
  gr.Checkbox(value=True, label="LAEO", info="Compute and display LAEO"),
145
  gr.Checkbox(value=False, label="rgb", info="Display output on W/B image"),
146
+ gr.Checkbox(value=True, label="show_keypoints", info="Display keypoints on image"),
147
  ],
148
+ outputs=outputs,
149
+ live=live,
150
+ title=title,
151
  description="This is a demo developed by Federico Figari T. at MaLGa Lab, University of Genoa, Italy. You can choose to have only the Head Pose Estimation or also the LAEO computation (more than 1 person should be in the image). You need to upload an image and the algorithm will calculate the Head Pose and will be showed as an arrow on your face. LAEO, instead is showed colouring the arrow in green.",
152
  examples=[["LAEO_demo_data/examples/1.jpg"], ["LAEO_demo_data/examples/20.jpg"]]
153
  )