# Load model
print('--> Loading model')
model = ONNX_MODEL
ret = rknn.load_onnx(model=model)
if ret != 0:
print('Load model failed!')
exit(ret)
print('done')
作者: yuelaiyue 时间: 2021-3-17 10:05
我的模型是YOLOv5模型,但我尝试直接用pt文件转换为rknn的时候,又出现了如下问题:(还是加载模型的错误)
W Verbose file path is invalid, debug info will not dump to file.
--> Config model
done
--> Loading model
I Start importing pytorch...
./weights/best.pt ********************
D import clients finished
E Catch exception when loading pytorch model: ./weights/best.pt!
E Traceback (most recent call last):
E File "rknn\api\rknn_base.py", line 339, in rknn.api.rknn_base.RKNNBase.load_pytorch
E File "rknn\base\RKNNlib\RK_nn.py", line 146, in rknn.base.RKNNlib.RK_nn.RKnn.load_pytorch
E File "rknn\base\RKNNlib\app\importer\import_pytorch.py", line 128, in rknn.base.RKNNlib.app.importer.import_pytorch.ImportPytorch.run
E File "rknn\base\RKNNlib\converter\convert_pytorch_new.py", line 2243, in rknn.base.RKNNlib.converter.convert_pytorch_new.convert_pytorch.load
E File "D:\Anaconda3\envs\py363\lib\site-packages\torch\jit\__init__.py", line 228, in load
E cpp_module = torch._C.import_ir_module(cu, f, map_location, _extra_files)
E RuntimeError: [enforce fail at ..\caffe2\serialize\inline_container.cc:143] . PytorchStreamReader failed reading zip archive: failed finding central directory
Load Pytorch model failed!
我的加载代码如下:
weight = './weights/best.pt'