/usr/local/lib/python3.5/dist-packages/onnx_tf/common/__init__.py:87: UserWarning: FrontendHandler.get_outputs_names is deprecated. It will be removed in future release.. Use node.outputs instead.
warnings.warn(message)
checkpoint_best.pt ********************
E Catch exception when loading pytorch model: checkpoint_best.pt!
E Traceback (most recent call last):
E File "rknn/api/rknn_base.py", line 657, in rknn.api.rknn_base.RKNNBase.load_pytorch
E File "rknn/base/RKNNlib/app/importer/import_pytorch.py", line 97, in rknn.base.RKNNlib.app.importer.import_pytorch.ImportPytorch.run
E File "rknn/base/RKNNlib/converter/convert_pytorch.py", line 737, in rknn.base.RKNNlib.converter.convert_pytorch.convert_pytorch.__init__
E File "/usr/local/lib/python3.5/dist-packages/torch/jit/__init__.py", line 235, in load
E cpp_module = torch._C.import_ir_module(cu, f, map_location, _extra_files)
E RuntimeError: [enforce fail at inline_container.cc:143] . PytorchStreamReader failed reading zip archive: failed finding central directory
E frame #0: c10::ThrowEnforceNotMet(char const*, int, char const*, std::string const&, void const*) + 0x47 (0x7f33ec7e4d37 in /usr/local/lib/python3.5/dist-packages/torch/lib/libc10.so)
E frame #1: caffe2::serialize:yTorchStreamReader::valid(char const*, char const*) + 0x72 (0x7f33ef903db2 in /usr/local/lib/python3.5/dist-packages/torch/lib/libtorch.so)
E frame #2: caffe2::serialize:yTorchStreamReader::init() + 0xa1 (0x7f33ef906d81 in /usr/local/lib/python3.5/dist-packages/torch/lib/libtorch.so)
E frame #3: caffe2::serialize:yTorchStreamReader:yTorchStreamReader(std::string const&) + 0x64 (0x7f33ef909e54 in /usr/local/lib/python3.5/dist-packages/torch/lib/libtorch.so)
E frame #4: torch::jit::import_ir_module(std::shared_ptr<torch::jit::script::CompilationUnit>, std::string const&, c10:ptional<c10:evice>, std::unordered_map<std::string, std::string, std::hash<std::string>, std::equal_to<std::string>, std::allocator<std::pair<std::string const, std::string> > >&) + 0x35 (0x7f33f0c69a95 in /usr/local/lib/python3.5/dist-packages/torch/lib/libtorch.so)
E frame #5: <unknown function> + 0x7765bb (0x7f342e3e35bb in /usr/local/lib/python3.5/dist-packages/torch/lib/libtorch_python.so)
E frame #6: <unknown function> + 0x2956c4 (0x7f342df026c4 in /usr/local/lib/python3.5/dist-packages/torch/lib/libtorch_python.so)
E <omitting python frames>
E frame #10: <unknown function> + 0x1df15 (0x7f34373b3f15 in /usr/local/lib/python3.5/dist-packages/rknn/base/RKNNlib/converter/convert_pytorch.cpython-35m-x86_64-linux-gnu.so)
E frame #11: <unknown function> + 0x1ed5f (0x7f34373b4d5f in /usr/local/lib/python3.5/dist-packages/rknn/base/RKNNlib/converter/convert_pytorch.cpython-35m-x86_64-linux-gnu.so)
E frame #12: <unknown function> + 0x60b48 (0x7f34373f6b48 in /usr/local/lib/python3.5/dist-packages/rknn/base/RKNNlib/converter/convert_pytorch.cpython-35m-x86_64-linux-gnu.so)
E frame #14: python3() [0x4f42ce]
E frame #16: python3() [0x5991b9]
E frame #17: python3() [0x56c40c]
E frame #18: <unknown function> + 0x65b0 (0x7f34388735b0 in /usr/local/lib/python3.5/dist-packages/rknn/base/RKNNlib/app/importer/import_pytorch.cpython-35m-x86_64-linux-gnu.so)
E frame #19: <unknown function> + 0xbb87 (0x7f3438878b87 in /usr/local/lib/python3.5/dist-packages/rknn/base/RKNNlib/app/importer/import_pytorch.cpython-35m-x86_64-linux-gnu.so)
E frame #20: <unknown function> + 0x236bd (0x7f351b4266bd in /usr/local/lib/python3.5/dist-packages/rknn/api/rknn_base.cpython-35m-x86_64-linux-gnu.so)
E frame #21: <unknown function> + 0xc8fc3 (0x7f351b4cbfc3 in /usr/local/lib/python3.5/dist-packages/rknn/api/rknn_base.cpython-35m-x86_64-linux-gnu.so)
E frame #24: python3() [0x544399]
E frame #26: python3() [0x544399]
E frame #28: python3() [0x625042]
E frame #33: __libc_start_main + 0xf0 (0x7f359f8f3840 in /lib/x86_64-linux-gnu/libc.so.6)
Load model.pt failed!
转换代码:
import numpy as np
import cv2
from rknn.api import RKNN
input_size_list = [[3,224,224]]
# Load tensorflow model
print('--> Loading model')
ret = rknn.load_pytorch(model='checkpoint_best.pt', input_size_list=input_size_list)
if ret != 0:
print('Load model.pt failed!')
exit(ret)
print('done')
# Build model
print('--> Building model')
ret = rknn.build(do_quantization=True, dataset='./dataset.txt', pre_compile=False)
if ret != 0:
print('Build platemark failed!')
exit(ret)
print('done')
# Export rknn model
print('--> Export RKNN model')
ret = rknn.export_rknn('./rcfv4-20210106.rknn')
if ret != 0:
print('Export platemark.rknn failed!')
exit(ret)
print('done')