|
caffe转rknn模型转成功,但测试demo时报错,下面是我的代码:
import numpy as np
2 import cv2
3 from rknn.api import RKNN
4
5 if __name__ == '__main__':
6
7 # Create RKNN object
8 rknn = RKNN()
9
10 # pre-process config
11 print('--> config model')
12 rknn.config(channel_mean_value='123.675 123.675 123.675 58.395', reorder_channel='2 1 0')
13 print('done')
14
15 # Load tensorflow model
16 print('--> Loading model')
17 ret = rknn.load_caffe(model='./model.prototxt',
18 proto='caffe',
19 blobs='./model.caffemodel')
23 '''
24 ret = rknn.load_onnx(model='./LResNet34-IR-simple.onnx')
25 '''
26 if ret != 0:
27 print('Load model failed! Ret = {}'.format(ret))
28 exit(ret)
29 print('done')
30
31 # Build model
32 print('--> Building model')
33 ret = rknn.build(do_quantization=True, dataset='./dataset.txt')
34 if ret != 0:
35 print('Build model failed!')
36 exit(ret)
37 print('done')
38
39 # Export rknn model
40 print('--> Export RKNN model')
41 ret = rknn.export_rknn('./model.rknn')
42 if ret != 0:
43 print('Export rknn model failed!')
44 exit(ret)
45 print('done')
46
47 # Set inputs
48 old_img = cv2.imread('jj1.jpg')
49 old_img = cv2.resize(old_img, (112,112))
50 img = cv2.cvtColor(old_img, cv2.COLOR_BGR2RGB)
51
52 print('--> Init runtime environment')
53 ret = rknn.init_runtime()
54 if ret != 0:
55 print('Init runtime environment failed')
56 exit(ret)
57 print('done')
58
59 # Inference
60 print('--> Running model')
61 outputs = rknn.inference(inputs=[img])
62
63 print(outputs)
rknn.release()
运行时报的错:
--> config model
done
--> Loading model
done
--> Building model
W:tensorflow:From /home/derron/.local/lib/python3.6/site-packages/tensorflow/python/ops/control_flow_ops.py:3632: colocate_with (from tensorflow.python.framework.ops) is deprecated and will
be removed in a future version.Instructions for updating:
Colocations handled automatically by placer.
W:tensorflow:From /home/derron/.local/lib/python3.6/site-packages/tensorflow/python/ops/control_flow_ops.py:1941: py_func (from tensorflow.python.ops.script_ops) is deprecated and will be r
emoved in a future version.Instructions for updating:
tf.py_func is deprecated in TF V2. Instead, use
tf.py_function, which takes a python function which manipulates tf eager
tensors instead of numpy arrays. It's easy to convert a tf eager tensor to
an ndarray (just call tensor.numpy()) but having access to eager tensors
means `tf.py_function`s can use accelerators such as GPUs as well as
being differentiable using a gradient tape.
W Warning: Axis may need to be adjusted according to original model shape.
done
--> Export RKNN model
done
--> Init runtime environment
done
--> Running model
ASSERT in NeuralNet.cpp.getNNInst(1471): (m_NnInst.outImageZeroPoint == 0x0) && "only UINT8 support tensor flow quantization\n"
terminate called after throwing an instance of 'bool'
Aborted (core dumped)
有大神可以帮我看下吗
|
|