首页IT科技数据集长什么样(tt100k数据集跑yolov5s模型时,所遇到的问题记录)

数据集长什么样(tt100k数据集跑yolov5s模型时,所遇到的问题记录)

时间2025-06-15 05:51:24分类IT科技浏览4321
导读:错误1: FileNotFoundError: [Errno 2] No such file or directory: yolov5s.pt...

错误1:  FileNotFoundError: [Errno 2] No such file or directory: yolov5s.pt

解决:离谱             ,重新运行就没了这个错误                   ,开始报下一个错误             。意思是找不到权重文件      ,但明明weights目录下有这个pt文件                   。

错误2:   AttributeError: Cant get attribute SPPF on <module models.common from

解决:网上查说是缺少一个代码段             ,在models/common.py里

 代码贴在下面                    ,加到相应位置就可以      。

class SPPF(nn.Module): def __init__(self, c1, c2, k=5): super().__init__() c_ = c1 // 2 self.cv1 = Conv(c1, c_, 1, 1) self.cv2 = Conv(c_ * 4, c2, 1, 1) self.m = nn.MaxPool2d(kernel_size=k, stride=1, padding=k // 2) def forward(self, x): x = self.cv1(x) with warnings.catch_warnings(): warnings.simplefilter(ignore) y1 = self.m(x) y2 = self.m(y1) return self.cv2(torch.cat([x, y1, y2, self.m(y2)], 1))

网上有说这个方法解决不了      ,其他人的方法如下图

错误3:    RuntimeError: Given groups=1, weight of size [512, 1024, 1, 1], expected input[1, 512, 8, 8] to have

解决:默认的模型配置文件yaml路径没有指定             。 添加路径即可                    。

错误4:   Exception: train: Error loading data from ../coco128/images/train2017/: train: ..\coco128\images\train2017 does not exist

解决:是coco128数据集的位置有问题      ,我的coco数据集放在了项目目录下                    ,但是实际应该放在项目目录的平行目录中

同时 coco128.yaml文件中的路径也需要设置正确             ,一个“.             ”表示上级目录      ,调整之前是上上级目录

 错误5:TimeoutError: [WinError 10060] 由于连接方在一段时间后没有正确答复或连接的主

解决:离谱                   ,好像是网络问题      。

错误6: RuntimeError: result type Float can‘t be cast to the desired output type long int

解决:通过百度搜索             ,看到别人解决方案,

1.打开你的【utils】文件下的【loss.py】

2.按【Ctrl】+【F】打开搜索功能                   ,输入【for i in range(self.nl)】找到下面的一行内容:

(上面的代码在【loss.py】的后半部分)

将下面的代码替换掉上图中的红圈部分:

anchors, shape = self.anchors[i], p[i].shape

 3.按【Ctrl】+【F】打开搜索功能                   ,输入【indices.append】找到下面的一行内容: 

上面的代码在【loss.py】的最后部分,具体位置在上一处搜索位置的下面10行左右)

 将下面的代码替换掉上图中的红圈部分:

indices.append((b, a, gj.clamp_(0, shape[2] - 1), gi.clamp_(0, shape[3] - 1))) # image, anchor, grid

 之后就可以了      。

看别人的博客说如果还不行

调试detect文件测试时遇到的问题:

1.问题如下以及网上搜到的解决方法:

解决方案来自:一步真实解决AttributeError: ‘Upsample‘ object has no attribute ‘recompute_scale_factor‘_蓝胖胖▸的博客-CSDN博客

2.另一个问题:

RuntimeError: The size of tensor a (80) must match the size of tensor b (56) at non-singleton

解决方法是             ,yolov5s.pt默认下载的6.1                   ,而模型是5.0      ,所以去下载5.0的权重文件就行                    。

解决方法来自:【解决问题】RuntimeError: The size of tensor a (80) must match the size of tensor b (56) at non-singleton_王大队长的博客-CSDN博客

创心域SEO版权声明:以上内容作者已申请原创保护,未经允许不得转载,侵权必究!授权事宜、对本内容有异议或投诉,敬请联系网站管理员,我们将尽快回复您,谢谢合作!

展开全文READ MORE
肇庆网站建设技巧(鄂州网站建设技巧) 聊城官网(聊城欢迎您)