Toybrick

caffe转rknn模型转成功,但测试demo时报错

111111

注册会员

积分
138
楼主
发表于 2020-3-11 11:11:05    查看: 7648|回复: 1 | [复制链接]    打印 | 只看该作者
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)


有大神可以帮我看下吗

回复

使用道具 举报

jefferyzhang

版主

积分
13580
沙发
发表于 2020-3-11 11:59:24 | 只看该作者
请核对下版本信息。
版本必须一致才行。。具体看下发布贴和文档
回复

使用道具 举报

您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

产品中心 购买渠道 开源社区 Wiki教程 资料下载 关于Toybrick


快速回复 返回顶部 返回列表