Toybrick

虚拟机上可以跑通,上板子就挂了。。。。求指导!

zhouzhouzlove

高级会员

积分
548
楼主
发表于 2019-3-11 20:54:59    查看: 6086|回复: 5 | [复制链接]    打印 | 只看该作者
本帖最后由 zhouzhouzlove 于 2019-3-11 20:54 编辑

按照toolkit工具手册的流程图,比对并照搬example文件夹中的Mobilenet_V2代码,把*.prototxt和*.caffemodel换成了自己的caffe文件,然后上虚拟机上跑了一遍,没问题,能够跑通,
但是把文件复制到3399pro板子上的时候,就挂了,输出信息如下:
[toybrick@localhost 111]$ sudo python3 ./face_det_new.py
/usr/lib64/python3.6/site-packages/h5py/__init__.py:36: FutureWarning: Conversion of the second argument of issubdtype from `float` to `np.floating` is deprecated. In future, it will be treated as `np.float64 == np.dtype(float).type`.
  from ._conv import register_converters as _register_converters
--> config model
done
--> Loading model
done
--> Building model
done
--> Export RKNN model
done
--> Init runtime environment
done
--> Running model
E Catch exception when setting inputs.
T Traceback (most recent call last):
T   File "rknn/api/rknn_base.py", line 614, in rknn.api.rknn_base.RKNNBase.inference
T   File "rknn/api/rknn_base.py", line 532, in rknn.api.rknn_base.RKNNBase.set_inputs
T   File "rknn/api/rknn_runtime.py", line 318, in rknn.api.rknn_runtime.RKNNRuntime.set_inputs
T Exception: Set inputs failed. error code: RKNN_ERR_PARAM_INVALID
Traceback (most recent call last):
  File "./face_det_new.py", line 72, in <module>
    show_outputs(outputs)
  File "./face_det_new.py", line 6, in show_outputs
    output = outputs[0][0]
TypeError: 'NoneType' object is not subscriptable
[toybrick@localhost 111]$




ubuntu虚拟机上结果如下:

本帖子中包含更多资源

您需要 登录 才可以下载或查看,没有帐号?立即注册

x
回复

使用道具 举报

zhangzj

超级版主

积分
1109
沙发
发表于 2019-3-12 09:05:59 | 只看该作者
代码方便贴出来看下?
回复

使用道具 举报

zhouzhouzlove

高级会员

积分
548
板凳
 楼主| 发表于 2019-3-12 09:16:06 | 只看该作者
这是照搬的test.py的内容,只替换了一下文件名,然后在虚拟机上可以运行。


  1. import numpy as np
  2. import cv2
  3. from rknn.api import RKNN

  4. def show_outputs(outputs):
  5.     output = outputs[0][0]
  6.     output_sorted = sorted(output, reverse=True)
  7.     top5_str = 'face_det_new\n-----TOP 5-----\n'
  8.     for i in range(5):
  9.         value = output_sorted[i]
  10.         index = np.where(output == value)
  11.         for j in range(len(index)):
  12.             if (i + j) >= 5:
  13.                 break
  14.             if value > 0:
  15.                 topi = '{}: {}\n'.format(index[j], value)
  16.             else:
  17.                 topi = '-1: 0.0\n'
  18.             top5_str += topi
  19.     print(top5_str)

  20. if __name__ == '__main__':

  21.     # Create RKNN object
  22.     rknn = RKNN()
  23.    
  24.     # pre-process config
  25.     print('--> config model')
  26.     rknn.config(channel_mean_value='103.94 116.78 123.68 58.82', reorder_channel='2 1 0')
  27.     print('done')

  28.     # Load tensorflow model
  29.     print('--> Loading model')
  30.     ret = rknn.load_caffe(model='./face_det_new.prototxt',
  31.                           proto='caffe',
  32.                           blobs='./face_det_new.caffemodel')
  33.     if ret != 0:
  34.         print('Load face_det_new failed! Ret = {}'.format(ret))
  35.         exit(ret)
  36.     print('done')

  37.     # Build model
  38.     print('--> Building model')
  39.     ret = rknn.build(do_quantization=True, dataset='./dataset.txt')
  40.     if ret != 0:
  41.         print('Build face_det_new failed!')
  42.         exit(ret)
  43.     print('done')

  44.     # Export rknn model
  45.     print('--> Export RKNN model')
  46.     ret = rknn.export_rknn('./face_det_new.rknn')
  47.     if ret != 0:
  48.         print('Export face_det_new.rknn failed!')
  49.         exit(ret)
  50.     print('done')

  51.     # Set inputs
  52.     img = cv2.imread('./cat_224x224.jpg')
  53.     img = cv2.cvtColor(img, cv2.COLOR_BGR2RGB)

  54.     print('--> Init runtime environment')
  55.     ret = rknn.init_runtime()
  56.     if ret != 0:
  57.         print('Init runtime environment failed')
  58.         exit(ret)
  59.     print('done')

  60.     # Inference
  61.     print('--> Running model')
  62.     outputs = rknn.inference(inputs=[img])
  63.     show_outputs(outputs)
  64.     print('done')

  65.     # perf
  66.     print('--> Begin evaluate model performance')
  67.     perf_results = rknn.eval_perf(inputs=[img])
  68.     print('done')

  69.     rknn.release()
复制代码
回复

使用道具 举报

zhouzhouzlove

高级会员

积分
548
地板
 楼主| 发表于 2019-3-12 11:51:03 | 只看该作者
顶一下。。。。。
回复

使用道具 举报

elooon

注册会员

积分
139
5#
发表于 2019-3-12 15:43:58 | 只看该作者
interesting.
The exception below seems that somthing is wrong in inputs data
T Exception: Set inputs failed. error code: RKNN_ERR_PARAM_INVALID

So *.prototxt and *.caffemodel files are also mobilenet_v2 model? Can they be shared out?
回复

使用道具 举报

zhouzhouzlove

高级会员

积分
548
6#
 楼主| 发表于 2019-3-12 17:59:04 | 只看该作者
elooon 发表于 2019-3-12 15:43
interesting.
The exception below seems that somthing is wrong in inputs data
T Exception: Set inputs ...

灵异事件~~~虚拟机和板子上(错误)的推理结果不一致!
http://t.rock-chips.com/forum.ph ... 235&fromuid=208
(出处: Toybrick)
This is the new problem,the results are not identical.
回复

使用道具 举报

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

本版积分规则

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


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