标题: mobilefacenet 模型转换问题 RKNN_ERR_MODEL_INVALID [打印本页] 作者: 281963347 时间: 2019-12-3 18:18 标题: mobilefacenet 模型转换问题 RKNN_ERR_MODEL_INVALID 开源项目:https://github.com/sirius-ai/MobileFaceNet_TF
模型:MobileFaceNet_9925_9680.pb 我的转换代码
报错日志:
--> Init runtime environment
E Catch exception when init runtime!
E Traceback (most recent call last):
E File "rknn/api/rknn_base.py", line 788, in rknn.api.rknn_base.RKNNBase.init_runtime
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.2.0 (1190a71 build: 2019-09-25 12:39:14)
E RKNNAPI: DRV: 0.9.8 (943f8e8 build: 2019-07-03 17:51:17)
E RKNNAPI: ==============================================
E File "rknn/api/rknn_runtime.py", line 303, in rknn.api.rknn_runtime.RKNNRuntime.build_graph
E Exception: RKNN init failed. error code: RKNN_ERR_MODEL_INVALID
E Current device id is: None
E Devices connected:
Init runtime environment failed
E ['TS018082190800251']
############################################################################
# 此处使用 inputs=['input'] 单输入是没问题的,也不会存在前面帖子里面说的要关闭 train_node 问题
# 因为 phase_train_placeholder = tf.placeholder_with_default(tf.constant(False, dtype=tf.bool), shape=None, name='phase_train')
# 这里是有一个默认值的 False
# 我尝试过 在对pb模型进行测试时,feed_dict 加不加 phase_train_placeholder 选项其推理结果是一样的
# 如: feed_dict = {images_placeholder: normed, phase_train_placeholder: False}
# feed_dict2 = {images_placeholder: normed}
# embs = sess.run(embeddings, feed_dict=feed_dict)
# embs2 = sess.run(embeddings, feed_dict=feed_dict2)
# print(embs-embs2)
# 结果为 全 0.
# 但是运行报错:
# E File "rknn/api/rknn_runtime.py", line 303, in rknn.api.rknn_runtime.RKNNRuntime.build_graph
# E Exception: RKNN init failed. error code: RKNN_ERR_MODEL_INVALID
# E Current device id is: None
# E Devices connected:
# Init runtime environment failed
# E ['TS018082190800251']
############################################################################
if ret != 0:
print('Load mobilenet_v1 failed!')
exit(ret)
print('done')
# Build model
print('--> Building model')
ret = rknn.build(do_quantization=True, dataset='./dataset.txt')
if ret != 0:
print('Build mobilenet_v1 failed!')
exit(ret)
print('done')
# Export rknn model
print('--> Export RKNN model')
ret = rknn.export_rknn('./mobilefacenet.rknn')
if ret != 0:
print('Export mobilefacenet.rknn failed!')
exit(ret)
print('done')
# Set inputs
img = cv2.imread('./sunzz112.jpg')
img = cv2.cvtColor(img, cv2.COLOR_BGR2RGB)
# init runtime environment
print('--> Init runtime environment')
ret = rknn.init_runtime(target='rk1808')
if ret != 0:
print('Init runtime environment failed')
exit(ret)
print('done')