Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Refactor] Update the arguments of 3d inferencer to align with the demo script #2561

Merged
merged 4 commits into from
Jul 21, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 13 additions & 5 deletions demo/inferencer_demo.py
Original file line number Diff line number Diff line change
Expand Up @@ -104,12 +104,20 @@ def parse_args():
'the average bbox center of the dataset. This is useful when bbox '
'is small, especially in multi-person scenarios.')
parser.add_argument(
'--rebase-keypoint-height',
'--disable-rebase-keypoint',
action='store_true',
help='Rebase the predicted 3D pose so its lowest keypoint has a '
'height of 0 (landing on the ground). This is useful for '
'visualization when the model do not predict the global position '
'of the 3D pose.')
default=False,
help='Whether to disable rebasing the predicted 3D pose so its '
'lowest keypoint has a height of 0 (landing on the ground). Rebase '
'is useful for visualization when the model do not predict the '
'global position of the 3D pose.')
parser.add_argument(
'--num-instances',
type=int,
default=1,
help='The number of 3D poses to be visualized in every frame. If '
'less than 0, it will be set to the number of pose results in the '
'first frame.')
parser.add_argument(
'--radius',
type=int,
Expand Down
39 changes: 20 additions & 19 deletions docs/en/user_guides/inference.md
Original file line number Diff line number Diff line change
Expand Up @@ -235,25 +235,26 @@ The `MMPoseInferencer` offers a variety of arguments for customizing pose estima

The inferencer is designed for both visualization and saving predictions. The table below presents the list of arguments available when using the `MMPoseInferencer` for inference, along with their compatibility with 2D and 3D inferencing:

| Argument | Description | 2D | 3D |
| ------------------------ | ----------------------------------------------------------------------------------------------------------------------------------------------------------------- | --- | --- |
| `show` | Controls the display of the image or video in a pop-up window. | ✔️ | ✔️ |
| `radius` | Sets the visualization keypoint radius. | ✔️ | ✔️ |
| `thickness` | Determines the link thickness for visualization. | ✔️ | ✔️ |
| `kpt_thr` | Sets the keypoint score threshold. Keypoints with scores exceeding this threshold will be displayed. | ✔️ | ✔️ |
| `draw_bbox` | Decides whether to display the bounding boxes of instances. | ✔️ | ✔️ |
| `draw_heatmap` | Decides if the predicted heatmaps should be drawn. | ✔️ | ❌ |
| `black_background` | Decides whether the estimated poses should be displayed on a black background. | ✔️ | ❌ |
| `skeleton_style` | Sets the skeleton style. Options include 'mmpose' (default) and 'openpose'. | ✔️ | ❌ |
| `use_oks_tracking` | Decides whether to use OKS as a similarity measure in tracking. | ❌ | ✔️ |
| `tracking_thr` | Sets the similarity threshold for tracking. | ❌ | ✔️ |
| `norm_pose_2d` | Decides whether to scale the bounding box to the dataset's average bounding box scale and relocate the bounding box to the dataset's average bounding box center. | ❌ | ✔️ |
| `rebase_keypoint_height` | Decides whether to set the lowest keypoint with height 0. | ❌ | ✔️ |
| `return_vis` | Decides whether to include visualization images in the results. | ✔️ | ✔️ |
| `vis_out_dir` | Defines the folder path to save the visualization images. If unset, the visualization images will not be saved. | ✔️ | ✔️ |
| `return_datasample` | Determines if the prediction should be returned in the `PoseDataSample` format. | ✔️ | ✔️ |
| `pred_out_dir` | Specifies the folder path to save the predictions. If unset, the predictions will not be saved. | ✔️ | ✔️ |
| `out_dir` | If `vis_out_dir` or `pred_out_dir` is unset, these will be set to `f'{out_dir}/visualization'` or `f'{out_dir}/predictions'`, respectively. | ✔️ | ✔️ |
| Argument | Description | 2D | 3D |
| ------------------------- | ----------------------------------------------------------------------------------------------------------------------------------------------------------------- | --- | --- |
| `show` | Controls the display of the image or video in a pop-up window. | ✔️ | ✔️ |
| `radius` | Sets the visualization keypoint radius. | ✔️ | ✔️ |
| `thickness` | Determines the link thickness for visualization. | ✔️ | ✔️ |
| `kpt_thr` | Sets the keypoint score threshold. Keypoints with scores exceeding this threshold will be displayed. | ✔️ | ✔️ |
| `draw_bbox` | Decides whether to display the bounding boxes of instances. | ✔️ | ✔️ |
| `draw_heatmap` | Decides if the predicted heatmaps should be drawn. | ✔️ | ❌ |
| `black_background` | Decides whether the estimated poses should be displayed on a black background. | ✔️ | ❌ |
| `skeleton_style` | Sets the skeleton style. Options include 'mmpose' (default) and 'openpose'. | ✔️ | ❌ |
| `use_oks_tracking` | Decides whether to use OKS as a similarity measure in tracking. | ❌ | ✔️ |
| `tracking_thr` | Sets the similarity threshold for tracking. | ❌ | ✔️ |
| `norm_pose_2d` | Decides whether to scale the bounding box to the dataset's average bounding box scale and relocate the bounding box to the dataset's average bounding box center. | ❌ | ✔️ |
| `disable_rebase_keypoint` | Decides whether to set the lowest keypoint with height 0. | ❌ | ✔️ |
| `num_instances` | Sets the number of instances to visualize in the results. If set to a negative number, all detected instances will be visualized. | ❌ | ✔️ |
| `return_vis` | Decides whether to include visualization images in the results. | ✔️ | ✔️ |
| `vis_out_dir` | Defines the folder path to save the visualization images. If unset, the visualization images will not be saved. | ✔️ | ✔️ |
| `return_datasample` | Determines if the prediction should be returned in the `PoseDataSample` format. | ✔️ | ✔️ |
| `pred_out_dir` | Specifies the folder path to save the predictions. If unset, the predictions will not be saved. | ✔️ | ✔️ |
| `out_dir` | If `vis_out_dir` or `pred_out_dir` is unset, these will be set to `f'{out_dir}/visualization'` or `f'{out_dir}/predictions'`, respectively. | ✔️ | ✔️ |

### Model Alias

Expand Down
39 changes: 20 additions & 19 deletions docs/zh_cn/user_guides/inference.md
Original file line number Diff line number Diff line change
Expand Up @@ -223,25 +223,26 @@ result = next(result_generator)

推理器被设计用于可视化和保存预测。以下表格列出了在使用 `MMPoseInferencer` <mark>进行推断</mark>时可用的参数列表,以及它们与 2D 和 3D 推理器的兼容性:

| 参数 | 描述 | 2D | 3D |
| ------------------------ | -------------------------------------------------------------------------------------------------------------------------- | --- | --- |
| `show` | 控制是否在弹出窗口中显示图像或视频。 | ✔️ | ✔️ |
| `radius` | 设置可视化关键点的半径。 | ✔️ | ✔️ |
| `thickness` | 确定可视化链接的厚度。 | ✔️ | ✔️ |
| `kpt_thr` | 设置关键点分数阈值。分数超过此阈值的关键点将被显示。 | ✔️ | ✔️ |
| `draw_bbox` | 决定是否显示实例的边界框。 | ✔️ | ✔️ |
| `draw_heatmap` | 决定是否绘制预测的热图。 | ✔️ | ❌ |
| `black_background` | 决定是否在黑色背景上显示预估的姿势。 | ✔️ | ❌ |
| `skeleton_style` | 设置骨架样式。可选项包括 'mmpose'(默认)和 'openpose'。 | ✔️ | ❌ |
| `use_oks_tracking` | 决定是否在追踪中使用OKS作为相似度测量。 | ❌ | ✔️ |
| `tracking_thr` | 设置追踪的相似度阈值。 | ❌ | ✔️ |
| `norm_pose_2d` | 决定是否将边界框缩放至数据集的平均边界框尺寸,并将边界框移至数据集的平均边界框中心。 | ❌ | ✔️ |
| `rebase_keypoint_height` | 决定是否将最低关键点的高度置为 0。 | ❌ | ✔️ |
| `return_vis` | 决定是否在结果中包含可视化图像。 | ✔️ | ✔️ |
| `vis_out_dir` | 定义保存可视化图像的文件夹路径。如果未设置,将不保存可视化图像。 | ✔️ | ✔️ |
| `return_datasample` | 决定是否以 `PoseDataSample` 格式返回预测。 | ✔️ | ✔️ |
| `pred_out_dir` | 指定保存预测的文件夹路径。如果未设置,将不保存预测。 | ✔️ | ✔️ |
| `out_dir` | 如果 `vis_out_dir` 或 `pred_out_dir` 未设置,它们将分别设置为 `f'{out_dir}/visualization'` 或 `f'{out_dir}/predictions'`。 | ✔️ | ✔️ |
| 参数 | 描述 | 2D | 3D |
| ------------------------- | -------------------------------------------------------------------------------------------------------------------------- | --- | --- |
| `show` | 控制是否在弹出窗口中显示图像或视频。 | ✔️ | ✔️ |
| `radius` | 设置可视化关键点的半径。 | ✔️ | ✔️ |
| `thickness` | 确定可视化链接的厚度。 | ✔️ | ✔️ |
| `kpt_thr` | 设置关键点分数阈值。分数超过此阈值的关键点将被显示。 | ✔️ | ✔️ |
| `draw_bbox` | 决定是否显示实例的边界框。 | ✔️ | ✔️ |
| `draw_heatmap` | 决定是否绘制预测的热图。 | ✔️ | ❌ |
| `black_background` | 决定是否在黑色背景上显示预估的姿势。 | ✔️ | ❌ |
| `skeleton_style` | 设置骨架样式。可选项包括 'mmpose'(默认)和 'openpose'。 | ✔️ | ❌ |
| `use_oks_tracking` | 决定是否在追踪中使用OKS作为相似度测量。 | ❌ | ✔️ |
| `tracking_thr` | 设置追踪的相似度阈值。 | ❌ | ✔️ |
| `norm_pose_2d` | 决定是否将边界框缩放至数据集的平均边界框尺寸,并将边界框移至数据集的平均边界框中心。 | ❌ | ✔️ |
| `disable_rebase_keypoint` | 决定是否将最低关键点的高度置为 0。 | ❌ | ✔️ |
| `num_instances` | 设置可视化结果中显示的实例数量。如果设置为负数,则所有实例的结果都会可视化。 | ❌ | ✔️ |
| `return_vis` | 决定是否在结果中包含可视化图像。 | ✔️ | ✔️ |
| `vis_out_dir` | 定义保存可视化图像的文件夹路径。如果未设置,将不保存可视化图像。 | ✔️ | ✔️ |
| `return_datasample` | 决定是否以 `PoseDataSample` 格式返回预测。 | ✔️ | ✔️ |
| `pred_out_dir` | 指定保存预测的文件夹路径。如果未设置,将不保存预测。 | ✔️ | ✔️ |
| `out_dir` | 如果 `vis_out_dir` 或 `pred_out_dir` 未设置,它们将分别设置为 `f'{out_dir}/visualization'` 或 `f'{out_dir}/predictions'`。 | ✔️ | ✔️ |

### 模型别名

Expand Down
4 changes: 2 additions & 2 deletions mmpose/apis/inferencers/mmpose_inferencer.py
Original file line number Diff line number Diff line change
Expand Up @@ -58,11 +58,11 @@ class MMPoseInferencer(BaseMMPoseInferencer):
'bbox_thr', 'nms_thr', 'bboxes', 'use_oks_tracking', 'tracking_thr',
'norm_pose_2d'
}
forward_kwargs: set = {'rebase_keypoint_height'}
forward_kwargs: set = {'disable_rebase_keypoint'}
visualize_kwargs: set = {
'return_vis', 'show', 'wait_time', 'draw_bbox', 'radius', 'thickness',
'kpt_thr', 'vis_out_dir', 'skeleton_style', 'draw_heatmap',
'black_background'
'black_background', 'num_instances'
}
postprocess_kwargs: set = {'pred_out_dir'}

Expand Down
Loading