-
Notifications
You must be signed in to change notification settings - Fork 675
Description
Checklist
- I have searched related issues but cannot get the expected help.
- 2. I have read the FAQ documentation but cannot get the expected help.
- 3. The bug has not been fixed in the latest version.
Describe the bug
python mmdeploy/tools/deploy.py mmdeploy/configs/mmdet/detection/detection_onnxruntime_static.py status.py latest.pth hm028.jpg --device cpu
I meet the Error traceback below.
I am a novice and I feel very helpless. I hope that kind hearted people can help me. Thank you very much!
Reproduction
status.py # it is the model config.
I didnot make any modifications.
I git clone and run 'deploy.py' just now. I clone all the latest code.
model = dict(
type='CascadeRCNN',
backbone=dict(
type='ResNet',
depth=50,
num_stages=4,
out_indices=(0, 1, 2, 3),
frozen_stages=1,
norm_cfg=dict(type='BN', requires_grad=True),
norm_eval=True,
style='pytorch',
init_cfg=None),
neck=dict(
type='FPN',
in_channels=[256, 512, 1024, 2048],
out_channels=256,
num_outs=5),
rpn_head=dict(
type='RPNHead',
in_channels=256,
feat_channels=256,
anchor_generator=dict(
type='AnchorGenerator',
scales=[8],
ratios=[0.5, 1.0, 2.0],
strides=[4, 8, 16, 32, 64]),
bbox_coder=dict(
type='DeltaXYWHBBoxCoder',
target_means=[0.0, 0.0, 0.0, 0.0],
target_stds=[1.0, 1.0, 1.0, 1.0]),
loss_cls=dict(
type='CrossEntropyLoss', use_sigmoid=True, loss_weight=1.0),
loss_bbox=dict(
type='SmoothL1Loss', beta=0.1111111111111111, loss_weight=1.0)),
roi_head=dict(
type='CascadeRoIHead',
num_stages=3,
stage_loss_weights=[1, 0.5, 0.25],
bbox_roi_extractor=dict(
type='SingleRoIExtractor',
roi_layer=dict(type='RoIAlign', output_size=7, sampling_ratio=0),
out_channels=256,
featmap_strides=[4, 8, 16, 32]),
bbox_head=[
dict(type='Shared2FCBBoxHead', num_classes=10),
dict(type='Shared2FCBBoxHead', num_classes=10),
dict(type='Shared2FCBBoxHead', num_classes=10)
]),
train_cfg=dict(
rpn=dict(
assigner=dict(
type='MaxIoUAssigner',
pos_iou_thr=0.7,
neg_iou_thr=0.3,
min_pos_iou=0.3,
match_low_quality=True,
ignore_iof_thr=-1),
sampler=dict(
type='RandomSampler',
num=256,
pos_fraction=0.5,
neg_pos_ub=-1,
add_gt_as_proposals=False),
allowed_border=0,
pos_weight=-1,
debug=False),
rpn_proposal=dict(
nms_pre=2000,
max_per_img=2000,
nms=dict(type='nms', iou_threshold=0.7),
min_bbox_size=0),
rcnn=[
dict(
assigner=dict(
type='MaxIoUAssigner',
pos_iou_thr=0.5,
neg_iou_thr=0.5,
min_pos_iou=0.5,
match_low_quality=False,
ignore_iof_thr=-1),
sampler=dict(
type='RandomSampler',
num=512,
pos_fraction=0.25,
neg_pos_ub=-1,
add_gt_as_proposals=True),
pos_weight=-1,
debug=False),
dict(
assigner=dict(
type='MaxIoUAssigner',
pos_iou_thr=0.6,
neg_iou_thr=0.6,
min_pos_iou=0.6,
match_low_quality=False,
ignore_iof_thr=-1),
sampler=dict(
type='RandomSampler',
num=512,
pos_fraction=0.25,
neg_pos_ub=-1,
add_gt_as_proposals=True),
pos_weight=-1,
debug=False),
dict(
assigner=dict(
type='MaxIoUAssigner',
pos_iou_thr=0.7,
neg_iou_thr=0.7,
min_pos_iou=0.7,
match_low_quality=False,
ignore_iof_thr=-1),
sampler=dict(
type='RandomSampler',
num=512,
pos_fraction=0.25,
neg_pos_ub=-1,
add_gt_as_proposals=True),
pos_weight=-1,
debug=False)
]),
test_cfg=dict(
rpn=dict(
nms_pre=1000,
max_per_img=1000,
nms=dict(type='nms', iou_threshold=0.7),
min_bbox_size=0),
rcnn=dict(
score_thr=0.05,
nms=dict(type='nms', iou_threshold=0.5),
max_per_img=100)))
dataset_type = 'CocoDataset'
data_root = 'data/status/'
img_norm_cfg = dict(
mean=[123.675, 116.28, 103.53], std=[58.395, 57.12, 57.375], to_rgb=True)
train_pipeline = [
dict(type='LoadImageFromFile'),
dict(type='LoadAnnotations', with_bbox=True),
dict(type='Resize', img_scale=(1333, 800), keep_ratio=True),
dict(type='RandomFlip', flip_ratio=0.5),
dict(
type='Normalize',
mean=[123.675, 116.28, 103.53],
std=[58.395, 57.12, 57.375],
to_rgb=True),
dict(type='Pad', size_divisor=32),
dict(type='DefaultFormatBundle'),
dict(type='Collect', keys=['img', 'gt_bboxes', 'gt_labels'])
]
test_pipeline = [
dict(type='LoadImageFromFile'),
dict(
type='MultiScaleFlipAug',
img_scale=(1333, 800),
flip=False,
transforms=[
dict(type='Resize', keep_ratio=True),
dict(type='RandomFlip'),
dict(
type='Normalize',
mean=[123.675, 116.28, 103.53],
std=[58.395, 57.12, 57.375],
to_rgb=True),
dict(type='Pad', size_divisor=32),
dict(type='ImageToTensor', keys=['img']),
dict(type='Collect', keys=['img'])
])
]
data = dict(
samples_per_gpu=3,
workers_per_gpu=2,
train=dict(
type='CocoDataset',
ann_file='data/status/annotations/instances_train.json',
img_prefix='data/status/train/',
pipeline=[
dict(type='LoadImageFromFile'),
dict(type='LoadAnnotations', with_bbox=True),
dict(type='Resize', img_scale=(1333, 800), keep_ratio=True),
dict(type='RandomFlip', flip_ratio=0.5),
dict(
type='Normalize',
mean=[123.675, 116.28, 103.53],
std=[58.395, 57.12, 57.375],
to_rgb=True),
dict(type='Pad', size_divisor=32),
dict(type='DefaultFormatBundle'),
dict(type='Collect', keys=['img', 'gt_bboxes', 'gt_labels'])
],
classes=('leaf_g', 'leaf_y', 'strawberry_g', 'strawberry_r', 'flower',
'sepal', 'grayMold', 'snakeEye', 'powderyMildew', 'aphid')),
val=dict(
type='CocoDataset',
ann_file='data/status/annotations/instances_val.json',
img_prefix='data/status/val/',
pipeline=[
dict(type='LoadImageFromFile'),
dict(
type='MultiScaleFlipAug',
img_scale=(1333, 800),
flip=False,
transforms=[
dict(type='Resize', keep_ratio=True),
dict(type='RandomFlip'),
dict(
type='Normalize',
mean=[123.675, 116.28, 103.53],
std=[58.395, 57.12, 57.375],
to_rgb=True),
dict(type='Pad', size_divisor=32),
dict(type='ImageToTensor', keys=['img']),
dict(type='Collect', keys=['img'])
])
],
classes=('leaf_g', 'leaf_y', 'strawberry_g', 'strawberry_r', 'flower',
'sepal', 'grayMold', 'snakeEye', 'powderyMildew', 'aphid')),
test=dict(
type='CocoDataset',
ann_file='data/status/annotations/instances_val.json',
img_prefix='data/status/val/',
pipeline=[
dict(type='LoadImageFromFile'),
dict(
type='MultiScaleFlipAug',
img_scale=(1333, 800),
flip=False,
transforms=[
dict(type='Resize', keep_ratio=True),
dict(type='RandomFlip'),
dict(
type='Normalize',
mean=[123.675, 116.28, 103.53],
std=[58.395, 57.12, 57.375],
to_rgb=True),
dict(type='Pad', size_divisor=32),
dict(type='ImageToTensor', keys=['img']),
dict(type='Collect', keys=['img'])
])
],
classes=('leaf_g', 'leaf_y', 'strawberry_g', 'strawberry_r', 'flower',
'sepal', 'grayMold', 'snakeEye', 'powderyMildew', 'aphid')))
evaluation = dict(interval=3, metric='bbox', save_best='auto')
optimizer = dict(type='SGD', lr=0.001, momentum=0.9, weight_decay=0.0001)
optimizer_config = dict(grad_clip=None)
lr_config = dict(policy='CosineAnnealing', min_lr_ratio=1e-06)
runner = dict(type='EpochBasedRunner', max_epochs=40)
checkpoint_config = dict(interval=10)
log_config = dict(interval=20, hooks=[dict(type='TextLoggerHook')])
custom_hooks = [dict(type='NumClassCheckHook')]
dist_params = dict(backend='nccl')
log_level = 'INFO'
load_from = None
resume_from = None
workflow = [('train', 1)]
opencv_num_threads = 0
mp_start_method = 'fork'
auto_scale_lr = dict(enable=False, base_batch_size=16)
classes = ('leaf_g', 'leaf_y', 'strawberry_g', 'strawberry_r', 'flower',
'sepal', 'grayMold', 'snakeEye', 'powderyMildew', 'aphid')
num_classes = 10
vis_backends = [dict(type='LocalVisBackend')]
visualizer = dict(
type='DetLocalVisualizer',
vis_backends=[dict(type='LocalVisBackend')],
name='visualizer',
save_dir='D:')
work_dir = './work_dirs/status'
auto_resume = False
gpu_ids = [0]
Environment
2023-03-31 17:12:52,291 - mmdeploy - INFO - **********Environmental information**********
fatal: not a git repository (or any of the parent directories): .git
2023-03-31 17:12:52,780 - mmdeploy - INFO - sys.platform: linux
2023-03-31 17:12:52,780 - mmdeploy - INFO - Python: 3.8.16 (default, Mar 2 2023, 03:21:46) [GCC 11.2.0]
2023-03-31 17:12:52,780 - mmdeploy - INFO - CUDA available: False
2023-03-31 17:12:52,780 - mmdeploy - INFO - GCC: gcc (Ubuntu 9.3.0-17ubuntu1~20.04) 9.3.0
2023-03-31 17:12:52,780 - mmdeploy - INFO - PyTorch: 1.13.0
2023-03-31 17:12:52,780 - mmdeploy - INFO - PyTorch compiling details: PyTorch built with:
- GCC 9.3
- C++ Version: 201402
- Intel(R) oneAPI Math Kernel Library Version 2021.4-Product Build 20210904 for Intel(R) 64 architecture applications
- Intel(R) MKL-DNN v2.6.0 (Git Hash 52b5f107dd9cf10910aaa19cb47f3abf9b349815)
- OpenMP 201511 (a.k.a. OpenMP 4.5)
- LAPACK is enabled (usually provided by MKL)
- NNPACK is enabled
- CPU capability usage: AVX2
- Build settings: BLAS_INFO=mkl, BUILD_TYPE=Release, CXX_COMPILER=/opt/rh/devtoolset-9/root/usr/bin/c++, CXX_FLAGS= -fabi-version=11 -Wno-deprecated -fvisibility-inlines-hidden -DUSE_PTHREADPOOL -fopenmp -DNDEBUG -DUSE_KINETO -DLIBKINETO_NOCUPTI -DUSE_FBGEMM -DUSE_QNNPACK -DUSE_PYTORCH_QNNPACK -DUSE_XNNPACK -DSYMBOLICATE_MOBILE_DEBUG_HANDLE -DEDGE_PROFILER_USE_KINETO -O2 -fPIC -Wno-narrowing -Wall -Wextra -Werror=return-type -Werror=non-virtual-dtor -Wno-missing-field-initializers -Wno-type-limits -Wno-array-bounds -Wno-unknown-pragmas -Wunused-local-typedefs -Wno-unused-parameter -Wno-unused-function -Wno-unused-result -Wno-strict-overflow -Wno-strict-aliasing -Wno-error=deprecated-declarations -Wno-stringop-overflow -Wno-psabi -Wno-error=pedantic -Wno-error=redundant-decls -Wno-error=old-style-cast -fdiagnostics-color=always -faligned-new -Wno-unused-but-set-variable -Wno-maybe-uninitialized -fno-math-errno -fno-trapping-math -Werror=format -Werror=cast-function-type -Wno-stringop-overflow, LAPACK_INFO=mkl, PERF_WITH_AVX=1, PERF_WITH_AVX2=1, PERF_WITH_AVX512=1, TORCH_VERSION=1.13.0, USE_CUDA=0, USE_CUDNN=OFF, USE_EXCEPTION_PTR=1, USE_GFLAGS=OFF, USE_GLOG=OFF, USE_MKL=ON, USE_MKLDNN=ON, USE_MPI=OFF, USE_NCCL=OFF, USE_NNPACK=ON, USE_OPENMP=ON, USE_ROCM=OFF,
2023-03-31 17:12:52,780 - mmdeploy - INFO - TorchVision: 0.14.0
2023-03-31 17:12:52,780 - mmdeploy - INFO - OpenCV: 4.7.0
2023-03-31 17:12:52,780 - mmdeploy - INFO - MMCV: 1.7.1
2023-03-31 17:12:52,780 - mmdeploy - INFO - MMCV Compiler: GCC 7.3
2023-03-31 17:12:52,780 - mmdeploy - INFO - MMCV CUDA Compiler: not available
2023-03-31 17:12:52,781 - mmdeploy - INFO - MMDeploy: 0.13.0+
2023-03-31 17:12:52,781 - mmdeploy - INFO -
2023-03-31 17:12:52,781 - mmdeploy - INFO - **********Backend information**********
2023-03-31 17:12:52,795 - mmdeploy - INFO - tensorrt: None
2023-03-31 17:12:52,823 - mmdeploy - INFO - ONNXRuntime: 1.8.1
2023-03-31 17:12:52,823 - mmdeploy - INFO - ONNXRuntime-gpu: None
2023-03-31 17:12:52,823 - mmdeploy - INFO - ONNXRuntime custom ops: Available
2023-03-31 17:12:52,824 - mmdeploy - INFO - pplnn: None
2023-03-31 17:12:52,825 - mmdeploy - INFO - ncnn: None
2023-03-31 17:12:52,827 - mmdeploy - INFO - snpe: None
2023-03-31 17:12:52,827 - mmdeploy - INFO - openvino: None
2023-03-31 17:12:52,829 - mmdeploy - INFO - torchscript: 1.13.0
2023-03-31 17:12:52,829 - mmdeploy - INFO - torchscript custom ops: NotAvailable
2023-03-31 17:12:52,851 - mmdeploy - INFO - rknn-toolkit: None
2023-03-31 17:12:52,851 - mmdeploy - INFO - rknn2-toolkit: None
2023-03-31 17:12:52,852 - mmdeploy - INFO - ascend: None
2023-03-31 17:12:52,853 - mmdeploy - INFO - coreml: None
2023-03-31 17:12:52,854 - mmdeploy - INFO - tvm: None
2023-03-31 17:12:52,854 - mmdeploy - INFO -
2023-03-31 17:12:52,854 - mmdeploy - INFO - **********Codebase information**********
2023-03-31 17:12:52,855 - mmdeploy - INFO - mmdet: 2.28.2
2023-03-31 17:12:52,855 - mmdeploy - INFO - mmseg: None
2023-03-31 17:12:52,855 - mmdeploy - INFO - mmcls: None
2023-03-31 17:12:52,855 - mmdeploy - INFO - mmocr: None
2023-03-31 17:12:52,855 - mmdeploy - INFO - mmedit: None
2023-03-31 17:12:52,855 - mmdeploy - INFO - mmdet3d: None
2023-03-31 17:12:52,855 - mmdeploy - INFO - mmpose: None
2023-03-31 17:12:52,855 - mmdeploy - INFO - mmrotate: None
2023-03-31 17:12:52,855 - mmdeploy - INFO - mmaction: None
Error traceback
/root/anaconda3/envs/mmdeploy/lib/python3.8/site-packages/mmcv/ops/roi_align.py:83: TracerWarning: Converting a tensor to a Python boolean might cause the trace to be incorrect. We can't record the data flow of Python values, so this value will be treated as a constant in the future. This means that the trace might not generalize to other inputs!
assert rois.size(1) == 5, 'RoI must be (idx, x1, y1, x2, y2)!'
Process Process-2:
Traceback (most recent call last):
File "/root/anaconda3/envs/mmdeploy/lib/python3.8/multiprocessing/process.py", line 315, in _bootstrap
self.run()
File "/root/anaconda3/envs/mmdeploy/lib/python3.8/multiprocessing/process.py", line 108, in run
self._target(*self._args, **self._kwargs)
File "/root/anaconda3/envs/mmdeploy/lib/python3.8/site-packages/mmdeploy/apis/core/pipeline_manager.py", line 107, in __call__
ret = func(*args, **kwargs)
File "/root/anaconda3/envs/mmdeploy/lib/python3.8/site-packages/mmdeploy/apis/pytorch2onnx.py", line 98, in torch2onnx
export(
File "/root/anaconda3/envs/mmdeploy/lib/python3.8/site-packages/mmdeploy/apis/core/pipeline_manager.py", line 356, in _wrap
return self.call_function(func_name_, *args, **kwargs)
File "/root/anaconda3/envs/mmdeploy/lib/python3.8/site-packages/mmdeploy/apis/core/pipeline_manager.py", line 326, in call_function
return self.call_function_local(func_name, *args, **kwargs)
File "/root/anaconda3/envs/mmdeploy/lib/python3.8/site-packages/mmdeploy/apis/core/pipeline_manager.py", line 275, in call_function_local
return pipe_caller(*args, **kwargs)
File "/root/anaconda3/envs/mmdeploy/lib/python3.8/site-packages/mmdeploy/apis/core/pipeline_manager.py", line 107, in __call__
ret = func(*args, **kwargs)
File "/root/anaconda3/envs/mmdeploy/lib/python3.8/site-packages/mmdeploy/apis/onnx/export.py", line 122, in export
torch.onnx.export(
File "/root/anaconda3/envs/mmdeploy/lib/python3.8/site-packages/torch/onnx/utils.py", line 504, in export
_export(
File "/root/anaconda3/envs/mmdeploy/lib/python3.8/site-packages/torch/onnx/utils.py", line 1529, in _export
graph, params_dict, torch_out = _model_to_graph(
File "/root/anaconda3/envs/mmdeploy/lib/python3.8/site-packages/mmdeploy/core/rewriters/rewriter_utils.py", line 402, in wrapper
return self.func(self, *args, **kwargs)
File "/root/anaconda3/envs/mmdeploy/lib/python3.8/site-packages/mmdeploy/apis/onnx/optimizer.py", line 10, in model_to_graph__custom_optimizer
graph, params_dict, torch_out = ctx.origin_func(*args, **kwargs)
File "/root/anaconda3/envs/mmdeploy/lib/python3.8/site-packages/torch/onnx/utils.py", line 1111, in _model_to_graph
graph, params, torch_out, module = _create_jit_graph(model, args)
File "/root/anaconda3/envs/mmdeploy/lib/python3.8/site-packages/torch/onnx/utils.py", line 987, in _create_jit_graph
graph, torch_out = _trace_and_get_graph_from_model(model, args)
File "/root/anaconda3/envs/mmdeploy/lib/python3.8/site-packages/torch/onnx/utils.py", line 891, in _trace_and_get_graph_from_model
trace_graph, torch_out, inputs_states = torch.jit._get_trace_graph(
File "/root/anaconda3/envs/mmdeploy/lib/python3.8/site-packages/torch/jit/_trace.py", line 1184, in _get_trace_graph
outs = ONNXTracedModule(f, strict, _force_outplace, return_inputs, _return_inputs_states)(*args, **kwargs)
File "/root/anaconda3/envs/mmdeploy/lib/python3.8/site-packages/torch/nn/modules/module.py", line 1190, in _call_impl
return forward_call(*input, **kwargs)
File "/root/anaconda3/envs/mmdeploy/lib/python3.8/site-packages/torch/jit/_trace.py", line 127, in forward
graph, out = torch._C._create_graph_by_tracing(
File "/root/anaconda3/envs/mmdeploy/lib/python3.8/site-packages/torch/jit/_trace.py", line 118, in wrapper
outs.append(self.inner(*trace_inputs))
File "/root/anaconda3/envs/mmdeploy/lib/python3.8/site-packages/torch/nn/modules/module.py", line 1190, in _call_impl
return forward_call(*input, **kwargs)
File "/root/anaconda3/envs/mmdeploy/lib/python3.8/site-packages/torch/nn/modules/module.py", line 1178, in _slow_forward
result = self.forward(*input, **kwargs)
File "/root/anaconda3/envs/mmdeploy/lib/python3.8/site-packages/mmdeploy/core/rewriters/rewriter_utils.py", line 402, in wrapper
return self.func(self, *args, **kwargs)
File "/root/anaconda3/envs/mmdeploy/lib/python3.8/site-packages/mmdeploy/codebase/mmdet/models/detectors/base.py", line 70, in base_detector__forward
return __forward_impl(ctx, self, img, img_metas=img_metas, **kwargs)
File "/root/anaconda3/envs/mmdeploy/lib/python3.8/site-packages/mmdeploy/core/optimizers/function_marker.py", line 261, in g
rets = f(*args, **kwargs)
File "/root/anaconda3/envs/mmdeploy/lib/python3.8/site-packages/mmdeploy/codebase/mmdet/models/detectors/base.py", line 26, in __forward_impl
return self.simple_test(img, img_metas, **kwargs)
File "/root/anaconda3/envs/mmdeploy/lib/python3.8/site-packages/mmdeploy/core/rewriters/rewriter_utils.py", line 402, in wrapper
return self.func(self, *args, **kwargs)
File "/root/anaconda3/envs/mmdeploy/lib/python3.8/site-packages/mmdeploy/codebase/mmdet/models/detectors/two_stage.py", line 59, in two_stage_detector__simple_test
return self.roi_head.simple_test(x, proposals, img_metas, rescale=False)
File "/root/anaconda3/envs/mmdeploy/lib/python3.8/site-packages/mmdeploy/core/rewriters/rewriter_utils.py", line 402, in wrapper
return self.func(self, *args, **kwargs)
File "/root/anaconda3/envs/mmdeploy/lib/python3.8/site-packages/mmdeploy/codebase/mmdet/models/roi_heads/cascade_roi_head.py", line 66, in cascade_roi_head__simple_test
bbox_pred = bbox_pred.reshape(batch_size, num_proposals_per_img, 4)
RuntimeError: shape '[1, 174, 4]' is invalid for input of size 6960
2023-03-31 17:07:04,748 - mmdeploy - ERROR - `mmdeploy.apis.pytorch2onnx.torch2onnx` with Call id: 0 failed. exit.