def onnx_to_rknn(input_model, output_model): input_model, output_model = \
[os.path.expanduser(f) for f in [input_model, output_model]]
from rknn.api import RKNN rknn = RKNN(verbose=True)
print('--> Config model') ret = rknn.config(mean_values=[[127, 127, 127]], std_values=[[128, 128, 128]])
if ret != 0:
print('Config failed!')
exit(ret)
print('done')
# Load model
print('--> Loading model') ret = rknn.load_onnx(model=input_model)
if ret != 0:
print('Load failed!')
exit(ret)
print('done')
# Build model
print('--> Building model') ret = rknn.build(do_quantization=False)
if ret != 0:
print('Build failed!')
exit(ret)
print('done')
# Export rknn model
print('--> Export RKNN model') ret = rknn.export_rknn(output_model)
if ret != 0:
print('Export failed!')
exit(ret)
print('done')
rknn.release()
模型和转模型日志见附件。
转好之后,我在 C++ 里调用该模型,会报错,报错信息如下:
E RKNNAPI: rknn_init, msg_load_ack fail, ack = 1(ACK_FAIL), expect 0(ACK_SUCC)!
E RKNNAPI: ==============================================
E RKNNAPI: RKNN VERSION:
E RKNNAPI: API: 1.3.2 (7c17e39 build: 2020-04-02 14:49:04)
E RKNNAPI: DRV: 1.3.4 (399a00a build: 2020-07-24 14:09:19)
E RKNNAPI: ==============================================
rknn_init fail! ret=-6