Skip to content

Commit 2ab56bc

Browse files
authored
[Refactor] Remove webcam API (#2511)
1 parent 0855fca commit 2ab56bc

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

55 files changed

+53
-5318
lines changed

demo/docs/en/webcam_api_demo.md

Lines changed: 18 additions & 92 deletions
Original file line numberDiff line numberDiff line change
@@ -1,104 +1,30 @@
11
## Webcam Demo
22

3-
We provide a webcam demo tool which integrartes detection and 2D pose estimation for humans and animals. It can also apply fun effects like putting on sunglasses or enlarging the eyes, based on the pose estimation results.
3+
The original Webcam API has been deprecated starting from version v1.1.0. Users now have the option to utilize either the Inferencer or the demo script for conducting pose estimation using webcam input.
44

5-
<div align="center">
6-
<img src="https://user-images.githubusercontent.com/15977946/124059525-ce20c580-da5d-11eb-8e4a-2d96cd31fe9f.gif" width="600px" alt><br>
7-
</div>
5+
### Webcam Demo with Inferencer
86

9-
### Get started
10-
11-
Launch the demo from the mmpose root directory:
12-
13-
```shell
14-
# Run webcam demo with GPU
15-
python demo/webcam_api_demo.py
16-
17-
# Run webcam demo with CPU
18-
python demo/webcam_api_demo.py --cpu
19-
```
20-
21-
The command above will use the default config file `demo/webcam_cfg/human_pose.py`. You can also specify the config file in the command:
7+
Users can utilize the MMPose Inferencer to estimate human poses in webcam inputs by executing the following command:
228

239
```shell
24-
python demo/webcam_api_demo.py --config demo/webcam_cfg/human_pose.py
10+
python demo/inferencer_demo.py webcam --pose2d 'human'
2511
```
2612

27-
### Hotkeys
28-
29-
| Hotkey | Function |
30-
| ------ | ------------------------------------- |
31-
| v | Toggle the pose visualization on/off. |
32-
| h | Show help information. |
33-
| m | Show the monitoring information. |
34-
| q | Exit. |
35-
36-
Note that the demo will automatically save the output video into a file `webcam_api_demo.mp4`.
13+
For additional information about the arguments of Inferencer, please refer to the [Inferencer Documentation](/docs/en/user_guides/inference.md).
3714

38-
### Usage and configuarations
15+
### Webcam Demo with Demo Script
3916

40-
Detailed configurations can be found in the config file.
17+
All of the demo scripts, except for `demo/image_demo.py`, support webcam input.
4118

42-
- **Configure detection models**
43-
Users can choose detection models from the [MMDetection Model Zoo](https://mmdetection.readthedocs.io/en/3.x/model_zoo.html). Just set the `model_config` and `model_checkpoint` in the detector node accordingly, and the model will be automatically downloaded and loaded.
19+
Take `demo/topdown_demo_with_mmdet.py` as example, users can utilize this script with webcam input by specifying **`--input webcam`** in the command:
4420

45-
```python
46-
# 'DetectorNode':
47-
# This node performs object detection from the frame image using an
48-
# MMDetection model.
49-
dict(
50-
type='DetectorNode',
51-
name='detector',
52-
model_config='demo/mmdetection_cfg/'
53-
'ssdlite_mobilenetv2-scratch_8xb24-600e_coco.py',
54-
model_checkpoint='https://download.openmmlab.com'
55-
'/mmdetection/v2.0/ssd/'
56-
'ssdlite_mobilenetv2_scratch_600e_coco/ssdlite_mobilenetv2_'
57-
'scratch_600e_coco_20210629_110627-974d9307.pth',
58-
input_buffer='_input_',
59-
output_buffer='det_result'),
60-
```
61-
62-
- **Configure pose estimation models**
63-
In this demo we use two [top-down](https://github.com/open-mmlab/mmpose/tree/latest/configs/body_2d_keypoint/topdown_heatmap) pose estimation models for humans and animals respectively. Users can choose models from the [MMPose Model Zoo](https://mmpose.readthedocs.io/en/latest/modelzoo.html). To apply different pose models on different instance types, you can add multiple pose estimator nodes with `cls_names` set accordingly.
64-
65-
```python
66-
# 'TopdownPoseEstimatorNode':
67-
# This node performs keypoint detection from the frame image using an
68-
# MMPose top-down model. Detection results is needed.
69-
dict(
70-
type='TopdownPoseEstimatorNode',
71-
name='human pose estimator',
72-
model_config='configs/wholebody_2d_keypoint/'
73-
'topdown_heatmap/coco-wholebody/'
74-
'td-hm_vipnas-mbv3_dark-8xb64-210e_coco-wholebody-256x192.py',
75-
model_checkpoint='https://download.openmmlab.com/mmpose/'
76-
'top_down/vipnas/vipnas_mbv3_coco_wholebody_256x192_dark'
77-
'-e2158108_20211205.pth',
78-
labels=['person'],
79-
input_buffer='det_result',
80-
output_buffer='human_pose'),
81-
dict(
82-
type='TopdownPoseEstimatorNode',
83-
name='animal pose estimator',
84-
model_config='configs/animal_2d_keypoint/topdown_heatmap/'
85-
'animalpose/td-hm_hrnet-w32_8xb64-210e_animalpose-256x256.py',
86-
model_checkpoint='https://download.openmmlab.com/mmpose/animal/'
87-
'hrnet/hrnet_w32_animalpose_256x256-1aa7f075_20210426.pth',
88-
labels=['cat', 'dog', 'horse', 'sheep', 'cow'],
89-
input_buffer='human_pose',
90-
output_buffer='animal_pose'),
91-
```
92-
93-
- **Run the demo on a local video file**
94-
You can use local video files as the demo input by set `camera_id` to the file path.
95-
96-
- **The computer doesn't have a camera?**
97-
A smart phone can serve as a webcam via apps like [Camo](https://reincubate.com/camo/) or [DroidCam](https://www.dev47apps.com/).
98-
99-
- **Test the camera and display**
100-
Run follow command for a quick test of video capturing and displaying.
101-
102-
```shell
103-
python demo/webcam_api_demo.py --config demo/webcam_cfg/test_camera.py
104-
```
21+
```shell
22+
# inference with webcam
23+
python demo/topdown_demo_with_mmdet.py \
24+
projects/rtmpose/rtmdet/person/rtmdet_nano_320-8xb32_coco-person.py \
25+
https://download.openmmlab.com/mmpose/v1/projects/rtmpose/rtmdet_nano_8xb32-100e_coco-obj365-person-05d8511e.pth \
26+
projects/rtmpose/rtmpose/body_2d_keypoint/rtmpose-m_8xb256-420e_coco-256x192.py \
27+
https://download.openmmlab.com/mmpose/v1/projects/rtmposev1/rtmpose-m_simcc-aic-coco_pt-aic-coco_420e-256x192-63eb25f7_20230126.pth \
28+
--input webcam \
29+
--show
30+
```

demo/docs/zh_cn/webcam_api_demo.md

Lines changed: 19 additions & 98 deletions
Original file line numberDiff line numberDiff line change
@@ -1,109 +1,30 @@
1-
## Webcam Demo
1+
## 摄像头推理
22

3-
我们提供了同时支持人体和动物的识别和 2D 姿态预估 webcam demo 工具,用户也可以用这个脚本在姿态预测结果上加入譬如大眼和戴墨镜等好玩的特效
3+
从版本 v1.1.0 开始,原来的摄像头 API 已被弃用。用户现在可以选择使用推理器(Inferencer)或 Demo 脚本从摄像头读取的视频中进行姿势估计
44

5-
<div align="center">
6-
<img src="https://user-images.githubusercontent.com/15977946/124059525-ce20c580-da5d-11eb-8e4a-2d96cd31fe9f.gif" width="600px" alt><br>
7-
</div>
5+
### 使用推理器进行摄像头推理
86

9-
### Get started
10-
11-
脚本使用方式很简单,直接在 MMPose 根路径使用:
12-
13-
```shell
14-
# 使用 GPU
15-
python demo/webcam_api_demo.py
16-
17-
# 仅使用 CPU
18-
python demo/webcam_api_demo.py --cpu
19-
```
20-
21-
该命令会使用默认的 `demo/webcam_cfg/human_pose.py` 作为配置文件,用户可以自行指定别的配置:
7+
用户可以通过执行以下命令来利用 MMPose Inferencer 对摄像头输入进行人体姿势估计:
228

239
```shell
24-
python demo/webcam_api_demo.py --config demo/webcam_cfg/human_pose.py
10+
python demo/inferencer_demo.py webcam --pose2d 'human'
2511
```
2612

27-
### Hotkeys
28-
29-
| Hotkey | Function |
30-
| ------ | ------------------------------------- |
31-
| v | Toggle the pose visualization on/off. |
32-
| h | Show help information. |
33-
| m | Show the monitoring information. |
34-
| q | Exit. |
35-
36-
注意:脚本会自动将实时结果保存成一个名为 `webcam_api_demo.mp4` 的视频文件。
37-
38-
### 配置使用
39-
40-
这里我们只进行一些基本的说明,更多的信息可以直接参考对应的配置文件。
41-
42-
- **设置检测模型**
13+
有关推理器的参数详细信息,请参阅 [推理器文档](/docs/en/user_guides/inference.md)
4314

44-
用户可以直接使用 [MMDetection Model Zoo](https://mmdetection.readthedocs.io/en/3.x/model_zoo.html) 里的识别模型,需要注意的是确保配置文件中的 DetectorNode 里的 `model_config``model_checkpoint` 需要对应起来,这样模型就会被自动下载和加载,例如:
15+
### 使用 Demo 脚本进行摄像头推理
4516

46-
```python
47-
# 'DetectorNode':
48-
# This node performs object detection from the frame image using an
49-
# MMDetection model.
50-
dict(
51-
type='DetectorNode',
52-
name='detector',
53-
model_config='demo/mmdetection_cfg/'
54-
'ssdlite_mobilenetv2-scratch_8xb24-600e_coco.py',
55-
model_checkpoint='https://download.openmmlab.com'
56-
'/mmdetection/v2.0/ssd/'
57-
'ssdlite_mobilenetv2_scratch_600e_coco/ssdlite_mobilenetv2_'
58-
'scratch_600e_coco_20210629_110627-974d9307.pth',
59-
input_buffer='_input_',
60-
output_buffer='det_result'),
61-
```
17+
除了 `demo/image_demo.py` 之外,所有的 Demo 脚本都支持摄像头输入。
6218

63-
- **设置姿态预估模型**
19+
`demo/topdown_demo_with_mmdet.py` 为例,用户可以通过在命令中指定 **`--input webcam`** 来使用该脚本对摄像头输入进行推理:
6420

65-
这里我们用两个 [top-down](https://github.com/open-mmlab/mmpose/tree/latest/configs/body_2d_keypoint/topdown_heatmap) 结构的人体和动物姿态预估模型进行演示。用户可以自由使用 [MMPose Model Zoo](https://mmpose.readthedocs.io/zh_CN/latest/model_zoo/body_2d_keypoint.html) 里的模型。需要注意的是,更换模型后用户需要在对应的 pose estimate node 里添加或修改对应的 `cls_names` ,例如:
66-
67-
```python
68-
# 'TopdownPoseEstimatorNode':
69-
# This node performs keypoint detection from the frame image using an
70-
# MMPose top-down model. Detection results is needed.
71-
dict(
72-
type='TopdownPoseEstimatorNode',
73-
name='human pose estimator',
74-
model_config='configs/wholebody_2d_keypoint/'
75-
'topdown_heatmap/coco-wholebody/'
76-
'td-hm_vipnas-mbv3_dark-8xb64-210e_coco-wholebody-256x192.py',
77-
model_checkpoint='https://download.openmmlab.com/mmpose/'
78-
'top_down/vipnas/vipnas_mbv3_coco_wholebody_256x192_dark'
79-
'-e2158108_20211205.pth',
80-
labels=['person'],
81-
input_buffer='det_result',
82-
output_buffer='human_pose'),
83-
dict(
84-
type='TopdownPoseEstimatorNode',
85-
name='animal pose estimator',
86-
model_config='configs/animal_2d_keypoint/topdown_heatmap/'
87-
'animalpose/td-hm_hrnet-w32_8xb64-210e_animalpose-256x256.py',
88-
model_checkpoint='https://download.openmmlab.com/mmpose/animal/'
89-
'hrnet/hrnet_w32_animalpose_256x256-1aa7f075_20210426.pth',
90-
labels=['cat', 'dog', 'horse', 'sheep', 'cow'],
91-
input_buffer='human_pose',
92-
output_buffer='animal_pose'),
93-
```
94-
95-
- **使用本地视频文件**
96-
97-
如果想直接使用本地的视频文件,用户只需要把文件路径设置到 `camera_id` 就行。
98-
99-
- **本机没有摄像头怎么办**
100-
101-
用户可以在自己手机安装上一些 app 就能替代摄像头,例如 [Camo](https://reincubate.com/camo/)[DroidCam](https://www.dev47apps.com/)
102-
103-
- **测试摄像头和显示器连接**
104-
105-
使用如下命令就能完成检测:
106-
107-
```shell
108-
python demo/webcam_api_demo.py --config demo/webcam_cfg/test_camera.py
109-
```
21+
```shell
22+
# inference with webcam
23+
python demo/topdown_demo_with_mmdet.py \
24+
projects/rtmpose/rtmdet/person/rtmdet_nano_320-8xb32_coco-person.py \
25+
https://download.openmmlab.com/mmpose/v1/projects/rtmpose/rtmdet_nano_8xb32-100e_coco-obj365-person-05d8511e.pth \
26+
projects/rtmpose/rtmpose/body_2d_keypoint/rtmpose-m_8xb256-420e_coco-256x192.py \
27+
https://download.openmmlab.com/mmpose/v1/projects/rtmposev1/rtmpose-m_simcc-aic-coco_pt-aic-coco_420e-256x192-63eb25f7_20230126.pth \
28+
--input webcam \
29+
--show
30+
```

demo/webcam_api_demo.py

Lines changed: 0 additions & 76 deletions
This file was deleted.

0 commit comments

Comments
 (0)