当前位置: 首页 > news >正文

邯郸做网站推广找谁怎么建设小说网站

邯郸做网站推广找谁,怎么建设小说网站,网站开发公司招聘技术人员,软件外包公司介绍前言 环境介绍: 1.编译环境 Ubuntu 18.04.5 LTS 2.RKNN版本 py3.8-rknn2-1.4.0 3.单板 迅为itop-3568开发板 一、现象 采用yolov5训练并将pt转换为onnx,再将onnx采用py3.8-rknn2-1.4.0推理转换为rknn出现置信度大于1,并且图像乱框问题…

前言

环境介绍:

1.编译环境

Ubuntu 18.04.5 LTS

2.RKNN版本

py3.8-rknn2-1.4.0

3.单板

迅为itop-3568开发板


一、现象

采用yolov5训练并将pt转换为onnx,再将onnx采用py3.8-rknn2-1.4.0推理转换为rknn出现置信度大于1,并且图像乱框问题。
类似下面这样
在这里插入图片描述

二、解决

经过网上一顿查找发现是在将pt文件转化为onnx时对models/yolo.py的修改有问题。网上大部分的修改都是下面这种
models/yolo.py

def forward(self, x):z = []  # inference outputfor i in range(self.nl):x[i] = self.m[i](x[i])  # convreturn x# def forward(self, x):#     z = []  # inference output#     for i in range(self.nl):#         x[i] = self.m[i](x[i])  # conv        #         bs, _, ny, nx = x[i].shape  # x(bs,255,20,20) to x(bs,3,20,20,85)#         x[i] = x[i].view(bs, self.na, self.no, ny, nx).permute(0, 1, 3, 4, 2).contiguous()#         if not self.training:  # inference#             if self.dynamic or self.grid[i].shape[2:4] != x[i].shape[2:4]:#                 self.grid[i], self.anchor_grid[i] = self._make_grid(nx, ny, i)#             if isinstance(self, Segment):  # (boxes + masks)#                 xy, wh, conf, mask = x[i].split((2, 2, self.nc + 1, self.no - self.nc - 5), 4)#                 xy = (xy.sigmoid() * 2 + self.grid[i]) * self.stride[i]  # xy#                 wh = (wh.sigmoid() * 2) ** 2 * self.anchor_grid[i]  # wh#                 y = torch.cat((xy, wh, conf.sigmoid(), mask), 4)#             else:  # Detect (boxes only)#                 xy, wh, conf = x[i].sigmoid().split((2, 2, self.nc + 1), 4)#                 xy = (xy * 2 + self.grid[i]) * self.stride[i]  # xy#                 wh = (wh * 2) ** 2 * self.anchor_grid[i]  # wh#                 y = torch.cat((xy, wh, conf), 4)#             z.append(y.view(bs, self.na * nx * ny, self.no))#     return x if self.training else (torch.cat(z, 1),) if self.export else (torch.cat(z, 1), x)

这是导致问题的根源,至于为什么现在我还没办法回答。正确的应该按如下方式修改

models/yolo.py

def forward(self, x):z = []  # inference outputfor i in range(self.nl):if os.getenv('RKNN_model_hack', '0') != '0':x[i] = torch.sigmoid(self.m[i](x[i]))  # convreturn x
# def forward(self, x):
#     z = []  # inference output
#     for i in range(self.nl):
#         x[i] = self.m[i](x[i])  # conv
#         bs, _, ny, nx = x[i].shape  # x(bs,255,20,20) to x(bs,3,20,20,85)
#         x[i] = x[i].view(bs, self.na, self.no, ny, nx).permute(0, 1, 3, 4, 2).contiguous()
#
#         if not self.training:  # inference
#             if self.grid[i].shape[2:4] != x[i].shape[2:4] or self.onnx_dynamic:
#                 self.grid[i] = self._make_grid(nx, ny).to(x[i].device)
#
#             y = x[i].sigmoid()
#             if self.inplace:
#                 y[..., 0:2] = (y[..., 0:2] * 2. - 0.5 + self.grid[i]) * self.stride[i]  # xy
#                 y[..., 2:4] = (y[..., 2:4] * 2) ** 2 * self.anchor_grid[i]  # wh
#             else:  # for YOLOv5 on AWS Inferentia https://github.com/ultralytics/yolov5/pull/2953
#                 xy = (y[..., 0:2] * 2. - 0.5 + self.grid[i]) * self.stride[i]  # xy
#                 wh = (y[..., 2:4] * 2) ** 2 * self.anchor_grid[i].view(1, self.na, 1, 1, 2)  # wh
#                 y = torch.cat((xy, wh, y[..., 4:]), -1)
#             z.append(y.view(bs, -1, self.no))
#
#     return x if self.training else (torch.cat(z, 1), x)

export.py文件的run函数

# shape = tuple((y[0] if isinstance(y, tuple) else y).shape)  # model output shape
shape = tuple(y[0].shape)  # model output shape

export.py文件的开头加上

#onn转换添加内容
import os
os.environ['RKNN_model_hack'] = 'npu_2'
#

修改之后按照如下命令导出onnx
其中./runs/train/exp3/weights/best.pt换成自己训练的pt文件

python export.py --weights ./runs/train/exp3/weights/best.pt --img 640 --batch 1 --include onnx --opset 12

参考这位大佬的文件

http://www.yayakq.cn/news/50657/

相关文章:

  • 做问卷调查赚钱的网站学平面设计好找工作吗
  • 查看网站是否备案什么网站不用备案
  • 电商企业网站建设的一般要素有哪些wordpress网站数据备份
  • 崇信县门户网站官网wordpress动态链接301
  • 建百度网站私域运营
  • 无锡高端网站设计开发wordpress删除自豪的
  • 图片类网站建设微信小程序源码网
  • 个人做美食视频网站网站设计公司排名前十
  • 麻章手机网站建设公司设备网站建设
  • 做网站的公司苏州wordpress如何打赏
  • 电脑维修网站模板下载免费图片制作生成器
  • 河南省建设厅注册中心网站有哪些可以在线做app的网站
  • 网站301定向dw可以做视频网站么
  • 资源型网站建设 需要多大硬盘百度权重网站排名
  • 深圳手机机械网站建设wordpress 幻灯片 插件
  • 做的网站需要什么技术软件库合集软件资料2024
  • 回收网站怎么做如何成为电商
  • wordpress 公网访问滕州网站优化
  • 网站头部代码品牌建设的阶段和步骤是什么
  • 代码做网站常用单词电商网平台
  • 创意聊城做网站的公司多媒体网站开发
  • 成都哪里可以做网站做淘客网站注意事项
  • 平面设计主要学哪些软件灰色词seo
  • 重庆点优建设网站公司网站开发能进无形资产吗
  • 无锡网络公司无锡网站制作推广公司好做吗
  • 2007年怎么做网站保定seo网络推广
  • 响应式网站模板免费下载赤峰网站建设建站公司
  • 施工企业官方正版清理优化工具
  • 三合一网站有必要吗找建站公司做网站注意事项
  • 12380网站建设centos 6.5 wordpress