YOLOV7常见错误合集(含经典错误,共六类)

1、Unicode DecodeError: 'gbk' codec can't decode type 0xaf in position 525: illegal multibyte sequence

 原因是python和win10系统,打开文件时默认的编码方式冲突导致:python默认的是gbk,而win10默认的是utf-8,所以只要改一下python打开文件时,默认的编码就行。

 

2、subprocess.Called processError: Command 'git tag' returned non-zero exit status 128

主要原因是因为request请求访问github被墙,解决方案就是手动下载所需的yolov7.pt权重文件,地址为https://github.com/WongKinYiu/yolov7

 

 

在 yolov7-main下建一个weight文件,把这两个权重文件都保存在weight文件下,

然后还要把train.py中的权重从‘yolo7.pt’改为‘weight/yolov7.pt’

3、AssertionError: Label class 15 exceeds nc=1 in data/defectyaml. Possible class labels are 0-0

主要原因是类别设置出现错误:条件是标签类别数(mlc)应该小于总类别数(nc),如果不满足这个条件,就会抛出 AssertionError。

 改成大于或等于错误提示里的class就好了。

4、RuntimeError: CUDA out of memory. Tried to allocate 52.00 MiB (GPU 0; 5.80 GiB total capacity; 4.62 GiB already allocated; 36.38 MiB free; 4.64 GiB reserved in total by PyTorch) If reserved memory is

主要原因是cuda内存不足

(1)最直接的解决办法是减小batch_size
python train_net.py --config-file configs/coco/darknet53.yaml --num-gpus 1

 如果使用以上命令,可以在 configs/coco/darknet53.yaml文件下使用ctrl+f搜索batch 将其修改为16,还是报同样错误则修改为8。

(2)如果在训练过程遇到这种情况,可以尝试在训练前先释放CUDA内存
nvidia-smi查看GPU使用率,如果使用率不高,就使用torch.cuda.empty_cache()释放内存

在train_net.py中main下面添加如下代码:

    if hasattr(torch.cuda, 'empty_cache'):
        torch.cuda.empty_cache()

5、/yolov7-1.0/yolov7/modeling/meta_arch/yolov7.py:704: UserWarning: __floordiv__ is deprecated, and its behavior will change in a future version of pytorch. It currently rounds toward 0 (like the 'trunc' function NOT 'floor'). This results in incorrect rounding for negative values. To keep the current behavior, use torch.div(a, b, rounding_mode='trunc'), or for actual floor division, use torch.div(a, b, rounding_mode='floor').
  best_n_mask = (best_n_all // 3) == self.level

按照要求找到yolov7-1.0/yolov7/modeling/meta_arch/yolov7.py文件所在的行

 将其修改为如下内容:

best_n_mask=torch.div(best_n_all, 3, rounding_mode='floor')== self.level

再次运行下面命令即可成功。

python train_net.py --config-file configs/coco/darknet53.yaml --num-gpus 1

6、AssertionError: train: No labels in C:\Users\34336\Desktop\yolov7-main\datasets\knife\train.cache. Can not train without labels. See 

(1)

代码中要求的文件名是Images和Labels,可能自己命名的是image和label。

看看自己有没有把文件名搞错。

(2)可能改配置的过程中不小心动到了哪里,把yolov7这个文件删了,重新把解压包解压,再次运行就可以了。

  • 5
    点赞
  • 16
    收藏
    觉得还不错? 一键收藏
  • 5
    评论
评论 5
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值