Closed chen-del closed 1 year ago
@chen-del hi, pls install mmdeploy and then do model conversion
@RunningLeon ,I have installed mmdeploy, but the configuration inside is not usable. I have added classification branch training to mmpose and removed the test_cfg configuration parameter. None of the methods is applicable now. It has this error I have tried earlier -detection_onnxruntime_static, it has the following error
test_cfg
, could update your model config. Do you mean that I need to re-build inference mode and onnx derivation mode suitable for my model on mmdeply according to my model? Is there any quick way to do that?
This issue is marked as stale because it has been marked as invalid or awaiting response for 7 days without any further response. It will be closed in 5 days if the stale label is not removed or if there is no further response.
This issue is closed because it has been stale for 5 days. Please open a new issue if you have similar issues or you have any new updates now.
Checklist
Describe the bug
I am not very proficient in using mmdeploy. The framework configuration that originally exported the model is no longer applicable. I used torch.onnx.export for direct export, but I encountered a problem, and a TypeError: forward() missing 1 appeared. required positional argument: 'data_samples', what is the reason for this? Thanks!
Reproduction
import argparse import warnings
import numpy as np import torch import io from mmpose.apis import init_model
from mmcv.runner import load_checkpoint
try: import onnx import onnxruntime as rt except ImportError as e: raise ImportError(f'Please install onnx and onnxruntime first. {e}')
def _convert_batchnorm(module): """Convert the syncBNs into normal BN3ds.""" module_output = module if isinstance(module, torch.nn.SyncBatchNorm): module_output = torch.nn.BatchNorm3d(module.num_features, module.eps, module.momentum, module.affine, module.track_running_stats) if module.affine: module_output.weight.data = module.weight.data.clone().detach() module_output.bias.data = module.bias.data.clone().detach()
keep requires_grad unchanged
def pytorch2onnx(model, opset_version=11, out='tmp.onnx'): """Convert pytorch model to onnx model.
def parse_args(): parser = argparse.ArgumentParser( description='Convert MMPose models to ONNX') parser.add_argument('config', help='test config file path') parser.add_argument('checkpoint', help='checkpoint file') parser.add_argument('--out', type=str, default='tmp.onnx') parser.add_argument('--opset-version', type=int, default=11) args = parser.parse_args() return args
if name == 'main': args = parse_args()
Following strings of text style are from colorama package
Environment
Error traceback