Toybrick

使用yolov3后,最后一层卷积输出数值非常怪异

hzdxs

注册会员

积分
153
发表于 2020-11-20 16:13:01    查看: 65|回复: 1 | [复制链接]    打印 | 显示全部楼层
import numpy as np
import cv2
from rknn.api import RKNN
import math
def sigd(x):
    return 1/(1 +math.exp(-x))
np.set_printoptions(precision=3)
img = cv2.imread('nj.jpg')
#img = cv2.cvtColor(img, cv2.COLOR_BGR2RGB)
img = cv2.resize(img, (512,512), interpolation=cv2.INTER_CUBIC)
rknn = RKNN()
##rknn.config(channel_mean_value='0 0 0 0.0039062', reorder_channel='0 1 2')
ret = rknn.load_rknn(path='bike_x.rknn')
if ret!=0:
   print('load rknn fail')
print('--> Init runtime ')
ret = rknn.init_runtime()
if ret != 0:
   print('Init runtime fail')
   exit()
import time
start_time=time.time()
print('--> Running model ')
outputs = rknn.inference(inputs=[img])
end_time=time.time()
end_time=end_time-start_time
if end_time>60:
   end_time=end_time/60.0
   print('outputs:',len(outputs),'time:%0.2f'%end_time,'m')
else:
   print('outputs:',len(outputs),'time:',end_time,'s')
print('11:',type(outputs[0]))
raw_res=outputs[0]
print('22:',raw_res.shape)
last_feat_w=16#最后一层的尺寸512/32
last_conv_filter=90
#45,45,65,65, 90,90, 120,120, 160,160, 200,200, 250,250,300,300, 360,360
#55, "65,90, "97, "105, "123, "117, "106, "125, "138, "143, "156, "151, "128, "166, "168, "190, "203
raw_res=raw_res[0]
print(raw_res.shape,type(raw_res[0]))


打印输出如下:

--> Init runtime
--> Running model
outputs: 1 time: 38.37649703025818 s
11: <class 'numpy.ndarray'>
22: (1, 23040)
(23040,) <class 'numpy.float32'>
2313.1567,0.0,-2313.1567,-4626.3135,2313.1567,0.0,0.0,0.0,-4626.3135,0.0,2313.1567,2313.1567,2313.1567,0.0,0.0,



这个数据明显不对,我特地从caffe中提取了数据如下:
dataf:0.4869,0.6122,0.9449,0.1455,0.4536,0.9512,-0.2302,-0.4188,

请问这是什么原因?

回复

使用道具 举报

jefferyzhang

超级版主

积分
6550
发表于 2020-11-22 12:10:19 | 显示全部楼层
参考下我们yolov3的教程
回复

使用道具 举报

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

本版积分规则

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


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