在yolov5中,直接下载github上的代码可能出现无法运行的情况,会报错

RuntimeError: result type Float can't be cast to the desired output type long int

运行结果报错样例

那么如何解决这个问题呢,下面来告诉你

首先,在yolo的文件夹下找到 yolov5-6.1/utils/loss.py 文件(以6.1版本为例),然后搜索(搜素快捷键CTRL+F) anchors = self.anchors[i] (大约在184行上下),并将其改为  anchors, shape = self.anchors[i], p[i].shape

修改前:

anchors = self.anchors[i] 

修改后:

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

修改后的代码

其次,仍然在该文件搜索【indices.append】(大约在217行上下)

修改前:

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

修改后:

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

修改后

ok, 完美解决,这样就可以跑通啦

快去试试吧

解决Yolov5的RuntimeError: result type Float can‘t be cast to the desired output type long int 问题相关推荐

  1. 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 ...

  2. 训练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 ...

  3. 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 ...

  4. 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 ...

  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. 【Error Logs】YoloV5出现RuntimeError: result type Float can‘t be cast to the desired output

    问题描述 在训练 yolov5做简单的识别的时候出现,错误:RuntimeError: result type Float can't be cast to the desired output ty ...

  7. python报错:TypeError: cant multiply sequence by non-int of type float(bug)(csdn标题没法用英文引号,以后注意别搜引号)

    python报错:TypeError: can't multiply sequence by non-int of type 'float' 注意:csdn标题没法用英文引号,以后注意别搜引号!!!! ...

  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. 成功解决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 " ...

最新文章

  1. python是什么编程教程-编程零基础应当如何开始学习 Python?
  2. 动态规划训练19、最短路 [Help Jimmy POJ - 1661 ]
  3. JSP -java service pages
  4. 深圳465亿建11代生产线,TCL三星带头认购股权
  5. JSP 页面实现一个计算器功能
  6. 禅道安装与常见问题!!
  7. robocode 安装 使用
  8. 社交网站Friendster获第四项美国专利
  9. 生活中的逻辑谬误03.滑坡谬误
  10. 虚拟机复制镜像操作方法
  11. vs项目配置类型解析
  12. DPDK 与DPDK-Pktgen 安装
  13. radis--简介和常遇问题
  14. (计算机组成原理)CPU的功能
  15. 弱人工智能阶段,优必选融资重视生态布局
  16. 列表排序|sort()函数
  17. 前端工程师必备实用网站
  18. 深圳鸣鸿带大家了解蚀刻刀模的种类
  19. Java学习 - URL短地址压缩算法
  20. 开源数字化校园 CoolSchool即将启动

热门文章

  1. 大数据剖析:离开互联网大厂的年轻人都去了哪里?
  2. Python推荐系统学习笔记(5)基于协同过滤的个性化推荐算法实战---UserCF算法(下)
  3. 根据条件展示不同图片
  4. 2023最新SSM计算机毕业设计选题大全(附源码+LW)之java图书销售网站v040m
  5. 请问C#中 if(fonrdlg .ShowDialog () ==DialogResult .OK )怎么理解
  6. 设计模式:Memento模式
  7. matlab超晶格,绝热频率转化和光学超晶格的结构设计重点.doc
  8. QtConcurrent的基础用法map,mapped,mappedReduced
  9. 花生壳和神卓互联的NAT产品为什么没有其它公司做出来(分析很到位)
  10. 《寒假去世十 第一章》