human_animal_pose.py 5.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137
  1. # Copyright (c) OpenMMLab. All rights reserved.
  2. executor_cfg = dict(
  3. # Basic configurations of the executor
  4. name='Pose Estimation',
  5. camera_id=0,
  6. # Define nodes.
  7. # The configuration of a node usually includes:
  8. # 1. 'type': Node class name
  9. # 2. 'name': Node name
  10. # 3. I/O buffers (e.g. 'input_buffer', 'output_buffer'): specify the
  11. # input and output buffer names. This may depend on the node class.
  12. # 4. 'enable_key': assign a hot-key to toggle enable/disable this node.
  13. # This may depend on the node class.
  14. # 5. Other class-specific arguments
  15. nodes=[
  16. # 'DetectorNode':
  17. # This node performs object detection from the frame image using an
  18. # MMDetection model.
  19. dict(
  20. type='DetectorNode',
  21. name='detector',
  22. model_config='demo/mmdetection_cfg/'
  23. 'ssdlite_mobilenetv2-scratch_8xb24-600e_coco.py',
  24. model_checkpoint='https://download.openmmlab.com'
  25. '/mmdetection/v2.0/ssd/'
  26. 'ssdlite_mobilenetv2_scratch_600e_coco/ssdlite_mobilenetv2_'
  27. 'scratch_600e_coco_20210629_110627-974d9307.pth',
  28. input_buffer='_input_', # `_input_` is an executor-reserved buffer
  29. output_buffer='det_result'),
  30. # 'TopdownPoseEstimatorNode':
  31. # This node performs keypoint detection from the frame image using an
  32. # MMPose top-down model. Detection results is needed.
  33. dict(
  34. type='TopdownPoseEstimatorNode',
  35. name='human pose estimator',
  36. model_config='configs/wholebody_2d_keypoint/'
  37. 'topdown_heatmap/coco-wholebody/'
  38. 'td-hm_vipnas-mbv3_dark-8xb64-210e_coco-wholebody-256x192.py',
  39. model_checkpoint='https://download.openmmlab.com/mmpose/'
  40. 'top_down/vipnas/vipnas_mbv3_coco_wholebody_256x192_dark'
  41. '-e2158108_20211205.pth',
  42. labels=['person'],
  43. input_buffer='det_result',
  44. output_buffer='human_pose'),
  45. dict(
  46. type='TopdownPoseEstimatorNode',
  47. name='animal pose estimator',
  48. model_config='configs/animal_2d_keypoint/topdown_heatmap/'
  49. 'animalpose/td-hm_hrnet-w32_8xb64-210e_animalpose-256x256.py',
  50. model_checkpoint='https://download.openmmlab.com/mmpose/animal/'
  51. 'hrnet/hrnet_w32_animalpose_256x256-1aa7f075_20210426.pth',
  52. labels=['cat', 'dog', 'horse', 'sheep', 'cow'],
  53. input_buffer='human_pose',
  54. output_buffer='animal_pose'),
  55. # 'ObjectAssignerNode':
  56. # This node binds the latest model inference result with the current
  57. # frame. (This means the frame image and inference result may be
  58. # asynchronous).
  59. dict(
  60. type='ObjectAssignerNode',
  61. name='object assigner',
  62. frame_buffer='_frame_', # `_frame_` is an executor-reserved buffer
  63. object_buffer='animal_pose',
  64. output_buffer='frame'),
  65. # 'ObjectVisualizerNode':
  66. # This node draw the pose visualization result in the frame image.
  67. # Pose results is needed.
  68. dict(
  69. type='ObjectVisualizerNode',
  70. name='object visualizer',
  71. enable_key='v',
  72. enable=True,
  73. show_bbox=True,
  74. must_have_keypoint=False,
  75. show_keypoint=True,
  76. input_buffer='frame',
  77. output_buffer='vis'),
  78. # 'SunglassesNode':
  79. # This node draw the sunglasses effect in the frame image.
  80. # Pose results is needed.
  81. dict(
  82. type='SunglassesEffectNode',
  83. name='sunglasses',
  84. enable_key='s',
  85. enable=False,
  86. input_buffer='vis',
  87. output_buffer='vis_sunglasses'),
  88. # 'BigeyeEffectNode':
  89. # This node draw the big-eye effetc in the frame image.
  90. # Pose results is needed.
  91. dict(
  92. type='BigeyeEffectNode',
  93. name='big-eye',
  94. enable_key='b',
  95. enable=False,
  96. input_buffer='vis_sunglasses',
  97. output_buffer='vis_bigeye'),
  98. # 'NoticeBoardNode':
  99. # This node show a notice board with given content, e.g. help
  100. # information.
  101. dict(
  102. type='NoticeBoardNode',
  103. name='instruction',
  104. enable_key='h',
  105. enable=True,
  106. input_buffer='vis_bigeye',
  107. output_buffer='vis_notice',
  108. content_lines=[
  109. 'This is a demo for pose visualization and simple image '
  110. 'effects. Have fun!', '', 'Hot-keys:',
  111. '"v": Pose estimation result visualization',
  112. '"s": Sunglasses effect B-)', '"b": Big-eye effect 0_0',
  113. '"h": Show help information',
  114. '"m": Show diagnostic information', '"q": Exit'
  115. ],
  116. ),
  117. # 'MonitorNode':
  118. # This node show diagnostic information in the frame image. It can
  119. # be used for debugging or monitoring system resource status.
  120. dict(
  121. type='MonitorNode',
  122. name='monitor',
  123. enable_key='m',
  124. enable=False,
  125. input_buffer='vis_notice',
  126. output_buffer='display'),
  127. # 'RecorderNode':
  128. # This node save the output video into a file.
  129. dict(
  130. type='RecorderNode',
  131. name='recorder',
  132. out_video_file='webcam_api_demo.mp4',
  133. input_buffer='display',
  134. output_buffer='_display_'
  135. # `_display_` is an executor-reserved buffer
  136. )
  137. ])