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

feat(codebase): support mmdet3d dev-1.x 1.1.0rc1 #1225

Merged
Merged
Show file tree
Hide file tree
Changes from 3 commits
Commits
Show all changes
25 commits
Select commit Hold shift + click to select a range
e6d2eeb
feat(mmdet3d): test pointpillars and centerpoint on ort, openvino and…
tpoisonooo Sep 5, 2022
5769cb3
fix(centerpoint): mvx_two_stage input error
tpoisonooo Oct 19, 2022
d738d4c
fix(review): remove mode decorator
tpoisonooo Oct 21, 2022
85126cf
fix(mmdet3d): review advices
tpoisonooo Oct 27, 2022
a811a52
fix(regression): update mmdet3d.yml and test ort/openvino passed
tpoisonooo Oct 27, 2022
aa5f797
unittest(mmdet3d): fix
tpoisonooo Oct 28, 2022
04150e1
fix(unittest): fix
tpoisonooo Oct 28, 2022
ee95015
fix(mmdet3d): unittest
tpoisonooo Oct 31, 2022
4fb0f09
fix(mmdet3d): unittest
tpoisonooo Oct 31, 2022
3f20482
fix(CI): remove mmcv.Config
tpoisonooo Oct 31, 2022
d3f6074
fix(mmdet3d): unittest
tpoisonooo Oct 31, 2022
7ae5be1
fix(mmdet3d): support torch1.12
tpoisonooo Nov 2, 2022
236f4b8
fix(CI): use bigger point cloud file
tpoisonooo Nov 3, 2022
560b661
improvement(mmdet3d): align backend outputs with torch
tpoisonooo Nov 4, 2022
325d006
fix(mmdet3d): remove useless
tpoisonooo Nov 4, 2022
cc6cf21
style(mmdet3d): format code
tpoisonooo Nov 4, 2022
c11f1aa
style(mmdet3d): remove useless
tpoisonooo Nov 4, 2022
33f8a64
fix(mmdet3d): sync vis_task
tpoisonooo Nov 4, 2022
971b384
unittest(mmdet3d): add test
tpoisonooo Nov 4, 2022
2111d95
docs(mmdet3d): add docstring
tpoisonooo Nov 4, 2022
a4a48f9
unittest(ci): add unittest data
tpoisonooo Nov 4, 2022
24cd506
fix(mmdet3d): review advices
tpoisonooo Nov 4, 2022
1375e5d
feat(mmdet3d): convert fail
tpoisonooo Nov 4, 2022
a9a194a
style(mmdet3d): docstring
tpoisonooo Nov 4, 2022
47552b0
style(mmdet3d): docstring
tpoisonooo Nov 4, 2022
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
4 changes: 2 additions & 2 deletions configs/mmdet3d/voxel-detection/voxel-detection_static.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,5 +2,5 @@
codebase_config = dict(
type='mmdet3d', task='VoxelDetection', model_type='end2end')
onnx_config = dict(
input_names=['voxels', 'num_points', 'coors'],
output_names=['scores', 'bbox_preds', 'dir_scores'])
input_names=['placeholder', 'num_points', 'voxels', 'coors'],
output_names=['cls_score', 'bbox_pred', 'dir_cls_pred'])
1 change: 0 additions & 1 deletion mmdeploy/apis/onnx/export.py
Original file line number Diff line number Diff line change
Expand Up @@ -119,7 +119,6 @@ def _add_or_update(cfg: dict, key: str, val: Any):
), f'Expect input_metas type is dict, get {type(input_metas)}.'
model_forward = model.forward
model.forward = partial(model.forward, **input_metas)

torch.onnx.export(
patched_model,
args,
Expand Down
6 changes: 3 additions & 3 deletions mmdeploy/apis/pytorch2onnx.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@
from typing import Any, Optional, Union

import mmengine
import torch

from mmdeploy.apis.core.pipeline_manager import no_mp
from mmdeploy.utils import (Backend, get_backend, get_dynamic_axes,
Expand Down Expand Up @@ -64,11 +63,12 @@ def torch2onnx(img: Any,
img,
input_shape,
data_preprocessor=getattr(torch_model, 'data_preprocessor', None))
if not isinstance(model_inputs, torch.Tensor) and len(model_inputs) == 1:

if isinstance(model_inputs, list) and len(model_inputs) == 1:
model_inputs = model_inputs[0]
data_samples = data['data_samples']
patch_metas = {'data_samples': data_samples}
input_metas = {'data_samples': data_samples, 'mode': 'predict'}
input_metas = {'data_samples': data_samples, 'mode': task_processor.mode()}
tpoisonooo marked this conversation as resolved.
Show resolved Hide resolved
tpoisonooo marked this conversation as resolved.
Show resolved Hide resolved

# export to onnx
context_info = dict()
Expand Down
6 changes: 6 additions & 0 deletions mmdeploy/apis/visualize.py
Original file line number Diff line number Diff line change
Expand Up @@ -68,21 +68,27 @@ def visualize_model(model_cfg: Union[str, mmengine.Config],
model = task_processor.build_backend_model(model)

model_inputs, _ = task_processor.create_input(img, input_shape)

with torch.no_grad():
result = model.test_step(model_inputs)[0]

try:
# check headless
import tkinter
tkinter.Tk()
data_samples = None
tpoisonooo marked this conversation as resolved.
Show resolved Hide resolved
if 'data_samples' in model_inputs:
data_samples = model_inputs['data_samples']

task_processor.visualize(
image=img,
model=model,
result=result,
data_samples=data_samples,
output_file=output_file,
window_name=backend.value,
show_result=show_result)

except Exception as e:
from mmdeploy.utils import get_root_logger
logger = get_root_logger()
Expand Down
10 changes: 9 additions & 1 deletion mmdeploy/backend/tensorrt/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,6 @@ def load(path: str) -> trt.ICudaEngine:

def search_cuda_version() -> str:
"""try cmd to get cuda version, then try `torch.cuda`

Returns:
str: cuda version, for example 10.2
"""
Expand Down Expand Up @@ -189,6 +188,15 @@ def from_onnx(onnx_model: Union[str, onnx.ModelProto],
profile.set_shape(input_name, min_shape, opt_shape, max_shape)
config.add_optimization_profile(profile)

cuda_version = search_cuda_version()
if cuda_version is not None:
version_major = int(cuda_version.split('.')[0])
if version_major < 11:
# cu11 support cublasLt, so cudnn heuristic tactic should disable CUBLAS_LT # noqa E501
tactic_source = config.get_tactic_sources() - (
1 << int(trt.TacticSource.CUBLAS_LT))
config.set_tactic_sources(tactic_source)

if fp16_mode:
if version.parse(trt.__version__) < version.parse('8'):
builder.fp16_mode = fp16_mode
Expand Down
9 changes: 9 additions & 0 deletions mmdeploy/codebase/base/task.py
Original file line number Diff line number Diff line change
Expand Up @@ -75,6 +75,7 @@ def build_data_preprocessor(self):

from mmengine.registry import MODELS
data_preprocessor = MODELS.build(preprocess_cfg)
data_preprocessor.to(self.device)

return data_preprocessor

Expand Down Expand Up @@ -302,6 +303,14 @@ def visualize(self,
show=show_result,
out_file=output_file)

def mode(self) -> str:
tpoisonooo marked this conversation as resolved.
Show resolved Hide resolved
"""Get pytorch inference mode, it depends on codebase implementation.

Returns:
str: codebase inference mode
"""
return 'predict'

@staticmethod
@abstractmethod
def get_partition_cfg(partition_type: str, **kwargs) -> Dict:
Expand Down
3 changes: 1 addition & 2 deletions mmdeploy/codebase/mmdet3d/deploy/__init__.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
# Copyright (c) OpenMMLab. All rights reserved.
from .mmdetection3d import MMDetection3d
from .voxel_detection import VoxelDetection
from .voxel_detection import MMDetection3d, VoxelDetection
from .voxel_detection_model import VoxelDetectionModel

__all__ = ['MMDetection3d', 'VoxelDetection', 'VoxelDetectionModel']
128 changes: 0 additions & 128 deletions mmdeploy/codebase/mmdet3d/deploy/mmdetection3d.py

This file was deleted.

Loading