- from rknn.api import RKNN
- if __name__ == '__main__':
- rknn = RKNN(verbose = True)
- rknn.load_tensorflow(tf_pb='model1.pb',
- inputs=['input_1'],
- outputs=['conv2d_24/Sigmoid'],
- input_size_list=[[256, 256, 1]])
- # rknn.config(channel_mean_value='0 0 0 255', reorder_channel='0 1 2')
- rknn.config(channel_mean_value='0 255', reorder_channel='0 1 2')
-
- rknn.build(do_quantization=True, dataset='./dataset.txt')
- #rknn.export_rknn('./mobilenet-ssd-8.rknn')
- rknn.export_rknn('unet_tf.rknn')
- exit(0)
复制代码
and the loading rknn model and run inference is:- from rknn.api import RKNN
- import cv2
- if __name__ == '__main__':
- rknn = RKNN(verbose = True)
- print('-->loading model')
- rknn.load_rknn('./unet_tf.rknn')
- #rknn.load_rknn('./yolov3.rknn')
- print('loading model done')
- print('--> Init runtime environment')
- ret = rknn.init_runtime()
- if ret != 0:
- print('Init runtime environment failed')
- exit(ret)
- print('done')
- image = cv2.imread('0test.png')
- print(image.shape)
- gray = cv2.cvtColor(image, cv2.COLOR_BGR2GRAY)
- gray = cv2.resize(gray, (256,256))
- out_boxes2 = rknn.inference(inputs=[gray])
- print(out_boxes2)
复制代码
The error is:- D [print_tensor:136]out(0): id[ 85] vtl[1] const[0] shape[ 31, 31, 512, 1 ] fmt[u8 ] qnt[ASM zp= 0, scale=0.015807]
- D [setup_node:368]Setup node id[28] uid[48] op[CONCAT]
- E [op_check:321]Concat input dims size(31 vs 32)
- E [setup_node:383]Check node[28] CONCAT fail
- I [remove_client_ops:4942]remove_client_ops num=0
- I [remove_client_ops:4953]remove_client_ops finish
- Create RKNN model fail!
- E Catch exception when init runtime!
- E Traceback (most recent call last):
- E File "rknn/api/rknn_base.py", line 988, in rknn.api.rknn_base.RKNNBase.init_runtime
- E File "rknn/api/rknn_runtime.py", line 320, in rknn.api.rknn_runtime.RKNNRuntime.build_graph
- E Exception: RKNN init failed. error code: RKNN_ERR_MODEL_INVALID
- Init runtime environment failed
复制代码
Clearly, the error is shape missmatched. But why I don't have this error in my tensorflow model? I can run inference normally with my tf model but but not rknn.hisping 发表于 2020-2-24 18:01
you expect a single channel when transform model,but you input three channels picture when runnin ...
欢迎光临 Toybrick (https://t.rock-chips.com/) | Powered by Discuz! X3.3 |