问题描述

在训练 yolov5做简单的识别的时候出现,错误:RuntimeError: result type Float can‘t be cast to the desired output type long int。下面对解决方案进行记录。

问题分析

所有的操作都是按照官网的教程来实施的,但是还是出现了错误,官网的yolov5-master版本可以正常运行,但是yolov5-5.0/yolov5-6.1等版本就是不可以运行, 想着是不是由于master版本和其他分支等版本下的utils的loss.py文件是不一样的。我估计是版本更新的时候出现了问题。

问题解决

修改utils/loss.py文件中的两处内容:
第一处:

  1. loss.py中,找到

            for i in range(self.nl):anchors = self.anchors[i]
    

    把上面的代码改成

     for i in range(self.nl):anchors, shape = self.anchors[i], p[i].shape
    
  2. 在改了上面的内容之后,在找到控制点的
    indices.append((b, a, gj.clamp_(0, gain[3] - 1), gi.clamp_(0, gain[2] - 1)))  # image, anchor, grid
    

改成:

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

之后就可以开始训练了:

总结

其实我也玩不明白,也是网上东抄抄,西看看,就纯记录。

参考


https://blog.csdn.net/qq_42835363/article/details/127753543
pudn.com/news/6321667af0cde61357537e80.html

【Error Logs】YoloV5出现RuntimeError: result type Float can‘t be cast to the desired output相关推荐

  1. 解决Yolov5的RuntimeError: result type Float can‘t be cast to the desired output type long int 问题

    在yolov5中,直接下载github上的代码可能出现无法运行的情况,会报错 RuntimeError: result type Float can't be cast to the desired ...

  2. YOLOV5报错:RuntimeError: result type Float can‘t be cast to the desired output type long int

    YOLOV5训练时报错: Traceback (most recent call last):   File "train.py", line 626, in <module ...

  3. 训练yolo时报错RuntimeError: result type Float can‘t be cast to the desired output type __int64个人解决方案

    运行YOLOv5 6.1和yolor的时候,训练都没能正常运行,均出现了如下错误: AutoAnchor: 5.00 anchors/target, 1.000 Best Possible Recal ...

  4. RuntimeError: result type Float can‘t be cast to the desired output type __int64

    yolo问题:RuntimeError: result type Float can't be cast to the desired output type __int64 解决办法: loss.p ...

  5. 解决错误:RuntimeError: result type Float can‘t be cast to the desired output type __int64

    在运行yolov5 train.py时出现了这个错误 解决方式: 将loss.py中gain = torch.ones(7, device=targets.device)改为gain = torch. ...

  6. YOLOv5训练报错:result type Float can‘t be cast to the desired output type __int64

    记录一个报错: 因为把Pytorch版本从1.8.0更新到1.13.1,YOLOv5-6.1版本的训练代码报错: RuntimeError: result type Float can't be ca ...

  7. 成功解决Type Error: can‘t multiply sequence by non-int of type ‘float‘

    成功解决Type Error: can't multiply sequence by non-int of type 'float' 目录 解决问题 解决思路 解决方法 解决问题 File " ...

  8. 使用PyTorch前向运算时出现“RuntimeError: Expected object of scalar type Long but got scalar type Float for ……”

    1 问题描述 今天在使用PyTorch搭建模型时,出现了一个问题: RuntimeError: Expected object of scalar type Long but got scalar t ...

  9. Runtime error: expected scalar type Float but found Double

    错误:Runtime error: expected scalar type Float but found Double w_true=torch.tensor([2,-3.4]).T b_true ...

最新文章

  1. c# 垃圾回收是引用类型而言的
  2. Windows下启动停止SQL Server 2005服务
  3. 02 基本序列以及序列表示
  4. 最好的android one手机,最高配置的Android One手机登场 LG推出G7 One与G7 F
  5. c语言春考题目,PAT 2017年春考乙级真题(1066. 图像过滤)(C语言)
  6. 信息学奥赛一本通 1188:菲波那契数列(2) | OpenJudge NOI 2.3 1760:菲波那契数列(2)
  7. Java I/O体系之OutputStream和InputStream详细讲解
  8. 提取字符串中字母数字方法
  9. windows server 2008配置之AD域服务器 1
  10. 浅谈tcpwrapper的基本使用方法
  11. 【Spark重点难点08】Spark3.0中的AQE和DPP小总结
  12. mysql怎么实现表的复制粘贴_如何对MySQL数据表进行复制、表结构复制
  13. 英语音标、发音技巧、浊化规则
  14. (半翻译)篡改mac应用后,如何resign签名,重新获得mac系统的信任?
  15. sklearn学习之Spectral Clustering
  16. Java虚拟机部分知识点
  17. Revit导出PDF格式图纸流程及“批量导出图纸”
  18. (二) 数据挖掘之分类
  19. 正则表达式(Regular Expression)——入门笔记(常用正则表达式符号、正则表达式在线调试工具)
  20. RK3399平台开发系列讲解(内核驱动外设篇)6.17、VOP驱动解析

热门文章

  1. java jmap_java性能监控工具:jmap命令详解
  2. web调用windows桌面程序
  3. 《侠盗车手3》全攻略(完美版)
  4. 节能减排 让绿色节能梦想照进现实
  5. 量子计算机具有天然的处理能力,量子密码
  6. foo bar是什么
  7. 33.递归数列XDOJ
  8. 完美解决ghost win10系统缺少hh.exe打不开chm
  9. lammps教程:以计算Fe晶格常数为例介绍jump命令使用
  10. 云服务器好还是虚拟主机好