Skip to content

Commit

Permalink
[Feature]: Support deployment of panoptic segmentation models (#2347)
Browse files Browse the repository at this point in the history
* add semantic segmentation head

 Author:    Daigo Hirooka <[email protected]>
 Date:      Sun Jun 26 18:25:29 2022 +0900

* add panoptic detection model

* add panoptic segmentation configs

* support panoptic-fpn

* remove interpolate

* update

* support panoptic-fpn mask2former maskformer

* update

* support dynamic

* update

* remove unused rewritings for mask2former

* Revert "remove unused rewritings for mask2former"

This reverts commit 2b6d24a.

* update configs and regs

* debug dynamic

* fix for panoptic-fpn

* update

* remove rewritings for mask2former

* update reg test config

* fix

* update docs

* fix comments

* fix

---------

Co-authored-by: Daigo Hirooka <[email protected]>
  • Loading branch information
RunningLeon and daigo0927 authored Aug 25, 2023
1 parent 4dbba14 commit b7024dd
Show file tree
Hide file tree
Showing 22 changed files with 652 additions and 106 deletions.
6 changes: 6 additions & 0 deletions .github/scripts/prepare_reg_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -98,6 +98,12 @@ def prepare_codebases(codebases):
f'{MMDEPLOY_DIR}/configs/mmyolo')
shutil.copy(f'{target_dir}/tests/regression/mmyolo.yml',
f'{MMDEPLOY_DIR}/tests/regression/mmyolo.yml')
elif codebase == 'mmdet':
# for panoptic
run_cmd([
'python -m pip install ',
'git+https://github.com/cocodataset/panopticapi.git',
])


def install_torch(torch_version):
Expand Down
15 changes: 15 additions & 0 deletions configs/mmdet/_base_/base_panoptic-seg_static.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
_base_ = ['../../_base_/onnx_config.py']

codebase_config = dict(
type='mmdet',
task='ObjectDetection',
model_type='panoptic_end2end',
post_processing=dict(
export_postprocess_mask=False,
score_threshold=0.0,
iou_threshold=0.5,
max_output_boxes_per_class=200,
pre_top_k=5000,
keep_top_k=100,
background_label_id=-1,
))
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
_base_ = [
'./panoptic-seg_maskformer_onnxruntime_static-800x1344.py',
]
onnx_config = dict(
dynamic_axes={
'input': {
0: 'batch',
2: 'height',
3: 'width'
},
'cls_logits': {
0: 'batch',
},
'mask_logits': {
0: 'batch',
2: 'h',
3: 'w',
},
},
input_shape=None)
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
_base_ = [
'../_base_/base_panoptic-seg_static.py',
'../../_base_/backends/onnxruntime.py'
]
onnx_config = dict(
opset_version=13,
output_names=['cls_logits', 'mask_logits'],
input_shape=[1344, 800])
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
_base_ = ['./panoptic-seg_maskformer_tensorrt_static-800x1344.py']
onnx_config = dict(
dynamic_axes={
'input': {
0: 'batch',
2: 'height',
3: 'width'
},
'cls_logits': {
0: 'batch',
},
'mask_logits': {
0: 'batch',
2: 'h',
3: 'w',
},
},
input_shape=None)

backend_config = dict(model_inputs=[
dict(
input_shapes=dict(
input=dict(
min_shape=[1, 3, 320, 512],
opt_shape=[1, 3, 800, 1344],
max_shape=[1, 3, 1344, 1344])))
])
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
_base_ = [
'../_base_/base_panoptic-seg_static.py',
'../../_base_/backends/tensorrt.py'
]
onnx_config = dict(
opset_version=13,
output_names=['cls_logits', 'mask_logits'],
input_shape=[1344, 800])

backend_config = dict(
common_config=dict(max_workspace_size=1 << 30),
model_inputs=[
dict(
input_shapes=dict(
input=dict(
min_shape=[1, 3, 800, 1344],
opt_shape=[1, 3, 800, 1344],
max_shape=[1, 3, 800, 1344])))
])
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
_base_ = [
'../_base_/base_panoptic-seg_static.py',
'../../_base_/backends/onnxruntime.py'
]
onnx_config = dict(
input_shape=None,
output_names=['dets', 'labels', 'masks', 'semseg'],
dynamic_axes={
'input': {
0: 'batch',
2: 'height',
3: 'width'
},
'dets': {
0: 'batch',
1: 'num_dets',
},
'labels': {
0: 'batch',
1: 'num_dets',
},
'masks': {
0: 'batch',
1: 'num_dets',
},
'semseg': {
0: 'batch',
2: 'height',
3: 'width'
},
},
)
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
_base_ = [
'../_base_/base_panoptic-seg_static.py',
'../../_base_/backends/tensorrt.py'
]
onnx_config = dict(
input_shape=None,
output_names=['dets', 'labels', 'masks', 'semseg'],
dynamic_axes={
'input': {
0: 'batch',
2: 'height',
3: 'width'
},
'dets': {
0: 'batch',
1: 'num_dets',
},
'labels': {
0: 'batch',
1: 'num_dets',
},
'masks': {
0: 'batch',
1: 'num_dets',
},
'semseg': {
0: 'batch',
2: 'height',
3: 'width'
},
},
)

backend_config = dict(
common_config=dict(max_workspace_size=1 << 30),
model_inputs=[
dict(
input_shapes=dict(
input=dict(
min_shape=[1, 3, 352, 512],
opt_shape=[1, 3, 800, 1344],
max_shape=[1, 3, 1344, 1344])))
])
57 changes: 33 additions & 24 deletions docs/en/04-supported-codebases/mmdet.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
- [Backend model inference](#backend-model-inference)
- [SDK model inference](#sdk-model-inference)
- [Supported models](#supported-models)
- [Reminder](#reminder)

______________________________________________________________________

Expand Down Expand Up @@ -189,27 +190,35 @@ Besides python API, mmdeploy SDK also provides other FFI (Foreign Function Inter

## Supported models

| Model | Task | OnnxRuntime | TensorRT | ncnn | PPLNN | OpenVINO |
| :-------------------------------------------------------------------------------------------: | :-------------------: | :---------: | :------: | :--: | :---: | :------: |
| [ATSS](https://github.com/open-mmlab/mmdetection/tree/3.x/configs/atss) | Object Detection | Y | Y | N | N | Y |
| [FCOS](https://github.com/open-mmlab/mmdetection/tree/3.x/configs/fcos) | Object Detection | Y | Y | Y | N | Y |
| [FoveaBox](https://github.com/open-mmlab/mmdetection/tree/3.x/configs/foveabox) | Object Detection | Y | N | N | N | Y |
| [FSAF](https://github.com/open-mmlab/mmdetection/tree/3.x/configs/fsaf) | Object Detection | Y | Y | Y | Y | Y |
| [RetinaNet](https://github.com/open-mmlab/mmdetection/tree/3.x/configs/retinanet) | Object Detection | Y | Y | Y | Y | Y |
| [SSD](https://github.com/open-mmlab/mmdetection/tree/3.x/configs/ssd) | Object Detection | Y | Y | Y | N | Y |
| [VFNet](https://github.com/open-mmlab/mmdetection/tree/3.x/configs/vfnet) | Object Detection | N | N | N | N | Y |
| [YOLOv3](https://github.com/open-mmlab/mmdetection/tree/3.x/configs/yolo) | Object Detection | Y | Y | Y | N | Y |
| [YOLOX](https://github.com/open-mmlab/mmdetection/tree/3.x/configs/yolox) | Object Detection | Y | Y | Y | N | Y |
| [Cascade R-CNN](https://github.com/open-mmlab/mmdetection/tree/3.x/configs/cascade_rcnn) | Object Detection | Y | Y | N | Y | Y |
| [Faster R-CNN](https://github.com/open-mmlab/mmdetection/tree/3.x/configs/faster_rcnn) | Object Detection | Y | Y | Y | Y | Y |
| [Faster R-CNN + DCN](https://github.com/open-mmlab/mmdetection/tree/3.x/configs/faster_rcnn) | Object Detection | Y | Y | Y | Y | Y |
| [GFL](https://github.com/open-mmlab/mmdetection/tree/3.x/configs/gfl) | Object Detection | Y | Y | N | ? | Y |
| [RepPoints](https://github.com/open-mmlab/mmdetection/tree/3.x/configs/reppoints) | Object Detection | N | Y | N | ? | Y |
| [DETR](https://github.com/open-mmlab/mmdetection/tree/3.x/configs/detr) | Object Detection | Y | Y | N | ? | Y |
| [CenterNet](https://github.com/open-mmlab/mmdetection/tree/3.x/configs/centernet) | Object Detection | Y | Y | N | ? | Y |
| [RTMDet](https://github.com/open-mmlab/mmdetection/tree/3.x/configs/rtmdet) | Object Detection | Y | Y | N | ? | Y |
| [Cascade Mask R-CNN](https://github.com/open-mmlab/mmdetection/tree/3.x/configs/cascade_rcnn) | Instance Segmentation | Y | Y | N | N | Y |
| [Mask R-CNN](https://github.com/open-mmlab/mmdetection/tree/3.x/configs/mask_rcnn) | Instance Segmentation | Y | Y | N | N | Y |
| [Swin Transformer](https://github.com/open-mmlab/mmdetection/tree/3.x/configs/swin) | Instance Segmentation | Y | Y | N | N | Y |
| [SOLO](https://github.com/open-mmlab/mmdetection/tree/3.x/configs/solo) | Instance Segmentation | Y | N | N | N | Y |
| [SOLOv2](https://github.com/open-mmlab/mmdetection/tree/3.x/configs/solov2) | Instance Segmentation | Y | N | N | N | Y |
| Model | Task | OnnxRuntime | TensorRT | ncnn | PPLNN | OpenVINO |
| :------------------------------------------------------------------------------------------------------: | :-------------------: | :---------: | :------: | :--: | :---: | :------: |
| [ATSS](https://github.com/open-mmlab/mmdetection/tree/3.x/configs/atss) | Object Detection | Y | Y | N | N | Y |
| [FCOS](https://github.com/open-mmlab/mmdetection/tree/3.x/configs/fcos) | Object Detection | Y | Y | Y | N | Y |
| [FoveaBox](https://github.com/open-mmlab/mmdetection/tree/3.x/configs/foveabox) | Object Detection | Y | N | N | N | Y |
| [FSAF](https://github.com/open-mmlab/mmdetection/tree/3.x/configs/fsaf) | Object Detection | Y | Y | Y | Y | Y |
| [RetinaNet](https://github.com/open-mmlab/mmdetection/tree/3.x/configs/retinanet) | Object Detection | Y | Y | Y | Y | Y |
| [SSD](https://github.com/open-mmlab/mmdetection/tree/3.x/configs/ssd) | Object Detection | Y | Y | Y | N | Y |
| [VFNet](https://github.com/open-mmlab/mmdetection/tree/3.x/configs/vfnet) | Object Detection | N | N | N | N | Y |
| [YOLOv3](https://github.com/open-mmlab/mmdetection/tree/3.x/configs/yolo) | Object Detection | Y | Y | Y | N | Y |
| [YOLOX](https://github.com/open-mmlab/mmdetection/tree/3.x/configs/yolox) | Object Detection | Y | Y | Y | N | Y |
| [Cascade R-CNN](https://github.com/open-mmlab/mmdetection/tree/3.x/configs/cascade_rcnn) | Object Detection | Y | Y | N | Y | Y |
| [Faster R-CNN](https://github.com/open-mmlab/mmdetection/tree/3.x/configs/faster_rcnn) | Object Detection | Y | Y | Y | Y | Y |
| [Faster R-CNN + DCN](https://github.com/open-mmlab/mmdetection/tree/3.x/configs/faster_rcnn) | Object Detection | Y | Y | Y | Y | Y |
| [GFL](https://github.com/open-mmlab/mmdetection/tree/3.x/configs/gfl) | Object Detection | Y | Y | N | ? | Y |
| [RepPoints](https://github.com/open-mmlab/mmdetection/tree/3.x/configs/reppoints) | Object Detection | N | Y | N | ? | Y |
| [DETR](https://github.com/open-mmlab/mmdetection/tree/3.x/configs/detr) | Object Detection | Y | Y | N | ? | Y |
| [CenterNet](https://github.com/open-mmlab/mmdetection/tree/3.x/configs/centernet) | Object Detection | Y | Y | N | ? | Y |
| [RTMDet](https://github.com/open-mmlab/mmdetection/tree/3.x/configs/rtmdet) | Object Detection | Y | Y | N | ? | Y |
| [Cascade Mask R-CNN](https://github.com/open-mmlab/mmdetection/tree/3.x/configs/cascade_rcnn) | Instance Segmentation | Y | Y | N | N | Y |
| [Mask R-CNN](https://github.com/open-mmlab/mmdetection/tree/3.x/configs/mask_rcnn) | Instance Segmentation | Y | Y | N | N | Y |
| [Swin Transformer](https://github.com/open-mmlab/mmdetection/tree/3.x/configs/swin) | Instance Segmentation | Y | Y | N | N | Y |
| [SOLO](https://github.com/open-mmlab/mmdetection/tree/3.x/configs/solo) | Instance Segmentation | Y | N | N | N | Y |
| [SOLOv2](https://github.com/open-mmlab/mmdetection/tree/3.x/configs/solov2) | Instance Segmentation | Y | N | N | N | Y |
| [Panoptic FPN](https://github.com/open-mmlab/mmdetection/tree/main/configs/panoptic_fpn) | Panoptic Segmentation | Y | Y | N | N | N |
| [MaskFormer](https://github.com/open-mmlab/mmdetection/tree/main/configs/maskformer) | Panoptic Segmentation | Y | Y | N | N | N |
| [Mask2Former](https://github.com/open-mmlab/mmdetection/tree/main/configs/mask2former)[\*](#mask2former) | Panoptic Segmentation | Y | Y | N | N | N |

## Reminder

- For transformer based models, strongly suggest use `TensorRT>=8.4`.
- <i id="mask2former">Mask2Former</i> should use `TensorRT>=8.6.1` for dynamic shape inference.
Loading

0 comments on commit b7024dd

Please sign in to comment.