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

[WIP] Deploy config updater #1579

Open
wants to merge 8 commits into
base: master
Choose a base branch
from
Open

Conversation

grimoire
Copy link
Member

@grimoire grimoire commented Dec 27, 2022

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant