mmdeploy icon indicating copy to clipboard operation
mmdeploy copied to clipboard

[WIP] Deploy config updater

Open grimoire opened this issue 3 years ago • 1 comments

Thanks for your contribution and we appreciate it a lot. The following instructions would make your pull request more healthy and more easily receiving feedbacks. If you do not understand some items, don't worry, just make the pull request and seek help from maintainers.

Motivation

This PR is a demo about the updater of model config. It is embedded in task processor.

NOTE: this is just a demo. DISCUSSION is required.

Super Resolution and Monocular Detection do not special input shape, so it is not possible to generate config for it.

For example:

# TensorRT config for object detection
# less context and parameters are more readable
ir_config = dict(type='onnx')
codebase_config = dict(
    type='mmdet',
    task='ObjectDetection',
    model_type='end2end',
    is_dynamic_batch=True,
    is_dynamic_size=True,
    # input_shape=(1344, 800),
    detection_mode='detection')
backend_config = dict(
    type='tensorrt',
    common_config=dict(fp16_mode=False, max_workspace_size=1073741824),
)
# generate script
from mmcv import Config
from mmdeploy.apis import build_task_processor

deploy_cfg = './deploy_cfg.py'
model_cfg = 'configs/ssd/ssd300_coco.py'

deploy_cfg = Config.fromfile(deploy_cfg)
model_cfg = Config.fromfile(model_cfg)

task = build_task_processor(model_cfg, deploy_cfg, 'cuda')

codebase_cfg = deploy_cfg['codebase_config'].copy()
codebase_cfg.pop('type')

task.update_deploy_config(deploy_cfg, **codebase_cfg)

print(deploy_cfg.pretty_text)

# generated config
ir_config = dict(
    type='onnx',
    input_names=['input'],
    output_names=['dets', 'labels'],
    dynamic_axes=dict(
        input=dict({0: 'batch'}),
        dets=dict({0: 'batch'}),
        labels=dict({0: 'batch'})),
    input_shape=(300, 300))
codebase_config = dict(
    type='mmdet',
    task='ObjectDetection',
    model_type='end2end',
    is_dynamic_batch=True,
    is_dynamic_size=False,
    detection_mode='detection',
    input_shape=(300, 300),
    post_processing=dict(
        score_threshold=0.05,
        confidence_threshold=0.005,
        iou_threshold=0.5,
        max_output_boxes_per_class=200,
        pre_top_k=5000,
        keep_top_k=100,
        background_label_id=-1))
backend_config = dict(
    type='tensorrt',
    common_config=dict(fp16_mode=False, max_workspace_size=1073741824),
    model_inputs=[
        dict(
            input_shapes=dict(
                input=dict(
                    min_shape=(1, 3, 300, 300),
                    opt_shape=(1, 3, 300, 300),
                    max_shape=(2, 3, 300, 300))))
    ])

Modification

Please briefly describe what modification is made in this PR.

BC-breaking (Optional)

Does the modification introduce changes that break the backward-compatibility of the downstream repositories? If so, please describe how it breaks the compatibility and how the downstream projects should modify their code to keep compatibility with this PR.

Use cases (Optional)

If this PR introduces a new feature, it is better to list some use cases here, and update the documentation.

Checklist

  1. Pre-commit or other linting tools are used to fix the potential lint issues.
  2. The modification is covered by complete unit tests. If not, please add more unit tests to ensure the correctness.
  3. If the modification has a dependency on downstream projects of a newer version, this PR should be tested with all supported versions of downstream projects.
  4. The documentation has been modified accordingly, like docstring or example tutorials.

grimoire avatar Dec 27 '22 07:12 grimoire

Codecov Report

Attention: Patch coverage is 3.39147% with 997 lines in your changes missing coverage. Please review.

Project coverage is 41.69%. Comparing base (d113a5f) to head (ac7f9c0). Report is 78 commits behind head on master.

Files with missing lines Patch % Lines
mmdeploy/codebase/mmdet/deploy/object_detection.py 0.65% 152 Missing :warning:
...ploy/codebase/mmrotate/deploy/rotated_detection.py 0.00% 144 Missing :warning:
mmdeploy/codebase/mmocr/deploy/text_detection.py 0.81% 122 Missing :warning:
mmdeploy/codebase/mmseg/deploy/segmentation.py 0.81% 122 Missing :warning:
...ploy/codebase/mmaction/deploy/video_recognition.py 0.00% 94 Missing :warning:
mmdeploy/codebase/mmocr/deploy/text_recognition.py 1.06% 93 Missing :warning:
mmdeploy/codebase/mmcls/deploy/classification.py 1.35% 73 Missing :warning:
mmdeploy/codebase/mmpose/deploy/pose_detection.py 1.72% 57 Missing :warning:
...mdeploy/codebase/mmdet3d/deploy/voxel_detection.py 0.00% 40 Missing :warning:
mmdeploy/backend/coreml/backend_manager.py 9.09% 20 Missing :warning:
... and 14 more
Additional details and impacted files
@@            Coverage Diff             @@
##           master    #1579      +/-   ##
==========================================
- Coverage   44.83%   41.69%   -3.14%     
==========================================
  Files         356      356              
  Lines       12698    13739    +1041     
  Branches     1791     2001     +210     
==========================================
+ Hits         5693     5729      +36     
- Misses       6614     7615    +1001     
- Partials      391      395       +4     
Flag Coverage Δ
unittests 41.69% <3.39%> (-3.14%) :arrow_down:

Flags with carried forward coverage won't be shown. Click here to find out more.

:umbrella: View full report in Codecov by Sentry.
:loudspeaker: Have feedback on the report? Share it here.

:rocket: New features to boost your workflow:
  • :snowflake: Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

codecov[bot] avatar Dec 18 '24 05:12 codecov[bot]