Toybrick

python与C++经过同样的rknn模型输出不一致

topThree

新手上路

积分
7
楼主
发表于 2020-5-26 19:14:34    查看: 10462|回复: 3 | [复制链接]    打印 | 只看该作者
同一张图像经过letterbox以及cvtColor函数转换以后,在python以及C++环境下得到相同的输出结果,但是经过rknn相关推理后得到的输出有个别数字存在0.1-0.3之间的差值。请问这是环境因素导致的吗?
python的输出
-0.370573,0.000000,0.123524,-0.123524,-8.893756,4.446878,-0.123524,0.247049,-0.247049,-0.247049,-9.511377,3.458683,0.247049,0.123524,-0.123524,0.000000,-10.993670,2.346963
0.000000,-0.247049,0.247049,-0.247049,-9.634902,2.223439,-0.123524,0.247049,0.123524,-0.123524,-9.881950,1.729341,0.123524,0.123524,0.000000,0.000000,-9.881950,1.729341
0.000000,-0.123524,0.123524,-0.123524,-10.005475,1.482293,0.123524,0.370573,0.000000,-0.123524,-10.252523,0.864671,0.000000,0.247049,0.123524,0.000000,-10.376048,0.864671
-0.123524,0.000000,0.000000,0.000000,-9.634902,0.864671,-0.123524,0.247049,0.000000,0.000000,-9.881950,0.247049,-0.123524,0.123524,0.000000,0.000000,-10.005475,0.123524
0.000000,0.000000,0.000000,0.000000,-9.634902,0.617622,-0.123524,0.247049,0.000000,0.000000,-9.881950,0.000000,-0.123524,0.123524,0.000000,0.000000,-10.005475,-0.123524
-0.123524,0.000000,0.000000,0.000000,-9.634902,0.617622,-0.123524,0.247049,0.000000,0.000000,-9.881950,-0.123524,0.000000,0.123524,0.123524,0.000000,-10.005475,-0.247049



C++的输出
-0.370573  7.45058e-08  0.123524  -0.123524  -9.1408  4.69393  -0.123524  0.370573  -0.247049  -0.247049  -9.75843  3.82926  0.247049  0.123524  -0.123524  7.45058e-08  -11.3642  2.59401  
7.45058e-08  -0.123524  0.247049  -0.247049  -10.129  2.59401  -0.123524  0.247049  0.247049  -0.247049  -10.2525  2.09991  0.123524  0.247049  0.123524  7.45058e-08  -10.376  2.09991  
7.45058e-08  -0.123524  0.123524  -0.123524  -10.376  1.85287  0.123524  0.494098  7.45058e-08  -0.123524  -10.4996  1.23524  7.45058e-08  0.247049  0.123524  7.45058e-08  -10.6231  1.23524  
7.45058e-08  7.45058e-08  7.45058e-08  -0.123524  -9.75843  0.988195  -0.123524  0.247049  7.45058e-08  7.45058e-08  -9.88195  0.370573  -0.123524  0.123524  0.123524  7.45058e-08  -9.88195  0.247049  
7.45058e-08  7.45058e-08  7.45058e-08  -0.123524  -9.6349  0.864671  -0.123524  0.247049  7.45058e-08  7.45058e-08  -9.75843  0.247049  -0.123524  0.123524  0.123524  7.45058e-08  -9.88195  0.123524  
-0.123524  7.45058e-08  7.45058e-08  7.45058e-08  -9.51138  0.741146  -0.123524  0.123524  7.45058e-08  7.45058e-08  -9.75843  7.45058e-08  7.45058e-08  0.123524  7.45058e-08  7.45058e-08  -10.0055  -0.247049  

回复

使用道具 举报

jefferyzhang

版主

积分
13580
沙发
发表于 2020-5-30 18:30:53 | 只看该作者
rknn不量化时候默认用的是FP16,
tensorflow默认是FP32,这里会有精度差异。
回复

使用道具 举报

xindongzhang

注册会员

积分
82
板凳
发表于 2020-7-7 02:01:06 | 只看该作者
楼主解决问题了吗?这个我也碰到了。。。
回复

使用道具 举报

kitedream

中级会员

积分
284
地板
发表于 2020-7-17 18:11:33 | 只看该作者
jefferyzhang 发表于 2020-5-30 18:30
rknn不量化时候默认用的是FP16,
tensorflow默认是FP32,这里会有精度差异。

我也遇到了楼主同样的问题。Python API 与c++ API输出结果不一致。
ssd_mobilenet_v1_coco
完全一样的.rknn文件,Python接口是通过microusb连接开发板
output[0]
python API:
[[[[ 0.          0.42366382 -2.9656467  -5.4471064 ]]
  [[ 1.0288979   1.3315148  -2.7235532  -0.54471064]]
  [[ 1.8157021   0.605234   -0.7262808  -2.4814594 ]]
c++ api
RGB输入下
-5.568153,  0.000000,  0.475214,  0.000000
-0.544711,  0.000000,  0.475214,  0.000000
-2.420937,  0.000000,  0.475214,  0.000000
BGR输入下
-4.781349,  0.000000,  0.644591,  0.000000
-0.363141,  0.000000,  0.644591,  0.000000
-2.118320,  0.000000,  0.644591,  0.000000




回复

使用道具 举报

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

本版积分规则

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


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