【无标题】

记录YOLO v5 错误

train.py 报错一:a view of a leaf Variable that requires grad is being used in an in-place operation.

解决办法:找到在File "C:\Users\it possible\Documents\yolov5Project\yolov5-master\models\yolo.py"的line 145
将代码修改为:
def _initialize_biases(self, cf=None): # initialize biases into Detect(), cf is class frequency
# cf = torch.bincount(torch.tensor(np.concatenate(dataset.labels, 0)[:, 0]).long(), minlength=nc) + 1.
m = self.model[-1] # Detect() module
for mi, s in zip(m.m, m.stride): # from
b = mi.bias.view(m.na, -1) # conv.bias(255) to (3,85)
with torch.no_grad():
b[:, 4] += math.log(8 / (640 / s) ** 2) # obj (8 objects per 640 image)
b[:, 5:] += math.log(0.6 / (m.nc - 0.99)) if cf is None else torch.log(cf / cf.sum()) # cls
mi.bias = torch.nn.Parameter(b.view(-1), requires_grad=True)

train.py报错二:AttributeError: module numpy has no attribute int .

解决办法:重新安装numpy
pip uninstall numpy
pip install numpy==1.22

dectect.py报错一:Backend QtAgg is interactive backend. Turning interactive mode on.

将matplotlib的backend设置为非交互式。
D:\Anaconda3\envs[your environment]\Lib\site-packages\matplotlib\mpl-data\matplotlibrc

You can also deploy your own backend outside of matplotlib by

referring to the module name (which must be in the PYTHONPATH) as

‘module://my_backend’.

#backend : Agg
去掉注释:backend : Agg

dectect.py报错二:tourch.nn.modules.module.ModuleAttributeError:‘Hardswish’ object has no attribute ‘inplace’

打开torch/nn/modules路径下的activation.py文件(具体路径可以看你的报错信息),定位到438行,去掉‘ self.inplace’
修改前

def forward(self, input: Tensor) -> Tensor:
    return F.hardswish(input, self.inplace)

修改后
def forward(self, input: Tensor) -> Tensor:
return F.hardswish(input)

参考:

  1. https://blog.csdn.net/Xunuo1995/article/details/115454076
  2. https://blog.csdn.net/weixin_46669612/article/details/129624331
  3. https://codeleading.com/article/89025983578/
  4. https://blog.csdn.net/weixin_44942126/article/details/120184159
  • 0
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值