yolov3 05节
https://zhuanlan.zhihu.com/p/37007960
开门见山,没跑起来,麻了,最终预测的时候全给预测成了person,简单看了下,自己甚至还忘了output的构成,所以到底哪儿除了问题也是没搞清楚。交给明天了
简单推断可能出错的地方:①前向传播过程中,在非极大抑制IoU这个过程中出错;②output下标对应出错;③没想到的错误
pytorch相关
- pytorch输入图像:批*C*高*宽 RGB
- openCV
cv2.imread():得到的数据矩阵为:高*宽*C BGR numpy数据格式
cv2.resize(Input尺寸,output尺寸) ,其中output设定尺寸是以 (宽,高)为序,但是resized_image结果仍然保持为(高*宽)形式;反人类设计
cv2.rectangle(img, pt1, pt2, color[, thickness[, lineType[, shift]]]) 在图上绘制矩形 https://www.freesion.com/article/1539967937/
- torch.clamp 对输入数据按照min max的设置(一定范围内)进行剪裁 https://pytorch.org/docs/1.10.0/generated/torch.clamp.html?highlight=clamp#torch.clam
1 >>a = torch.randn(4) 2 >>a 3 tensor([-1.7120, 0.1734, -0.0478, -0.0922]) 4 >>torch.clamp(a, min=-0.5, max=0.5) 5 tensor([-0.5000, 0.1734, -0.0478, -0.0922]) 6 7 >>min = torch.linspace(-1, 1, steps=4) 8 >>torch.clamp(a, min=min) 9 tensor([-1.0000, 0.1734, 0.3333, 1.0000])
- with torch.no_grad 一般在使用模型预测过程中,网络不产生计算图,进而提高效率,感觉比单独设置require_grad = False好用
高效运算技巧
- 使用map函数,map(function, variable_1, variable_2...),实际是一种映射关系,将变量variable映射到function中,可通过一个迭代器避免显示循环
bug排查
为了缩减一幅图像的尺寸,进行了重采样和填充操作,对其结果进行cv2绘制时,出现如下错误
error: (-215:Assertion failed) src_depth != CV_16F && src_depth != CV_32S in function 'convertToShow
其原因是填充时numpy的数据为int32,但是cv2需要uint8,dtype进行转换一下即可 https://blog.csdn.net/qq_36534731/article/details/97036038