具体报错如上所示

问题背景

用gradio库写了一个YOLOv7检测logo的demo,上传图片之后报错如上。

解决方法

一开始我以为是类别数不对应的问题,然而并不是。

实际上是一个非常粗心的错误,原本的YOLOv7在训练和检测时都对图片进行了resize操作,而我在调用detect函数的时候,传入的图片是未经过resize的,所以就有了上述错误。

回YOLOv7源码可以看到它是

from utils.datasets import letterbox

然后调用letterbox函数实现resize,于是照搬,增加一行代码就好了。

当然自己写一段resize代码也是可以的。

模型预测过程中报错 RuntimeError: Sizes of tensors must match except in dimension 1.相关推荐

  1. Pytorch_Geometric(PyG)使用DataLoader报错RuntimeError: Sizes of tensors must match except in dimension 0.

    使用Pytorch_Geometric(PyG)时构建DataLoader,从DataLoader获取样本Batch时报错:RuntimeError: Sizes of tensors must ma ...

  2. 记录解决RuntimeError: Sizes of tensors must match except in dimension 1. Expected size 27 but got size

    问题描述 在做目标检测服务过程中,将yolov7模型通过flask打包成预测服务API,此次训练的图像输入大小是1280,输入预测图片是如果图像大于1280则预测成功,小于1280则报RuntimeE ...

  3. RuntimeError: Sizes of tensors must match except in dimension 1. Got 61 and 60 in dimension 2

    1. 背景介绍 在训练语义分割模型时,出现以下错误: RuntimeError: Sizes of tensors must match except in dimension 1. Got 61 a ...

  4. RuntimeError: Sizes of tensors must match except in dimension 2. Got 5 and 4

    调试代码的时候,遇到***RuntimeError: Sizes of tensors must match except in dimension 2. Got 5 and 4*** 这个问题, 解 ...

  5. Sizes of tensors must match except in dimension 1. Got 61 and 60 in dimension 2

    1. 背景介绍       在训练编码解码网络模型时,出现以下错误: RuntimeError: Sizes of tensors must match except in dimension 1. ...

  6. Sizes of tensors must match except in dimension 1. Expected size 24 but got size 25 for tensor numbe

    在做图像分割的时候遇到了错误,错误如下: File "D:/segmentation/Pytorch-UNet-master/train.py", line 193, in < ...

  7. RuntimeError: invalid argument 0: Sizes of tensors must match except in dimension 1.

    最近在修改模型不支持的算子后,由于对模型的效果产生了影响,所以需要进行微调训练,但是训练的时候报错了,如下: File "/home/xxxxxxx/EdgeNets/nn_layers/e ...

  8. RuntimeError: invalid argument 0: Sizes of tensors must match except in dimension 0—问题分析

    声明: 这里仅仅提供一个思路,暂时没有绝对正确通用的解决方案 作者:{ 墨理 } 感谢通过私信.评论交流,协力探讨解决问题的同学 UP .Penser 文章目录 探讨的 pytorch 报错信息如下 ...

  9. Pytorch踩坑: RuntimeError: invalid argument 0: Sizes of tensors must match except in dimension 0.

    报错信息: RuntimeError: invalid argument 0: Sizes of tensors must match except in dimension 0. Got 186 a ...

最新文章

  1. 微服务架构的四大金刚利器
  2. windows部署微服务jar包 yml_杰克布开源项目,低代码开发框架,Docker快速部署
  3. 网络运维基础之IP地址学习
  4. UA MATH571A 多元线性回归IV 广义线性模型
  5. Mongo报如下类似错误时的修改方法Cannot natively represent the long 1396367483000 on this platform...
  6. 产品经理必备知识之网页设计系列(二)-如何设计出一个优秀的界面
  7. Asp.Net 数据分页
  8. ubuntu下面的git服务器搭建
  9. 50种Java编程技巧,越早知道越好!(建议收藏)
  10. 32位与64位、单精度(single-precision)与双精度(double-precision)
  11. php编译安装swoole模块
  12. Spring 5.0.3.RELEASE中的 Kotlin 语言等支持
  13. ai画面怎么调大小_AI页面面板中如何调尺寸
  14. vue error The code generator has deoptimised the styling exceeds the max of 100KB
  15. java halt_Java Runtime halt()方法
  16. 紫书 UVa437巴比伦塔
  17. Ubuntu查看USB串口号【简单、好记、好看】
  18. android手表密码忘了咋办,忘记解锁密码?教你如何重置Android手机的解锁密码
  19. 机器人焊枪动作与编程实验_敲黑板 | 机器人是怎么完成任务的?这三种编程方式的区别你造吗...
  20. ijkPlayer的基本使用(一)

热门文章

  1. Service通过onBind跨进程启动流程源码探究
  2. JavaScript-去除数组中重复元素
  3. 安卓手机怎么关闭服务器信息,安卓手机服务器信息怎么关闭
  4. Java Math toIntExact() 使用方法及示例 long转int
  5. Mybatis-Plus-Generator代码生成工具
  6. Win2000/WinXP/Win2003双系统启动
  7. MybatisPlus中的insert操作
  8. NGINX编译安装configure报错缺少zlib库
  9. python的join函数的用法及实例
  10. 关于python中的位置参数、关键字参数、可变长位置参数以及可变长关键字参数的详解和他们之间在书写时的顺序的问题,超详细总结的知识点!!!