|
vgg16-bn.onnx不开量化转换成功,预测也成功;开量化build失败!同样的转换代码,转另一个onnx 就可以成功,不知什么原因?
转换代码:
#_*_coding: utf-8 _*_
import numpy as np
import cv2
from rknn.api import RKNN
from PIL import Image
if __name__ == '__main__':
# Create RKNN object
rknn = RKNN(verbose=True,verbose_file='./crnntcn.log')
# pre-process config
print('--> config model')
rknn.config( channel_mean_value='128 128 128 128', reorder_channel='0 1 2')#,batch_size=1,epochs=500#batch_size=1, ,quantized_dtype='dynamic_fixed_point-16',quantized_dtype='dynamic_fixed_point-8'
print('done')
# Load tensorflow model
print('--> Loading model')
ret = rknn.load_onnx(model = './vgg16-bn.onnx')
if ret != 0:
print('Load crnn_cnn failed! Ret = {}'.format(ret))
exit(ret)
print('done')
# Build model
print('--> Building model')
ret = rknn.build(do_quantization=True, dataset='/home/sysman/rknn/mv2/vggpic/dataset.txt')
if ret != 0:
print('Build crnn_cnn failed!')
exit(ret)
print('done')
# Export rknn model
print('--> Export RKNN model')
ret = rknn.export_rknn('./vgg.rknn')
if ret != 0:
print('Export crnn_cnn.rknn failed!')
exit(ret)
print('doneOKOK')
rknn.release()
出错部分:
。。。。。
D Quantize tensor @Conv_17_37:bias.
D Quantize tensor @Conv_14_40:bias.
D Quantize tensor @Conv_10_44:bias.
D Quantize tensor @Conv_7_47:bias.
D Quantize tensor @Conv_3_51:bias.
D Quantize tensor @Conv_0_54:bias.
I Clean.
D Optimizing network with qnt_single_transmit_quantize, align_quantize, broadcast_quantize, qnt_adjust_coef
D Quantize tensor(@MaxPool_43_11ut0) with tensor(@Relu_42_12ut0)
D Quantize tensor(@attach_Gemm_53/out0_0ut0) with tensor(@Gemm_53_1ut0)
[TRAINER]Quantization complete.
E Catch exception when building RKNN model!
T Traceback (most recent call last):
T File "rknn/api/rknn_base.py", line 498, in rknn.api.rknn_base.RKNNBase.build
T File "rknn/api/rknn_base.py", line 1071, in rknn.api.rknn_base.RKNNBase._quantize
T File "rknn/base/RKNNlib/app/tensorzone/quantization.py", line 151, in rknn.base.RKNNlib.app.tensorzone.quantization.Quantization.run
T File "rknn/base/RKNNlib/RKNNnet.py", line 341, in rknn.base.RKNNlib.RKNNnet.RKNNNet.save_data
T File "rknn/base/RKNNlib/RKNNnet.py", line 355, in rknn.base.RKNNlib.RKNNnet.RKNNNet._save_old_data
T File "rknn/base/RKNNlib/RKNNnet.py", line 363, in rknn.base.RKNNlib.RKNNnet.RKNNNet._save_old_data
T File "/usr/local/lib/python3.5/dist-packages/numpy/lib/npyio.py", line 511, in save
T pickle_kwargs=pickle_kwargs)
T File "/usr/local/lib/python3.5/dist-packages/numpy/lib/format.py", line 586, in write_array
T pickle.dump(array, fp, protocol=2, **pickle_kwargs)
T MemoryError
请高手指点,多谢了
|
|