fix conflicts with dev-1.x

pull/1091/head
RunningLeon 2022-09-29 17:17:34 +08:00
commit b78121a776
4 changed files with 6 additions and 111 deletions
mmdeploy/codebase/mmocr/deploy
tests/test_codebase

View File

@ -53,9 +53,9 @@ MMDeploy 是 [OpenMMLab](https://openmmlab.com/) 模型部署工具箱,**为
### 支持多种推理后端
| ONNX Runtime | TensorRT | ppl.nn | ncnn | OpenVINO | LibTorch | snpe | Ascend | Core ML | RKNN | more |
| ------------ | -------- | ------ | ---- | -------- | -------- | ---- | ------ | ------- | ---- | ---------------------------------------------- |
| ✔️ | ✔️ | ✔️ | ✔️ | ✔️ | ✔️ | ✔️ | ✔️ | ✔️ | ✔️ | [benchmark](docs/en/03-benchmark/benchmark.md) |
| ONNX Runtime | TensorRT | ppl.nn | ncnn | OpenVINO | LibTorch | snpe | Ascend | Core ML | RKNN | more |
| ------------ | -------- | ------ | ---- | -------- | -------- | ---- | ------ | ------- | ---- | ------------------------------------------------- |
| ✔️ | ✔️ | ✔️ | ✔️ | ✔️ | ✔️ | ✔️ | ✔️ | ✔️ | ✔️ | [benchmark](docs/zh_cn/03-benchmark/benchmark.md) |
### SDK 可高度定制化

View File

@ -19,5 +19,5 @@ class MMOCR(MMCodebase):
register_all_modules as register_all_modules_mmdet
from mmocr.utils.setup_env import \
register_all_modules as register_all_modules_mmocr
register_all_modules_mmocr(False)
register_all_modules_mmdet(True)
register_all_modules_mmocr(True)
register_all_modules_mmdet(False)

View File

@ -1659,107 +1659,6 @@ def test_yolox_head_predict_by_feat_ncnn():
assert rewrite_outputs.shape[-1] == 6
def get_vfnet_head_model():
"""VFNet Head Config."""
test_cfg = Config(
dict(
deploy_nms_pre=0,
min_bbox_size=0,
score_thr=0.05,
nms=dict(type='nms', iou_threshold=0.5),
max_per_img=100))
from mmdet.models.dense_heads import VFNetHead
model = VFNetHead(num_classes=4, in_channels=1, test_cfg=test_cfg)
model.requires_grad_(False)
model.cpu().eval()
return model
@pytest.mark.parametrize('backend_type',
[Backend.OPENVINO, Backend.ONNXRUNTIME])
def test_predict_by_feat_of_vfnet_head(backend_type: Backend):
"""Test predict_by_feat rewrite of VFNet head."""
check_backend(backend_type)
vfnet_head = get_vfnet_head_model()
vfnet_head.cpu().eval()
s = 16
batch_img_metas = [{
'scale_factor': np.ones(4),
'pad_shape': (s, s, 3),
'img_shape': (s, s, 3)
}]
output_names = ['dets', 'labels']
deploy_cfg = Config(
dict(
backend_config=dict(type=backend_type.value),
onnx_config=dict(output_names=output_names, input_shape=None),
codebase_config=dict(
type='mmdet',
task='ObjectDetection',
post_processing=dict(
score_threshold=0.05,
iou_threshold=0.5,
max_output_boxes_per_class=200,
pre_top_k=-1,
keep_top_k=100,
background_label_id=-1,
))))
seed_everything(1234)
cls_score = [
torch.rand(1, vfnet_head.num_classes, pow(2, i), pow(2, i))
for i in range(5, 0, -1)
]
seed_everything(5678)
bboxes = [torch.rand(1, 4, pow(2, i), pow(2, i)) for i in range(5, 0, -1)]
seed_everything(9101)
model_inputs = {
'cls_scores': cls_score,
'bbox_preds': bboxes,
'batch_img_metas': batch_img_metas
}
model_outputs = get_model_outputs(vfnet_head, 'predict_by_feat',
model_inputs)
batch_img_metas[0]['img_shape'] = torch.Tensor([s, s])
wrapped_model = WrapModel(
vfnet_head,
'predict_by_feat',
batch_img_metas=batch_img_metas,
with_nms=True)
rewrite_inputs = {'cls_scores': cls_score, 'bbox_preds': bboxes}
rewrite_outputs, is_backend_output = get_rewrite_outputs(
wrapped_model=wrapped_model,
model_inputs=rewrite_inputs,
deploy_cfg=deploy_cfg)
if is_backend_output:
# hard code to make two tensors with the same shape
# rewrite and original codes applied different nms strategy
min_shape = min(model_outputs[0].bboxes.shape[0],
rewrite_outputs[0].shape[1], 1)
for i in range(len(model_outputs)):
assert np.allclose(
model_outputs[i].bboxes[:min_shape],
rewrite_outputs[0][i, :min_shape, :4],
rtol=1e-03,
atol=1e-05)
assert np.allclose(
model_outputs[i].scores[:min_shape],
rewrite_outputs[0][i, :min_shape, 4],
rtol=1e-03,
atol=1e-05)
assert np.allclose(
model_outputs[i].labels[:min_shape],
rewrite_outputs[1][i, :min_shape],
rtol=1e-03,
atol=1e-05)
else:
assert rewrite_outputs is not None
def get_deploy_cfg(backend_type: Backend, ir_type: str):
return Config(
dict(

View File

@ -49,11 +49,7 @@ def test_heatmaphead_predict(backend_type: Backend):
def get_msmu_head():
from mmpose.models.heads import MSPNHead
model = MSPNHead(
num_stages=1,
num_units=1,
out_shape=(32, 48),
unit_channels=16,
level_indices=[0])
num_stages=1, num_units=1, out_shape=(32, 48), unit_channels=16)
model.requires_grad_(False)
return model