最近我自己的电脑上面尝试训练yolox_s和yolox_nano模型,使用的都是我自己的数据集,只有1类,以下博客就是我自己环境配置、训练还有遇到的问题的过程,这些我都写在了一个博客上面:
https://blog.csdn.net/ELSA001/article/details/120918082?spm=1001.2014.3001.5501
这些问题我都一一解决了,但是我想要把训练好的yolox_nano.pth模型转换成yolox_nano.onnx文件,然后转换成ncnn相关的文件来部署到安卓机上面。
在转换之前我把.\exps\default文件夹下的nano.py改成了前面的版本:
如果不改变的话,把官网上的coco数据集的yolox_nano.pth模型转换成yolox_nano.onnx文件的就会报错,我也不知道为啥。
不过我在使用自己的数据集的yolox_nano.pth模型转换成yolox_nano.onnx文件的时候遇到了问题。
报错信息如下:
RuntimeError('Error(s) in loading state_dict for {}:\n\t{}'.format(
RuntimeError: Error(s) in loading state_dict for YOLOX:
Missing key(s) in state_dict: "backbone.backbone.dark2.0.dconv.conv.weight", "backbone.backbone.dark2.0.dconv.bn.weight".....
Unexpected key(s) in state_dict: "backbone.backbone.dark2.0.conv.weight", "backbone.backbone.dark2.0.bn.weight"......
(torch_G) E:\YOLOX>python tools/export_onnx.py -n yolox-nano -c weights/yolox_nano.pth --output-name weights/yolox_nano.onnx
2021-10-27 12:50:15.825 | INFO | __main__:main:59 - args value: Namespace(batch_size=1, ckpt='weights/yolox_nano.pth', dynamic=False, exp_file=None, experiment_name=None, input='images', name='yolox-nano', no_onnxsim=False, opset=11, opts=[], output='output', output_name='weights/yolox_nano.onnx')
2021-10-27 12:50:16.038 | ERROR | __main__:<module>:116 - An error has been caught in function '' , process 'MainProcess' (70928), thread 'MainThread' (70764):
Traceback (most recent call last):
> File "tools\export_onnx.py", line 116, in <module>
main()
└ <function main at 0x000001A3D70D64C0>
File "tools\export_onnx.py", line 79, in main
model.load_state_dict(ckpt)
│ │ └ OrderedDict([('backbone.backbone.stem.conv.conv.weight', tensor([[[[ 1.2789e-02, 1.7050e-02, 2.4743e-02],
│ │ [ 6.535...
│ └ <function Module.load_state_dict at 0x000001A3D64469D0>
└ YOLOX(
(backbone): YOLOPAFPN(
(backbone): CSPDarknet(
(stem): Focus(
(conv): BaseConv(
(conv): ...
File "E:\Anaconda3\envs\torch_G\lib\site-packages\torch\nn\modules\module.py", line 1223, in load_state_dict
raise RuntimeError('Error(s) in loading state_dict for {}:\n\t{}'.format(
RuntimeError: Error(s) in loading state_dict for YOLOX:
Missing key(s) in state_dict: "backbone.backbone.dark2.0.dconv.conv.weight", "backbone.backbone.dark2.0.dconv.bn.weight", "backbone.backbone.dark2.0.dconv.bn.bias", "backbone.backbone.dark2.0.dconv.bn.running_mean", "backbone.backbone.dark2.0.dconv.bn.running_var", "backbone.backbone.dark2.0.pconv.conv.weight", "backbone.backbone.dark2.0.pconv.bn.weight", "backbone.backbone.dark2.0.pconv.bn.bias", "backbone.backbone.dark2.0.pconv.bn.running_mean", "backbone.backbone.dark2.0.pconv.bn.running_var", "backbone.backbone.dark2.1.m.0.conv2.dconv.conv.weight", "backbone.backbone.dark2.1.m.0.conv2.dconv.bn.weight", "backbone.backbone.dark2.1.m.0.conv2.dconv.bn.bias", "backbone.backbone.dark2.1.m.0.conv2.dconv.bn.running_mean", "backbone.backbone.dark2.1.m.0.conv2.dconv.bn.running_var", "backbone.backbone.dark2.1.m.0.conv2.pconv.conv.weight", "backbone.backbone.dark2.1.m.0.conv2.pconv.bn.weight", "backbone.backbone.dark2.1.m.0.conv2.pconv.bn.bias", "backbone.backbone.dark2.1.m.0.conv2.pconv.bn.running_mean", "backbone.backbone.dark2.1.m.0.conv2.pconv.bn.running_var", "backbone.backbone.dark3.0.dconv.conv.weight", "backbone.backbone.dark3.0.dconv.bn.weight", "backbone.backbone.dark3.0.dconv.bn.bias", "backbone.backbone.dark3.0.dconv.bn.running_mean", "backbone.backbone.dark3.0.dconv.bn.running_var", "backbone.backbone.dark3.0.pconv.conv.weight", "backbone.backbone.dark3.0.pconv.bn.weight", "backbone.backbone.dark3.0.pconv.bn.bias", "backbone.backbone.dark3.0.pconv.bn.running_mean", "backbone.backbone.dark3.0.pconv.bn.running_var", "backbone.backbone.dark3.1.m.0.conv2.dconv.conv.weight", "backbone.backbone.dark3.1.m.0.conv2.dconv.bn.weight", "backbone.backbone.dark3.1.m.0.conv2.dconv.bn.bias", "backbone.backbone.dark3.1.m.0.conv2.dconv.bn.running_mean", "backbone.backbone.dark3.1.m.0.conv2.dconv.bn.running_var", "backbone.backbone.dark3.1.m.0.conv2.pconv.conv.weight", "backbone.backbone.dark3.1.m.0.conv2.pconv.bn.weight", "backbone.backbone.dark3.1.m.0.conv2.pconv.bn.bias", "backbone.backbone.dark3.1.m.0.conv2.pconv.bn.running_mean", "backbone.backbone.dark3.1.m.0.conv2.pconv.bn.running_var", "backbone.backbone.dark3.1.m.1.conv2.dconv.conv.weight", "backbone.backbone.dark3.1.m.1.conv2.dconv.bn.weight", "backbone.backbone.dark3.1.m.1.conv2.dconv.bn.bias", "backbone.backbone.dark3.1.m.1.conv2.dconv.bn.running_mean", "backbone.backbone.dark3.1.m.1.conv2.dconv.bn.running_var", "backbone.backbone.dark3.1.m.1.conv2.pconv.conv.weight", "backbone.backbone.dark3.1.m.1.conv2.pconv.bn.weight", "backbone.backbone.dark3.1.m.1.conv2.pconv.bn.bias", "backbone.backbone.dark3.1.m.1.conv2.pconv.bn.running_mean", "backbone.backbone.dark3.1.m.1.conv2.pconv.bn.running_var", "backbone.backbone.dark3.1.m.2.conv2.dconv.conv.weight", "backbone.backbone.dark3.1.m.2.conv2.dconv.bn.weight", "backbone.backbone.dark3.1.m.2.conv2.dconv.bn.bias", "backbone.backbone.dark3.1.m.2.conv2.dconv.bn.running_mean", "backbone.backbone.dark3.1.m.2.conv2.dconv.bn.running_var", "backbone.backbone.dark3.1.m.2.conv2.pconv.conv.weight", "backbone.backbone.dark3.1.m.2.conv2.pconv.bn.weight", "backbone.backbone.dark3.1.m.2.conv2.pconv.bn.bias", "backbone.backbone.dark3.1.m.2.conv2.pconv.bn.running_mean", "backbone.backbone.dark3.1.m.2.conv2.pconv.bn.running_var", "backbone.backbone.dark4.0.dconv.conv.weight", "backbone.backbone.dark4.0.dconv.bn.weight", "backbone.backbone.dark4.0.dconv.bn.bias", "backbone.backbone.dark4.0.dconv.bn.running_mean", "backbone.backbone.dark4.0.dconv.bn.running_var", "backbone.backbone.dark4.0.pconv.conv.weight", "backbone.backbone.dark4.0.pconv.bn.weight", "backbone.backbone.dark4.0.pconv.bn.bias", "backbone.backbone.dark4.0.pconv.bn.running_mean", "backbone.backbone.dark4.0.pconv.bn.running_var", "backbone.backbone.dark4.1.m.0.conv2.dconv.conv.weight", "backbone.backbone.dark4.1.m.0.conv2.dconv.bn.weight", "backbone.backbone.dark4.1.m.0.conv2.dconv.bn.bias", "backbone.backbone.dark4.1.m.0.conv2.dconv.bn.running_mean", "backbone.backbone.dark4.1.m.0.conv2.dconv.bn.running_var", "backbone.backbone.dark4.1.m.0.conv2.pconv.conv.weight", "backbone.backbone.dark4.1.m.0.conv2.pconv.bn.weight", "backbone.backbone.dark4.1.m.0.conv2.pconv.bn.bias", "backbone.backbone.dark4.1.m.0.conv2.pconv.bn.running_mean", "backbone.backbone.dark4.1.m.0.conv2.pconv.bn.running_var", "backbone.backbone.dark4.1.m.1.conv2.dconv.conv.weight", "backbone.backbone.dark4.1.m.1.conv2.dconv.bn.weight", "backbone.backbone.dark4.1.m.1.conv2.dconv.bn.bias", "backbone.backbone.dark4.1.m.1.conv2.dconv.bn.running_mean", "backbone.backbone.dark4.1.m.1.conv2.dconv.bn.running_var", "backbone.backbone.dark4.1.m.1.conv2.pconv.conv.weight", "backbone.backbone.dark4.1.m.1.conv2.pconv.bn.weight", "backbone.backbone.dark4.1.m.1.conv2.pconv.bn.bias", "backbone.backbone.dark4.1.m.1.conv2.pconv.bn.running_mean", "backbone.backbone.dark4.1.m.1.conv2.pconv.bn.running_var", "backbone.backbone.dark4.1.m.2.conv2.dconv.conv.weight", "backbone.backbone.dark4.1.m.2.conv2.dconv.bn.weight", "backbone.backbone.dark4.1.m.2.conv2.dconv.bn.bias", "backbone.backbone.dark4.1.m.2.conv2.dconv.bn.running_mean", "backbone.backbone.dark4.1.m.2.conv2.dconv.bn.running_var", "backbone.backbone.dark4.1.m.2.conv2.pconv.conv.weight", "backbone.backbone.dark4.1.m.2.conv2.pconv.bn.weight", "backbone.backbone.dark4.1.m.2.conv2.pconv.bn.bias", "backbone.backbone.dark4.1.m.2.conv2.pconv.bn.running_mean", "backbone.backbone.dark4.1.m.2.conv2.pconv.bn.running_var", "backbone.backbone.dark5.0.dconv.conv.weight", "backbone.backbone.dark5.0.dconv.bn.weight", "backbone.backbone.dark5.0.dconv.bn.bias", "backbone.backbone.dark5.0.dconv.bn.running_mean", "backbone.backbone.dark5.0.dconv.bn.running_var", "backbone.backbone.dark5.0.pconv.conv.weight", "backbone.backbone.dark5.0.pconv.bn.weight", "backbone.backbone.dark5.0.pconv.bn.bias", "backbone.backbone.dark5.0.pconv.bn.running_mean", "backbone.backbone.dark5.0.pconv.bn.running_var", "backbone.backbone.dark5.2.m.0.conv2.dconv.conv.weight", "backbone.backbone.dark5.2.m.0.conv2.dconv.bn.weight", "backbone.backbone.dark5.2.m.0.conv2.dconv.bn.bias", "backbone.backbone.dark5.2.m.0.conv2.dconv.bn.running_mean", "backbone.backbone.dark5.2.m.0.conv2.dconv.bn.running_var", "backbone.backbone.dark5.2.m.0.conv2.pconv.conv.weight", "backbone.backbone.dark5.2.m.0.conv2.pconv.bn.weight", "backbone.backbone.dark5.2.m.0.conv2.pconv.bn.bias", "backbone.backbone.dark5.2.m.0.conv2.pconv.bn.running_mean", "backbone.backbone.dark5.2.m.0.conv2.pconv.bn.running_var", "backbone.C3_p4.m.0.conv2.dconv.conv.weight", "backbone.C3_p4.m.0.conv2.dconv.bn.weight", "backbone.C3_p4.m.0.conv2.dconv.bn.bias", "backbone.C3_p4.m.0.conv2.dconv.bn.running_mean", "backbone.C3_p4.m.0.conv2.dconv.bn.running_var", "backbone.C3_p4.m.0.conv2.pconv.conv.weight", "backbone.C3_p4.m.0.conv2.pconv.bn.weight", "backbone.C3_p4.m.0.conv2.pconv.bn.bias", "backbone.C3_p4.m.0.conv2.pconv.bn.running_mean", "backbone.C3_p4.m.0.conv2.pconv.bn.running_var", "backbone.C3_p3.m.0.conv2.dconv.conv.weight", "backbone.C3_p3.m.0.conv2.dconv.bn.weight", "backbone.C3_p3.m.0.conv2.dconv.bn.bias", "backbone.C3_p3.m.0.conv2.dconv.bn.running_mean", "backbone.C3_p3.m.0.conv2.dconv.bn.running_var", "backbone.C3_p3.m.0.conv2.pconv.conv.weight", "backbone.C3_p3.m.0.conv2.pconv.bn.weight", "backbone.C3_p3.m.0.conv2.pconv.bn.bias", "backbone.C3_p3.m.0.conv2.pconv.bn.running_mean", "backbone.C3_p3.m.0.conv2.pconv.bn.running_var", "backbone.bu_conv2.dconv.conv.weight", "backbone.bu_conv2.dconv.bn.weight", "backbone.bu_conv2.dconv.bn.bias", "backbone.bu_conv2.dconv.bn.running_mean", "backbone.bu_conv2.dconv.bn.running_var", "backbone.bu_conv2.pconv.conv.weight", "backbone.bu_conv2.pconv.bn.weight", "backbone.bu_conv2.pconv.bn.bias", "backbone.bu_conv2.pconv.bn.running_mean", "backbone.bu_conv2.pconv.bn.running_var", "backbone.C3_n3.m.0.conv2.dconv.conv.weight", "backbone.C3_n3.m.0.conv2.dconv.bn.weight", "backbone.C3_n3.m.0.conv2.dconv.bn.bias", "backbone.C3_n3.m.0.conv2.dconv.bn.running_mean", "backbone.C3_n3.m.0.conv2.dconv.bn.running_var", "backbone.C3_n3.m.0.conv2.pconv.conv.weight", "backbone.C3_n3.m.0.conv2.pconv.bn.weight", "backbone.C3_n3.m.0.conv2.pconv.bn.bias", "backbone.C3_n3.m.0.conv2.pconv.bn.running_mean", "backbone.C3_n3.m.0.conv2.pconv.bn.running_var", "backbone.bu_conv1.dconv.conv.weight", "backbone.bu_conv1.dconv.bn.weight", "backbone.bu_conv1.dconv.bn.bias", "backbone.bu_conv1.dconv.bn.running_mean", "backbone.bu_conv1.dconv.bn.running_var", "backbone.bu_conv1.pconv.conv.weight", "backbone.bu_conv1.pconv.bn.weight", "backbone.bu_conv1.pconv.bn.bias", "backbone.bu_conv1.pconv.bn.running_mean", "backbone.bu_conv1.pconv.bn.running_var", "backbone.C3_n4.m.0.conv2.dconv.conv.weight", "backbone.C3_n4.m.0.conv2.dconv.bn.weight", "backbone.C3_n4.m.0.conv2.dconv.bn.bias", "backbone.C3_n4.m.0.conv2.dconv.bn.running_mean", "backbone.C3_n4.m.0.conv2.dconv.bn.running_var", "backbone.C3_n4.m.0.conv2.pconv.conv.weight", "backbone.C3_n4.m.0.conv2.pconv.bn.weight", "backbone.C3_n4.m.0.conv2.pconv.bn.bias", "backbone.C3_n4.m.0.conv2.pconv.bn.running_mean", "backbone.C3_n4.m.0.conv2.pconv.bn.running_var", "head.cls_convs.0.0.dconv.conv.weight", "head.cls_convs.0.0.dconv.bn.weight", "head.cls_convs.0.0.dconv.bn.bias", "head.cls_convs.0.0.dconv.bn.running_mean", "head.cls_convs.0.0.dconv.bn.running_var", "head.cls_convs.0.0.pconv.conv.weight", "head.cls_convs.0.0.pconv.bn.weight", "head.cls_convs.0.0.pconv.bn.bias", "head.cls_convs.0.0.pconv.bn.running_mean", "head.cls_convs.0.0.pconv.bn.running_var", "head.cls_convs.0.1.dconv.conv.weight", "head.cls_convs.0.1.dconv.bn.weight", "head.cls_convs.0.1.dconv.bn.bias", "head.cls_convs.0.1.dconv.bn.running_mean", "head.cls_convs.0.1.dconv.bn.running_var", "head.cls_convs.0.1.pconv.conv.weight", "head.cls_convs.0.1.pconv.bn.weight", "head.cls_convs.0.1.pconv.bn.bias", "head.cls_convs.0.1.pconv.bn.running_mean", "head.cls_convs.0.1.pconv.bn.running_var", "head.cls_convs.1.0.dconv.conv.weight", "head.cls_convs.1.0.dconv.bn.weight", "head.cls_convs.1.0.dconv.bn.bias", "head.cls_convs.1.0.dconv.bn.running_mean", "head.cls_convs.1.0.dconv.bn.running_var", "head.cls_convs.1.0.pconv.conv.weight", "head.cls_convs.1.0.pconv.bn.weight", "head.cls_convs.1.0.pconv.bn.bias", "head.cls_convs.1.0.pconv.bn.running_mean", "head.cls_convs.1.0.pconv.bn.running_var", "head.cls_convs.1.1.dconv.conv.weight", "head.cls_convs.1.1.dconv.bn.weight", "head.cls_convs.1.1.dconv.bn.bias", "head.cls_convs.1.1.dconv.bn.running_mean", "head.cls_convs.1.1.dconv.bn.running_var", "head.cls_convs.1.1.pconv.conv.weight", "head.cls_convs.1.1.pconv.bn.weight", "head.cls_convs.1.1.pconv.bn.bias", "head.cls_convs.1.1.pconv.bn.running_mean", "head.cls_convs.1.1.pconv.bn.running_var", "head.cls_convs.2.0.dconv.conv.weight", "head.cls_convs.2.0.dconv.bn.weight", "head.cls_convs.2.0.dconv.bn.bias", "head.cls_convs.2.0.dconv.bn.running_mean", "head.cls_convs.2.0.dconv.bn.running_var", "head.cls_convs.2.0.pconv.conv.weight", "head.cls_convs.2.0.pconv.bn.weight", "head.cls_convs.2.0.pconv.bn.bias", "head.cls_convs.2.0.pconv.bn.running_mean", "head.cls_convs.2.0.pconv.bn.running_var", "head.cls_convs.2.1.dconv.conv.weight", "head.cls_convs.2.1.dconv.bn.weight", "head.cls_convs.2.1.dconv.bn.bias", "head.cls_convs.2.1.dconv.bn.running_mean", "head.cls_convs.2.1.dconv.bn.running_var", "head.cls_convs.2.1.pconv.conv.weight", "head.cls_convs.2.1.pconv.bn.weight", "head.cls_convs.2.1.pconv.bn.bias", "head.cls_convs.2.1.pconv.bn.running_mean", "head.cls_convs.2.1.pconv.bn.running_var", "head.reg_convs.0.0.dconv.conv.weight", "head.reg_convs.0.0.dconv.bn.weight", "head.reg_convs.0.0.dconv.bn.bias", "head.reg_convs.0.0.dconv.bn.running_mean", "head.reg_convs.0.0.dconv.bn.running_var", "head.reg_convs.0.0.pconv.conv.weight", "head.reg_convs.0.0.pconv.bn.weight", "head.reg_convs.0.0.pconv.bn.bias", "head.reg_convs.0.0.pconv.bn.running_mean", "head.reg_convs.0.0.pconv.bn.running_var", "head.reg_convs.0.1.dconv.conv.weight", "head.reg_convs.0.1.dconv.bn.weight", "head.reg_convs.0.1.dconv.bn.bias", "head.reg_convs.0.1.dconv.bn.running_mean", "head.reg_convs.0.1.dconv.bn.running_var", "head.reg_convs.0.1.pconv.conv.weight", "head.reg_convs.0.1.pconv.bn.weight", "head.reg_convs.0.1.pconv.bn.bias", "head.reg_convs.0.1.pconv.bn.running_mean", "head.reg_convs.0.1.pconv.bn.running_var", "head.reg_convs.1.0.dconv.conv.weight", "head.reg_convs.1.0.dconv.bn.weight", "head.reg_convs.1.0.dconv.bn.bias", "head.reg_convs.1.0.dconv.bn.running_mean", "head.reg_convs.1.0.dconv.bn.running_var", "head.reg_convs.1.0.pconv.conv.weight", "head.reg_convs.1.0.pconv.bn.weight", "head.reg_convs.1.0.pconv.bn.bias", "head.reg_convs.1.0.pconv.bn.running_mean", "head.reg_convs.1.0.pconv.bn.running_var", "head.reg_convs.1.1.dconv.conv.weight", "head.reg_convs.1.1.dconv.bn.weight", "head.reg_convs.1.1.dconv.bn.bias", "head.reg_convs.1.1.dconv.bn.running_mean", "head.reg_convs.1.1.dconv.bn.running_var", "head.reg_convs.1.1.pconv.conv.weight", "head.reg_convs.1.1.pconv.bn.weight", "head.reg_convs.1.1.pconv.bn.bias", "head.reg_convs.1.1.pconv.bn.running_mean", "head.reg_convs.1.1.pconv.bn.running_var", "head.reg_convs.2.0.dconv.conv.weight", "head.reg_convs.2.0.dconv.bn.weight", "head.reg_convs.2.0.dconv.bn.bias", "head.reg_convs.2.0.dconv.bn.running_mean", "head.reg_convs.2.0.dconv.bn.running_var", "head.reg_convs.2.0.pconv.conv.weight", "head.reg_convs.2.0.pconv.bn.weight", "head.reg_convs.2.0.pconv.bn.bias", "head.reg_convs.2.0.pconv.bn.running_mean", "head.reg_convs.2.0.pconv.bn.running_var", "head.reg_convs.2.1.dconv.conv.weight", "head.reg_convs.2.1.dconv.bn.weight", "head.reg_convs.2.1.dconv.bn.bias", "head.reg_convs.2.1.dconv.bn.running_mean", "head.reg_convs.2.1.dconv.bn.running_var", "head.reg_convs.2.1.pconv.conv.weight", "head.reg_convs.2.1.pconv.bn.weight", "head.reg_convs.2.1.pconv.bn.bias", "head.reg_convs.2.1.pconv.bn.running_mean", "head.reg_convs.2.1.pconv.bn.running_var".
Unexpected key(s) in state_dict: "backbone.backbone.dark2.0.conv.weight", "backbone.backbone.dark2.0.bn.weight", "backbone.backbone.dark2.0.bn.bias", "backbone.backbone.dark2.0.bn.running_mean", "backbone.backbone.dark2.0.bn.running_var", "backbone.backbone.dark2.0.bn.num_batches_tracked", "backbone.backbone.dark2.1.m.0.conv2.conv.weight", "backbone.backbone.dark2.1.m.0.conv2.bn.weight", "backbone.backbone.dark2.1.m.0.conv2.bn.bias", "backbone.backbone.dark2.1.m.0.conv2.bn.running_mean", "backbone.backbone.dark2.1.m.0.conv2.bn.running_var", "backbone.backbone.dark2.1.m.0.conv2.bn.num_batches_tracked", "backbone.backbone.dark3.0.conv.weight", "backbone.backbone.dark3.0.bn.weight", "backbone.backbone.dark3.0.bn.bias", "backbone.backbone.dark3.0.bn.running_mean", "backbone.backbone.dark3.0.bn.running_var", "backbone.backbone.dark3.0.bn.num_batches_tracked", "backbone.backbone.dark3.1.m.0.conv2.conv.weight", "backbone.backbone.dark3.1.m.0.conv2.bn.weight", "backbone.backbone.dark3.1.m.0.conv2.bn.bias", "backbone.backbone.dark3.1.m.0.conv2.bn.running_mean", "backbone.backbone.dark3.1.m.0.conv2.bn.running_var", "backbone.backbone.dark3.1.m.0.conv2.bn.num_batches_tracked", "backbone.backbone.dark3.1.m.1.conv2.conv.weight", "backbone.backbone.dark3.1.m.1.conv2.bn.weight", "backbone.backbone.dark3.1.m.1.conv2.bn.bias", "backbone.backbone.dark3.1.m.1.conv2.bn.running_mean", "backbone.backbone.dark3.1.m.1.conv2.bn.running_var", "backbone.backbone.dark3.1.m.1.conv2.bn.num_batches_tracked", "backbone.backbone.dark3.1.m.2.conv2.conv.weight", "backbone.backbone.dark3.1.m.2.conv2.bn.weight", "backbone.backbone.dark3.1.m.2.conv2.bn.bias", "backbone.backbone.dark3.1.m.2.conv2.bn.running_mean", "backbone.backbone.dark3.1.m.2.conv2.bn.running_var", "backbone.backbone.dark3.1.m.2.conv2.bn.num_batches_tracked", "backbone.backbone.dark4.0.conv.weight", "backbone.backbone.dark4.0.bn.weight", "backbone.backbone.dark4.0.bn.bias", "backbone.backbone.dark4.0.bn.running_mean", "backbone.backbone.dark4.0.bn.running_var", "backbone.backbone.dark4.0.bn.num_batches_tracked", "backbone.backbone.dark4.1.m.0.conv2.conv.weight", "backbone.backbone.dark4.1.m.0.conv2.bn.weight", "backbone.backbone.dark4.1.m.0.conv2.bn.bias", "backbone.backbone.dark4.1.m.0.conv2.bn.running_mean", "backbone.backbone.dark4.1.m.0.conv2.bn.running_var", "backbone.backbone.dark4.1.m.0.conv2.bn.num_batches_tracked", "backbone.backbone.dark4.1.m.1.conv2.conv.weight", "backbone.backbone.dark4.1.m.1.conv2.bn.weight", "backbone.backbone.dark4.1.m.1.conv2.bn.bias", "backbone.backbone.dark4.1.m.1.conv2.bn.running_mean", "backbone.backbone.dark4.1.m.1.conv2.bn.running_var", "backbone.backbone.dark4.1.m.1.conv2.bn.num_batches_tracked", "backbone.backbone.dark4.1.m.2.conv2.conv.weight", "backbone.backbone.dark4.1.m.2.conv2.bn.weight", "backbone.backbone.dark4.1.m.2.conv2.bn.bias", "backbone.backbone.dark4.1.m.2.conv2.bn.running_mean", "backbone.backbone.dark4.1.m.2.conv2.bn.running_var", "backbone.backbone.dark4.1.m.2.conv2.bn.num_batches_tracked", "backbone.backbone.dark5.0.conv.weight", "backbone.backbone.dark5.0.bn.weight", "backbone.backbone.dark5.0.bn.bias", "backbone.backbone.dark5.0.bn.running_mean", "backbone.backbone.dark5.0.bn.running_var", "backbone.backbone.dark5.0.bn.num_batches_tracked", "backbone.backbone.dark5.2.m.0.conv2.conv.weight", "backbone.backbone.dark5.2.m.0.conv2.bn.weight", "backbone.backbone.dark5.2.m.0.conv2.bn.bias", "backbone.backbone.dark5.2.m.0.conv2.bn.running_mean", "backbone.backbone.dark5.2.m.0.conv2.bn.running_var", "backbone.backbone.dark5.2.m.0.conv2.bn.num_batches_tracked", "backbone.C3_p4.m.0.conv2.conv.weight", "backbone.C3_p4.m.0.conv2.bn.weight", "backbone.C3_p4.m.0.conv2.bn.bias", "backbone.C3_p4.m.0.conv2.bn.running_mean", "backbone.C3_p4.m.0.conv2.bn.running_var", "backbone.C3_p4.m.0.conv2.bn.num_batches_tracked", "backbone.C3_p3.m.0.conv2.conv.weight", "backbone.C3_p3.m.0.conv2.bn.weight", "backbone.C3_p3.m.0.conv2.bn.bias", "backbone.C3_p3.m.0.conv2.bn.running_mean", "backbone.C3_p3.m.0.conv2.bn.running_var", "backbone.C3_p3.m.0.conv2.bn.num_batches_tracked", "backbone.bu_conv2.conv.weight", "backbone.bu_conv2.bn.weight", "backbone.bu_conv2.bn.bias", "backbone.bu_conv2.bn.running_mean", "backbone.bu_conv2.bn.running_var", "backbone.bu_conv2.bn.num_batches_tracked", "backbone.C3_n3.m.0.conv2.conv.weight", "backbone.C3_n3.m.0.conv2.bn.weight", "backbone.C3_n3.m.0.conv2.bn.bias", "backbone.C3_n3.m.0.conv2.bn.running_mean", "backbone.C3_n3.m.0.conv2.bn.running_var", "backbone.C3_n3.m.0.conv2.bn.num_batches_tracked", "backbone.bu_conv1.conv.weight", "backbone.bu_conv1.bn.weight", "backbone.bu_conv1.bn.bias", "backbone.bu_conv1.bn.running_mean", "backbone.bu_conv1.bn.running_var", "backbone.bu_conv1.bn.num_batches_tracked", "backbone.C3_n4.m.0.conv2.conv.weight", "backbone.C3_n4.m.0.conv2.bn.weight", "backbone.C3_n4.m.0.conv2.bn.bias", "backbone.C3_n4.m.0.conv2.bn.running_mean", "backbone.C3_n4.m.0.conv2.bn.running_var", "backbone.C3_n4.m.0.conv2.bn.num_batches_tracked", "head.cls_convs.0.0.conv.weight", "head.cls_convs.0.0.bn.weight", "head.cls_convs.0.0.bn.bias", "head.cls_convs.0.0.bn.running_mean", "head.cls_convs.0.0.bn.running_var", "head.cls_convs.0.0.bn.num_batches_tracked", "head.cls_convs.0.1.conv.weight", "head.cls_convs.0.1.bn.weight", "head.cls_convs.0.1.bn.bias", "head.cls_convs.0.1.bn.running_mean", "head.cls_convs.0.1.bn.running_var", "head.cls_convs.0.1.bn.num_batches_tracked", "head.cls_convs.1.0.conv.weight", "head.cls_convs.1.0.bn.weight", "head.cls_convs.1.0.bn.bias", "head.cls_convs.1.0.bn.running_mean", "head.cls_convs.1.0.bn.running_var", "head.cls_convs.1.0.bn.num_batches_tracked", "head.cls_convs.1.1.conv.weight", "head.cls_convs.1.1.bn.weight", "head.cls_convs.1.1.bn.bias", "head.cls_convs.1.1.bn.running_mean", "head.cls_convs.1.1.bn.running_var", "head.cls_convs.1.1.bn.num_batches_tracked", "head.cls_convs.2.0.conv.weight", "head.cls_convs.2.0.bn.weight", "head.cls_convs.2.0.bn.bias", "head.cls_convs.2.0.bn.running_mean", "head.cls_convs.2.0.bn.running_var", "head.cls_convs.2.0.bn.num_batches_tracked", "head.cls_convs.2.1.conv.weight", "head.cls_convs.2.1.bn.weight", "head.cls_convs.2.1.bn.bias", "head.cls_convs.2.1.bn.running_mean", "head.cls_convs.2.1.bn.running_var", "head.cls_convs.2.1.bn.num_batches_tracked", "head.reg_convs.0.0.conv.weight", "head.reg_convs.0.0.bn.weight", "head.reg_convs.0.0.bn.bias", "head.reg_convs.0.0.bn.running_mean", "head.reg_convs.0.0.bn.running_var", "head.reg_convs.0.0.bn.num_batches_tracked", "head.reg_convs.0.1.conv.weight", "head.reg_convs.0.1.bn.weight", "head.reg_convs.0.1.bn.bias", "head.reg_convs.0.1.bn.running_mean", "head.reg_convs.0.1.bn.running_var", "head.reg_convs.0.1.bn.num_batches_tracked", "head.reg_convs.1.0.conv.weight", "head.reg_convs.1.0.bn.weight", "head.reg_convs.1.0.bn.bias", "head.reg_convs.1.0.bn.running_mean", "head.reg_convs.1.0.bn.running_var", "head.reg_convs.1.0.bn.num_batches_tracked", "head.reg_convs.1.1.conv.weight", "head.reg_convs.1.1.bn.weight", "head.reg_convs.1.1.bn.bias", "head.reg_convs.1.1.bn.running_mean", "head.reg_convs.1.1.bn.running_var", "head.reg_convs.1.1.bn.num_batches_tracked", "head.reg_convs.2.0.conv.weight", "head.reg_convs.2.0.bn.weight", "head.reg_convs.2.0.bn.bias", "head.reg_convs.2.0.bn.running_mean", "head.reg_convs.2.0.bn.running_var", "head.reg_convs.2.0.bn.num_batches_tracked", "head.reg_convs.2.1.conv.weight", "head.reg_convs.2.1.bn.weight", "head.reg_convs.2.1.bn.bias", "head.reg_convs.2.1.bn.running_mean", "head.reg_convs.2.1.bn.running_var", "head.reg_convs.2.1.bn.num_batches_tracked".
这些报错信息都是我在没有改变export_onnx.py时候的报错,我之前还把官网上面的80类的coco数据集的yolox_nano.pth模型转换成yolox_nano.onnx文件,但是可以成功转换:
而我已经修改了yolox_base.py里面的num_classes、depth、width还有input_size这些:
但是还是不能转换!
我看了网上很多教程,发现可以使用replace操作把权重文件的backbone.去掉,然后我操作了一下export_onnx.py这个文件:
把它改成这样:
但是依然有报错,只是稍微不一样了而已:
我发现这新的错误里面的有些变了,有些却没有变。
完整报错信息如下:
(torch_G) E:\YOLOX>python tools/export_onnx.py -n yolox-nano -c weights/yolox_nano.pth --output-name weights/yolox_nano.onnx
2021-10-26 00:01:35.809 | INFO | __main__:main:59 - args value: Namespace(batch_size=1, ckpt='weights/yolox_nano.pth', dynamic=False, exp_file=None, experiment_name=None, input='images', name='yolox-nano', no_onnxsim=False, opset=11, opts=[], output='output', output_name='weights/yolox_nano.onnx')
weights/yolox_nano.pth
2021-10-26 00:01:35.847 | ERROR | __main__:<module>:118 - An error has been caught in function '' , process 'MainProcess' (76240), thread 'MainThread' (70764):
Traceback (most recent call last):
> File "tools\export_onnx.py", line 118, in <module>
main()
└ <function main at 0x00000238F6B864C0>
File "tools\export_onnx.py", line 79, in main
if "model" in ckpt:
UnboundLocalError: local variable 'ckpt' referenced before assignment
(torch_G) E:\YOLOX>python tools/export_onnx.py -n yolox-nano -c weights/yolox_nano.pth --output-name weights/yolox_nano.onnx
2021-10-26 00:02:11.129 | INFO | __main__:main:59 - args value: Namespace(batch_size=1, ckpt='weights/yolox_nano.pth', dynamic=False, exp_file=None, experiment_name=None, input='images', name='yolox-nano', no_onnxsim=False, opset=11, opts=[], output='output', output_name='weights/yolox_nano.onnx')
weights/yolox_nano.pth
2021-10-26 00:02:11.201 | ERROR | __main__:<module>:118 - An error has been caught in function '' , process 'MainProcess' (25048), thread 'MainThread' (75000):
Traceback (most recent call last):
> File "tools\export_onnx.py", line 118, in <module>
main()
└ <function main at 0x0000017789E964C0>
File "tools\export_onnx.py", line 81, in main
model.load_state_dict({
k.replace('backbone.', ''): v for k, v in torch.load(ckpt_file, map_location="cpu").items()})
│ │ │ │ └ 'weights/yolox_nano.pth'
│ │ │ └ <function load at 0x0000017789051B80>
│ │ └ <module 'torch' from 'E:\\Anaconda3\\envs\\torch_G\\lib\\site-packages\\torch\\__init__.py'>
│ └ <function Module.load_state_dict at 0x00000177891769D0>
└ YOLOX(
(backbone): YOLOPAFPN(
(backbone): CSPDarknet(
(stem): Focus(
(conv): BaseConv(
(conv): ...
File "E:\Anaconda3\envs\torch_G\lib\site-packages\torch\nn\modules\module.py", line 1223, in load_state_dict
raise RuntimeError('Error(s) in loading state_dict for {}:\n\t{}'.format(
RuntimeError: Error(s) in loading state_dict for YOLOX:
Missing key(s) in state_dict: "backbone.backbone.stem.conv.conv.weight", "backbone.backbone.stem.conv.bn.weight", "backbone.backbone.stem.conv.bn.bias", "backbone.backbone.stem.conv.bn.running_mean", "backbone.backbone.stem.conv.bn.running_var", "backbone.backbone.dark2.0.dconv.conv.weight", "backbone.backbone.dark2.0.dconv.bn.weight", "backbone.backbone.dark2.0.dconv.bn.bias", "backbone.backbone.dark2.0.dconv.bn.running_mean", "backbone.backbone.dark2.0.dconv.bn.running_var", "backbone.backbone.dark2.0.pconv.conv.weight", "backbone.backbone.dark2.0.pconv.bn.weight", "backbone.backbone.dark2.0.pconv.bn.bias", "backbone.backbone.dark2.0.pconv.bn.running_mean", "backbone.backbone.dark2.0.pconv.bn.running_var", "backbone.backbone.dark2.1.conv1.conv.weight", "backbone.backbone.dark2.1.conv1.bn.weight", "backbone.backbone.dark2.1.conv1.bn.bias", "backbone.backbone.dark2.1.conv1.bn.running_mean", "backbone.backbone.dark2.1.conv1.bn.running_var", "backbone.backbone.dark2.1.conv2.conv.weight", "backbone.backbone.dark2.1.conv2.bn.weight", "backbone.backbone.dark2.1.conv2.bn.bias", "backbone.backbone.dark2.1.conv2.bn.running_mean", "backbone.backbone.dark2.1.conv2.bn.running_var", "backbone.backbone.dark2.1.conv3.conv.weight", "backbone.backbone.dark2.1.conv3.bn.weight", "backbone.backbone.dark2.1.conv3.bn.bias", "backbone.backbone.dark2.1.conv3.bn.running_mean", "backbone.backbone.dark2.1.conv3.bn.running_var", "backbone.backbone.dark2.1.m.0.conv1.conv.weight", "backbone.backbone.dark2.1.m.0.conv1.bn.weight", "backbone.backbone.dark2.1.m.0.conv1.bn.bias", "backbone.backbone.dark2.1.m.0.conv1.bn.running_mean", "backbone.backbone.dark2.1.m.0.conv1.bn.running_var", "backbone.backbone.dark2.1.m.0.conv2.dconv.conv.weight", "backbone.backbone.dark2.1.m.0.conv2.dconv.bn.weight", "backbone.backbone.dark2.1.m.0.conv2.dconv.bn.bias", "backbone.backbone.dark2.1.m.0.conv2.dconv.bn.running_mean", "backbone.backbone.dark2.1.m.0.conv2.dconv.bn.running_var", "backbone.backbone.dark2.1.m.0.conv2.pconv.conv.weight", "backbone.backbone.dark2.1.m.0.conv2.pconv.bn.weight", "backbone.backbone.dark2.1.m.0.conv2.pconv.bn.bias", "backbone.backbone.dark2.1.m.0.conv2.pconv.bn.running_mean", "backbone.backbone.dark2.1.m.0.conv2.pconv.bn.running_var", "backbone.backbone.dark3.0.dconv.conv.weight", "backbone.backbone.dark3.0.dconv.bn.weight", "backbone.backbone.dark3.0.dconv.bn.bias", "backbone.backbone.dark3.0.dconv.bn.running_mean", "backbone.backbone.dark3.0.dconv.bn.running_var", "backbone.backbone.dark3.0.pconv.conv.weight", "backbone.backbone.dark3.0.pconv.bn.weight", "backbone.backbone.dark3.0.pconv.bn.bias", "backbone.backbone.dark3.0.pconv.bn.running_mean", "backbone.backbone.dark3.0.pconv.bn.running_var", "backbone.backbone.dark3.1.conv1.conv.weight", "backbone.backbone.dark3.1.conv1.bn.weight", "backbone.backbone.dark3.1.conv1.bn.bias", "backbone.backbone.dark3.1.conv1.bn.running_mean", "backbone.backbone.dark3.1.conv1.bn.running_var", "backbone.backbone.dark3.1.conv2.conv.weight", "backbone.backbone.dark3.1.conv2.bn.weight", "backbone.backbone.dark3.1.conv2.bn.bias", "backbone.backbone.dark3.1.conv2.bn.running_mean", "backbone.backbone.dark3.1.conv2.bn.running_var", "backbone.backbone.dark3.1.conv3.conv.weight", "backbone.backbone.dark3.1.conv3.bn.weight", "backbone.backbone.dark3.1.conv3.bn.bias", "backbone.backbone.dark3.1.conv3.bn.running_mean", "backbone.backbone.dark3.1.conv3.bn.running_var", "backbone.backbone.dark3.1.m.0.conv1.conv.weight", "backbone.backbone.dark3.1.m.0.conv1.bn.weight", "backbone.backbone.dark3.1.m.0.conv1.bn.bias", "backbone.backbone.dark3.1.m.0.conv1.bn.running_mean", "backbone.backbone.dark3.1.m.0.conv1.bn.running_var", "backbone.backbone.dark3.1.m.0.conv2.dconv.conv.weight", "backbone.backbone.dark3.1.m.0.conv2.dconv.bn.weight", "backbone.backbone.dark3.1.m.0.conv2.dconv.bn.bias", "backbone.backbone.dark3.1.m.0.conv2.dconv.bn.running_mean", "backbone.backbone.dark3.1.m.0.conv2.dconv.bn.running_var", "backbone.backbone.dark3.1.m.0.conv2.pconv.conv.weight", "backbone.backbone.dark3.1.m.0.conv2.pconv.bn.weight", "backbone.backbone.dark3.1.m.0.conv2.pconv.bn.bias", "backbone.backbone.dark3.1.m.0.conv2.pconv.bn.running_mean", "backbone.backbone.dark3.1.m.0.conv2.pconv.bn.running_var", "backbone.backbone.dark3.1.m.1.conv1.conv.weight", "backbone.backbone.dark3.1.m.1.conv1.bn.weight", "backbone.backbone.dark3.1.m.1.conv1.bn.bias", "backbone.backbone.dark3.1.m.1.conv1.bn.running_mean", "backbone.backbone.dark3.1.m.1.conv1.bn.running_var", "backbone.backbone.dark3.1.m.1.conv2.dconv.conv.weight", "backbone.backbone.dark3.1.m.1.conv2.dconv.bn.weight", "backbone.backbone.dark3.1.m.1.conv2.dconv.bn.bias", "backbone.backbone.dark3.1.m.1.conv2.dconv.bn.running_mean", "backbone.backbone.dark3.1.m.1.conv2.dconv.bn.running_var", "backbone.backbone.dark3.1.m.1.conv2.pconv.conv.weight", "backbone.backbone.dark3.1.m.1.conv2.pconv.bn.weight", "backbone.backbone.dark3.1.m.1.conv2.pconv.bn.bias", "backbone.backbone.dark3.1.m.1.conv2.pconv.bn.running_mean", "backbone.backbone.dark3.1.m.1.conv2.pconv.bn.running_var", "backbone.backbone.dark3.1.m.2.conv1.conv.weight", "backbone.backbone.dark3.1.m.2.conv1.bn.weight", "backbone.backbone.dark3.1.m.2.conv1.bn.bias", "backbone.backbone.dark3.1.m.2.conv1.bn.running_mean", "backbone.backbone.dark3.1.m.2.conv1.bn.running_var", "backbone.backbone.dark3.1.m.2.conv2.dconv.conv.weight", "backbone.backbone.dark3.1.m.2.conv2.dconv.bn.weight", "backbone.backbone.dark3.1.m.2.conv2.dconv.bn.bias", "backbone.backbone.dark3.1.m.2.conv2.dconv.bn.running_mean", "backbone.backbone.dark3.1.m.2.conv2.dconv.bn.running_var", "backbone.backbone.dark3.1.m.2.conv2.pconv.conv.weight", "backbone.backbone.dark3.1.m.2.conv2.pconv.bn.weight", "backbone.backbone.dark3.1.m.2.conv2.pconv.bn.bias", "backbone.backbone.dark3.1.m.2.conv2.pconv.bn.running_mean", "backbone.backbone.dark3.1.m.2.conv2.pconv.bn.running_var", "backbone.backbone.dark4.0.dconv.conv.weight", "backbone.backbone.dark4.0.dconv.bn.weight", "backbone.backbone.dark4.0.dconv.bn.bias", "backbone.backbone.dark4.0.dconv.bn.running_mean", "backbone.backbone.dark4.0.dconv.bn.running_var", "backbone.backbone.dark4.0.pconv.conv.weight", "backbone.backbone.dark4.0.pconv.bn.weight", "backbone.backbone.dark4.0.pconv.bn.bias", "backbone.backbone.dark4.0.pconv.bn.running_mean", "backbone.backbone.dark4.0.pconv.bn.running_var", "backbone.backbone.dark4.1.conv1.conv.weight", "backbone.backbone.dark4.1.conv1.bn.weight", "backbone.backbone.dark4.1.conv1.bn.bias", "backbone.backbone.dark4.1.conv1.bn.running_mean", "backbone.backbone.dark4.1.conv1.bn.running_var", "backbone.backbone.dark4.1.conv2.conv.weight", "backbone.backbone.dark4.1.conv2.bn.weight", "backbone.backbone.dark4.1.conv2.bn.bias", "backbone.backbone.dark4.1.conv2.bn.running_mean", "backbone.backbone.dark4.1.conv2.bn.running_var", "backbone.backbone.dark4.1.conv3.conv.weight", "backbone.backbone.dark4.1.conv3.bn.weight", "backbone.backbone.dark4.1.conv3.bn.bias", "backbone.backbone.dark4.1.conv3.bn.running_mean", "backbone.backbone.dark4.1.conv3.bn.running_var", "backbone.backbone.dark4.1.m.0.conv1.conv.weight", "backbone.backbone.dark4.1.m.0.conv1.bn.weight", "backbone.backbone.dark4.1.m.0.conv1.bn.bias", "backbone.backbone.dark4.1.m.0.conv1.bn.running_mean", "backbone.backbone.dark4.1.m.0.conv1.bn.running_var", "backbone.backbone.dark4.1.m.0.conv2.dconv.conv.weight", "backbone.backbone.dark4.1.m.0.conv2.dconv.bn.weight", "backbone.backbone.dark4.1.m.0.conv2.dconv.bn.bias", "backbone.backbone.dark4.1.m.0.conv2.dconv.bn.running_mean", "backbone.backbone.dark4.1.m.0.conv2.dconv.bn.running_var", "backbone.backbone.dark4.1.m.0.conv2.pconv.conv.weight", "backbone.backbone.dark4.1.m.0.conv2.pconv.bn.weight", "backbone.backbone.dark4.1.m.0.conv2.pconv.bn.bias", "backbone.backbone.dark4.1.m.0.conv2.pconv.bn.running_mean", "backbone.backbone.dark4.1.m.0.conv2.pconv.bn.running_var", "backbone.backbone.dark4.1.m.1.conv1.conv.weight", "backbone.backbone.dark4.1.m.1.conv1.bn.weight", "backbone.backbone.dark4.1.m.1.conv1.bn.bias", "backbone.backbone.dark4.1.m.1.conv1.bn.running_mean", "backbone.backbone.dark4.1.m.1.conv1.bn.running_var", "backbone.backbone.dark4.1.m.1.conv2.dconv.conv.weight", "backbone.backbone.dark4.1.m.1.conv2.dconv.bn.weight", "backbone.backbone.dark4.1.m.1.conv2.dconv.bn.bias", "backbone.backbone.dark4.1.m.1.conv2.dconv.bn.running_mean", "backbone.backbone.dark4.1.m.1.conv2.dconv.bn.running_var", "backbone.backbone.dark4.1.m.1.conv2.pconv.conv.weight", "backbone.backbone.dark4.1.m.1.conv2.pconv.bn.weight", "backbone.backbone.dark4.1.m.1.conv2.pconv.bn.bias", "backbone.backbone.dark4.1.m.1.conv2.pconv.bn.running_mean", "backbone.backbone.dark4.1.m.1.conv2.pconv.bn.running_var", "backbone.backbone.dark4.1.m.2.conv1.conv.weight", "backbone.backbone.dark4.1.m.2.conv1.bn.weight", "backbone.backbone.dark4.1.m.2.conv1.bn.bias", "backbone.backbone.dark4.1.m.2.conv1.bn.running_mean", "backbone.backbone.dark4.1.m.2.conv1.bn.running_var", "backbone.backbone.dark4.1.m.2.conv2.dconv.conv.weight", "backbone.backbone.dark4.1.m.2.conv2.dconv.bn.weight", "backbone.backbone.dark4.1.m.2.conv2.dconv.bn.bias", "backbone.backbone.dark4.1.m.2.conv2.dconv.bn.running_mean", "backbone.backbone.dark4.1.m.2.conv2.dconv.bn.running_var", "backbone.backbone.dark4.1.m.2.conv2.pconv.conv.weight", "backbone.backbone.dark4.1.m.2.conv2.pconv.bn.weight", "backbone.backbone.dark4.1.m.2.conv2.pconv.bn.bias", "backbone.backbone.dark4.1.m.2.conv2.pconv.bn.running_mean", "backbone.backbone.dark4.1.m.2.conv2.pconv.bn.running_var", "backbone.backbone.dark5.0.dconv.conv.weight", "backbone.backbone.dark5.0.dconv.bn.weight", "backbone.backbone.dark5.0.dconv.bn.bias", "backbone.backbone.dark5.0.dconv.bn.running_mean", "backbone.backbone.dark5.0.dconv.bn.running_var", "backbone.backbone.dark5.0.pconv.conv.weight", "backbone.backbone.dark5.0.pconv.bn.weight", "backbone.backbone.dark5.0.pconv.bn.bias", "backbone.backbone.dark5.0.pconv.bn.running_mean", "backbone.backbone.dark5.0.pconv.bn.running_var", "backbone.backbone.dark5.1.conv1.conv.weight", "backbone.backbone.dark5.1.conv1.bn.weight", "backbone.backbone.dark5.1.conv1.bn.bias", "backbone.backbone.dark5.1.conv1.bn.running_mean", "backbone.backbone.dark5.1.conv1.bn.running_var", "backbone.backbone.dark5.1.conv2.conv.weight", "backbone.backbone.dark5.1.conv2.bn.weight", "backbone.backbone.dark5.1.conv2.bn.bias", "backbone.backbone.dark5.1.conv2.bn.running_mean", "backbone.backbone.dark5.1.conv2.bn.running_var", "backbone.backbone.dark5.2.conv1.conv.weight", "backbone.backbone.dark5.2.conv1.bn.weight", "backbone.backbone.dark5.2.conv1.bn.bias", "backbone.backbone.dark5.2.conv1.bn.running_mean", "backbone.backbone.dark5.2.conv1.bn.running_var", "backbone.backbone.dark5.2.conv2.conv.weight", "backbone.backbone.dark5.2.conv2.bn.weight", "backbone.backbone.dark5.2.conv2.bn.bias", "backbone.backbone.dark5.2.conv2.bn.running_mean", "backbone.backbone.dark5.2.conv2.bn.running_var", "backbone.backbone.dark5.2.conv3.conv.weight", "backbone.backbone.dark5.2.conv3.bn.weight", "backbone.backbone.dark5.2.conv3.bn.bias", "backbone.backbone.dark5.2.conv3.bn.running_mean", "backbone.backbone.dark5.2.conv3.bn.running_var", "backbone.backbone.dark5.2.m.0.conv1.conv.weight", "backbone.backbone.dark5.2.m.0.conv1.bn.weight", "backbone.backbone.dark5.2.m.0.conv1.bn.bias", "backbone.backbone.dark5.2.m.0.conv1.bn.running_mean", "backbone.backbone.dark5.2.m.0.conv1.bn.running_var", "backbone.backbone.dark5.2.m.0.conv2.dconv.conv.weight", "backbone.backbone.dark5.2.m.0.conv2.dconv.bn.weight", "backbone.backbone.dark5.2.m.0.conv2.dconv.bn.bias", "backbone.backbone.dark5.2.m.0.conv2.dconv.bn.running_mean", "backbone.backbone.dark5.2.m.0.conv2.dconv.bn.running_var", "backbone.backbone.dark5.2.m.0.conv2.pconv.conv.weight", "backbone.backbone.dark5.2.m.0.conv2.pconv.bn.weight", "backbone.backbone.dark5.2.m.0.conv2.pconv.bn.bias", "backbone.backbone.dark5.2.m.0.conv2.pconv.bn.running_mean", "backbone.backbone.dark5.2.m.0.conv2.pconv.bn.running_var", "backbone.lateral_conv0.conv.weight", "backbone.lateral_conv0.bn.weight", "backbone.lateral_conv0.bn.bias", "backbone.lateral_conv0.bn.running_mean", "backbone.lateral_conv0.bn.running_var", "backbone.C3_p4.conv1.conv.weight", "backbone.C3_p4.conv1.bn.weight", "backbone.C3_p4.conv1.bn.bias", "backbone.C3_p4.conv1.bn.running_mean", "backbone.C3_p4.conv1.bn.running_var", "backbone.C3_p4.conv2.conv.weight", "backbone.C3_p4.conv2.bn.weight", "backbone.C3_p4.conv2.bn.bias", "backbone.C3_p4.conv2.bn.running_mean", "backbone.C3_p4.conv2.bn.running_var", "backbone.C3_p4.conv3.conv.weight", "backbone.C3_p4.conv3.bn.weight", "backbone.C3_p4.conv3.bn.bias", "backbone.C3_p4.conv3.bn.running_mean", "backbone.C3_p4.conv3.bn.running_var", "backbone.C3_p4.m.0.conv1.conv.weight", "backbone.C3_p4.m.0.conv1.bn.weight", "backbone.C3_p4.m.0.conv1.bn.bias", "backbone.C3_p4.m.0.conv1.bn.running_mean", "backbone.C3_p4.m.0.conv1.bn.running_var", "backbone.C3_p4.m.0.conv2.dconv.conv.weight", "backbone.C3_p4.m.0.conv2.dconv.bn.weight", "backbone.C3_p4.m.0.conv2.dconv.bn.bias", "backbone.C3_p4.m.0.conv2.dconv.bn.running_mean", "backbone.C3_p4.m.0.conv2.dconv.bn.running_var", "backbone.C3_p4.m.0.conv2.pconv.conv.weight", "backbone.C3_p4.m.0.conv2.pconv.bn.weight", "backbone.C3_p4.m.0.conv2.pconv.bn.bias", "backbone.C3_p4.m.0.conv2.pconv.bn.running_mean", "backbone.C3_p4.m.0.conv2.pconv.bn.running_var", "backbone.reduce_conv1.conv.weight", "backbone.reduce_conv1.bn.weight", "backbone.reduce_conv1.bn.bias", "backbone.reduce_conv1.bn.running_mean", "backbone.reduce_conv1.bn.running_var", "backbone.C3_p3.conv1.conv.weight", "backbone.C3_p3.conv1.bn.weight", "backbone.C3_p3.conv1.bn.bias", "backbone.C3_p3.conv1.bn.running_mean", "backbone.C3_p3.conv1.bn.running_var", "backbone.C3_p3.conv2.conv.weight", "backbone.C3_p3.conv2.bn.weight", "backbone.C3_p3.conv2.bn.bias", "backbone.C3_p3.conv2.bn.running_mean", "backbone.C3_p3.conv2.bn.running_var", "backbone.C3_p3.conv3.conv.weight", "backbone.C3_p3.conv3.bn.weight", "backbone.C3_p3.conv3.bn.bias", "backbone.C3_p3.conv3.bn.running_mean", "backbone.C3_p3.conv3.bn.running_var", "backbone.C3_p3.m.0.conv1.conv.weight", "backbone.C3_p3.m.0.conv1.bn.weight", "backbone.C3_p3.m.0.conv1.bn.bias", "backbone.C3_p3.m.0.conv1.bn.running_mean", "backbone.C3_p3.m.0.conv1.bn.running_var", "backbone.C3_p3.m.0.conv2.dconv.conv.weight", "backbone.C3_p3.m.0.conv2.dconv.bn.weight", "backbone.C3_p3.m.0.conv2.dconv.bn.bias", "backbone.C3_p3.m.0.conv2.dconv.bn.running_mean", "backbone.C3_p3.m.0.conv2.dconv.bn.running_var", "backbone.C3_p3.m.0.conv2.pconv.conv.weight", "backbone.C3_p3.m.0.conv2.pconv.bn.weight", "backbone.C3_p3.m.0.conv2.pconv.bn.bias", "backbone.C3_p3.m.0.conv2.pconv.bn.running_mean", "backbone.C3_p3.m.0.conv2.pconv.bn.running_var", "backbone.bu_conv2.dconv.conv.weight", "backbone.bu_conv2.dconv.bn.weight", "backbone.bu_conv2.dconv.bn.bias", "backbone.bu_conv2.dconv.bn.running_mean", "backbone.bu_conv2.dconv.bn.running_var", "backbone.bu_conv2.pconv.conv.weight", "backbone.bu_conv2.pconv.bn.weight", "backbone.bu_conv2.pconv.bn.bias", "backbone.bu_conv2.pconv.bn.running_mean", "backbone.bu_conv2.pconv.bn.running_var", "backbone.C3_n3.conv1.conv.weight", "backbone.C3_n3.conv1.bn.weight", "backbone.C3_n3.conv1.bn.bias", "backbone.C3_n3.conv1.bn.running_mean", "backbone.C3_n3.conv1.bn.running_var", "backbone.C3_n3.conv2.conv.weight", "backbone.C3_n3.conv2.bn.weight", "backbone.C3_n3.conv2.bn.bias", "backbone.C3_n3.conv2.bn.running_mean", "backbone.C3_n3.conv2.bn.running_var", "backbone.C3_n3.conv3.conv.weight", "backbone.C3_n3.conv3.bn.weight", "backbone.C3_n3.conv3.bn.bias", "backbone.C3_n3.conv3.bn.running_mean", "backbone.C3_n3.conv3.bn.running_var", "backbone.C3_n3.m.0.conv1.conv.weight", "backbone.C3_n3.m.0.conv1.bn.weight", "backbone.C3_n3.m.0.conv1.bn.bias", "backbone.C3_n3.m.0.conv1.bn.running_mean", "backbone.C3_n3.m.0.conv1.bn.running_var", "backbone.C3_n3.m.0.conv2.dconv.conv.weight", "backbone.C3_n3.m.0.conv2.dconv.bn.weight", "backbone.C3_n3.m.0.conv2.dconv.bn.bias", "backbone.C3_n3.m.0.conv2.dconv.bn.running_mean", "backbone.C3_n3.m.0.conv2.dconv.bn.running_var", "backbone.C3_n3.m.0.conv2.pconv.conv.weight", "backbone.C3_n3.m.0.conv2.pconv.bn.weight", "backbone.C3_n3.m.0.conv2.pconv.bn.bias", "backbone.C3_n3.m.0.conv2.pconv.bn.running_mean", "backbone.C3_n3.m.0.conv2.pconv.bn.running_var", "backbone.bu_conv1.dconv.conv.weight", "backbone.bu_conv1.dconv.bn.weight", "backbone.bu_conv1.dconv.bn.bias", "backbone.bu_conv1.dconv.bn.running_mean", "backbone.bu_conv1.dconv.bn.running_var", "backbone.bu_conv1.pconv.conv.weight", "backbone.bu_conv1.pconv.bn.weight", "backbone.bu_conv1.pconv.bn.bias", "backbone.bu_conv1.pconv.bn.running_mean", "backbone.bu_conv1.pconv.bn.running_var", "backbone.C3_n4.conv1.conv.weight", "backbone.C3_n4.conv1.bn.weight", "backbone.C3_n4.conv1.bn.bias", "backbone.C3_n4.conv1.bn.running_mean", "backbone.C3_n4.conv1.bn.running_var", "backbone.C3_n4.conv2.conv.weight", "backbone.C3_n4.conv2.bn.weight", "backbone.C3_n4.conv2.bn.bias", "backbone.C3_n4.conv2.bn.running_mean", "backbone.C3_n4.conv2.bn.running_var", "backbone.C3_n4.conv3.conv.weight", "backbone.C3_n4.conv3.bn.weight", "backbone.C3_n4.conv3.bn.bias", "backbone.C3_n4.conv3.bn.running_mean", "backbone.C3_n4.conv3.bn.running_var", "backbone.C3_n4.m.0.conv1.conv.weight", "backbone.C3_n4.m.0.conv1.bn.weight", "backbone.C3_n4.m.0.conv1.bn.bias", "backbone.C3_n4.m.0.conv1.bn.running_mean", "backbone.C3_n4.m.0.conv1.bn.running_var", "backbone.C3_n4.m.0.conv2.dconv.conv.weight", "backbone.C3_n4.m.0.conv2.dconv.bn.weight", "backbone.C3_n4.m.0.conv2.dconv.bn.bias", "backbone.C3_n4.m.0.conv2.dconv.bn.running_mean", "backbone.C3_n4.m.0.conv2.dconv.bn.running_var", "backbone.C3_n4.m.0.conv2.pconv.conv.weight", "backbone.C3_n4.m.0.conv2.pconv.bn.weight", "backbone.C3_n4.m.0.conv2.pconv.bn.bias", "backbone.C3_n4.m.0.conv2.pconv.bn.running_mean", "backbone.C3_n4.m.0.conv2.pconv.bn.running_var", "head.cls_convs.0.0.dconv.conv.weight", "head.cls_convs.0.0.dconv.bn.weight", "head.cls_convs.0.0.dconv.bn.bias", "head.cls_convs.0.0.dconv.bn.running_mean", "head.cls_convs.0.0.dconv.bn.running_var", "head.cls_convs.0.0.pconv.conv.weight", "head.cls_convs.0.0.pconv.bn.weight", "head.cls_convs.0.0.pconv.bn.bias", "head.cls_convs.0.0.pconv.bn.running_mean", "head.cls_convs.0.0.pconv.bn.running_var", "head.cls_convs.0.1.dconv.conv.weight", "head.cls_convs.0.1.dconv.bn.weight", "head.cls_convs.0.1.dconv.bn.bias", "head.cls_convs.0.1.dconv.bn.running_mean", "head.cls_convs.0.1.dconv.bn.running_var", "head.cls_convs.0.1.pconv.conv.weight", "head.cls_convs.0.1.pconv.bn.weight", "head.cls_convs.0.1.pconv.bn.bias", "head.cls_convs.0.1.pconv.bn.running_mean", "head.cls_convs.0.1.pconv.bn.running_var", "head.cls_convs.1.0.dconv.conv.weight", "head.cls_convs.1.0.dconv.bn.weight", "head.cls_convs.1.0.dconv.bn.bias", "head.cls_convs.1.0.dconv.bn.running_mean", "head.cls_convs.1.0.dconv.bn.running_var", "head.cls_convs.1.0.pconv.conv.weight", "head.cls_convs.1.0.pconv.bn.weight", "head.cls_convs.1.0.pconv.bn.bias", "head.cls_convs.1.0.pconv.bn.running_mean", "head.cls_convs.1.0.pconv.bn.running_var", "head.cls_convs.1.1.dconv.conv.weight", "head.cls_convs.1.1.dconv.bn.weight", "head.cls_convs.1.1.dconv.bn.bias", "head.cls_convs.1.1.dconv.bn.running_mean", "head.cls_convs.1.1.dconv.bn.running_var", "head.cls_convs.1.1.pconv.conv.weight", "head.cls_convs.1.1.pconv.bn.weight", "head.cls_convs.1.1.pconv.bn.bias", "head.cls_convs.1.1.pconv.bn.running_mean", "head.cls_convs.1.1.pconv.bn.running_var", "head.cls_convs.2.0.dconv.conv.weight", "head.cls_convs.2.0.dconv.bn.weight", "head.cls_convs.2.0.dconv.bn.bias", "head.cls_convs.2.0.dconv.bn.running_mean", "head.cls_convs.2.0.dconv.bn.running_var", "head.cls_convs.2.0.pconv.conv.weight", "head.cls_convs.2.0.pconv.bn.weight", "head.cls_convs.2.0.pconv.bn.bias", "head.cls_convs.2.0.pconv.bn.running_mean", "head.cls_convs.2.0.pconv.bn.running_var", "head.cls_convs.2.1.dconv.conv.weight", "head.cls_convs.2.1.dconv.bn.weight", "head.cls_convs.2.1.dconv.bn.bias", "head.cls_convs.2.1.dconv.bn.running_mean", "head.cls_convs.2.1.dconv.bn.running_var", "head.cls_convs.2.1.pconv.conv.weight", "head.cls_convs.2.1.pconv.bn.weight", "head.cls_convs.2.1.pconv.bn.bias", "head.cls_convs.2.1.pconv.bn.running_mean", "head.cls_convs.2.1.pconv.bn.running_var", "head.reg_convs.0.0.dconv.conv.weight", "head.reg_convs.0.0.dconv.bn.weight", "head.reg_convs.0.0.dconv.bn.bias", "head.reg_convs.0.0.dconv.bn.running_mean", "head.reg_convs.0.0.dconv.bn.running_var", "head.reg_convs.0.0.pconv.conv.weight", "head.reg_convs.0.0.pconv.bn.weight", "head.reg_convs.0.0.pconv.bn.bias", "head.reg_convs.0.0.pconv.bn.running_mean", "head.reg_convs.0.0.pconv.bn.running_var", "head.reg_convs.0.1.dconv.conv.weight", "head.reg_convs.0.1.dconv.bn.weight", "head.reg_convs.0.1.dconv.bn.bias", "head.reg_convs.0.1.dconv.bn.running_mean", "head.reg_convs.0.1.dconv.bn.running_var", "head.reg_convs.0.1.pconv.conv.weight", "head.reg_convs.0.1.pconv.bn.weight", "head.reg_convs.0.1.pconv.bn.bias", "head.reg_convs.0.1.pconv.bn.running_mean", "head.reg_convs.0.1.pconv.bn.running_var", "head.reg_convs.1.0.dconv.conv.weight", "head.reg_convs.1.0.dconv.bn.weight", "head.reg_convs.1.0.dconv.bn.bias", "head.reg_convs.1.0.dconv.bn.running_mean", "head.reg_convs.1.0.dconv.bn.running_var", "head.reg_convs.1.0.pconv.conv.weight", "head.reg_convs.1.0.pconv.bn.weight", "head.reg_convs.1.0.pconv.bn.bias", "head.reg_convs.1.0.pconv.bn.running_mean", "head.reg_convs.1.0.pconv.bn.running_var", "head.reg_convs.1.1.dconv.conv.weight", "head.reg_convs.1.1.dconv.bn.weight", "head.reg_convs.1.1.dconv.bn.bias", "head.reg_convs.1.1.dconv.bn.running_mean", "head.reg_convs.1.1.dconv.bn.running_var", "head.reg_convs.1.1.pconv.conv.weight", "head.reg_convs.1.1.pconv.bn.weight", "head.reg_convs.1.1.pconv.bn.bias", "head.reg_convs.1.1.pconv.bn.running_mean", "head.reg_convs.1.1.pconv.bn.running_var", "head.reg_convs.2.0.dconv.conv.weight", "head.reg_convs.2.0.dconv.bn.weight", "head.reg_convs.2.0.dconv.bn.bias", "head.reg_convs.2.0.dconv.bn.running_mean", "head.reg_convs.2.0.dconv.bn.running_var", "head.reg_convs.2.0.pconv.conv.weight", "head.reg_convs.2.0.pconv.bn.weight", "head.reg_convs.2.0.pconv.bn.bias", "head.reg_convs.2.0.pconv.bn.running_mean", "head.reg_convs.2.0.pconv.bn.running_var", "head.reg_convs.2.1.dconv.conv.weight", "head.reg_convs.2.1.dconv.bn.weight", "head.reg_convs.2.1.dconv.bn.bias", "head.reg_convs.2.1.dconv.bn.running_mean", "head.reg_convs.2.1.dconv.bn.running_var", "head.reg_convs.2.1.pconv.conv.weight", "head.reg_convs.2.1.pconv.bn.weight", "head.reg_convs.2.1.pconv.bn.bias", "head.reg_convs.2.1.pconv.bn.running_mean", "head.reg_convs.2.1.pconv.bn.running_var", "head.cls_preds.0.weight", "head.cls_preds.0.bias", "head.cls_preds.1.weight", "head.cls_preds.1.bias", "head.cls_preds.2.weight", "head.cls_preds.2.bias", "head.reg_preds.0.weight", "head.reg_preds.0.bias", "head.reg_preds.1.weight", "head.reg_preds.1.bias", "head.reg_preds.2.weight", "head.reg_preds.2.bias", "head.obj_preds.0.weight", "head.obj_preds.0.bias", "head.obj_preds.1.weight", "head.obj_preds.1.bias", "head.obj_preds.2.weight", "head.obj_preds.2.bias", "head.stems.0.conv.weight", "head.stems.0.bn.weight", "head.stems.0.bn.bias", "head.stems.0.bn.running_mean", "head.stems.0.bn.running_var", "head.stems.1.conv.weight", "head.stems.1.bn.weight", "head.stems.1.bn.bias", "head.stems.1.bn.running_mean", "head.stems.1.bn.running_var", "head.stems.2.conv.weight", "head.stems.2.bn.weight", "head.stems.2.bn.bias", "head.stems.2.bn.running_mean", "head.stems.2.bn.running_var".
Unexpected key(s) in state_dict: "start_epoch", "model", "optimizer"
我训练好的的yolox_nano.pth是没问题的,可以正常预测(推理):
我认为是我使用自己的1类的数据集加上单卡训练加上没有使用半精度训练的原因,不过我之前还试过直接把model. load_state_dict(ckpt)这个代码直接注释掉:
这个model. load_state_dict(ckpt)的代码应该是加载训练好的模型的,但是我没有使用这个然后进行转换,发现可以转换成功:
onnx文件打开看发现也没问题:
最后我也成功转换了ncnn文件:
但最后部署到安卓上面的时候就出问题了,完全检测不到:
我认为这明显就是.pth文件转换.onnx文件的时候出了问题,因为我完全就是没有加载ckpt模型。
我在这里卡了好长时间,希望有过使用自己的数据集训练过yolox_nano.pth模型来部署到安卓上面的大佬可以教我一下,十分感谢,这个部署对我来说很重要。