PyTorch-YOLOv3训练自己的数据集--之--排坑指南

相比于官方给出的基于darknet框架的YOLOv3基于PyTorch的YOLOv3源码易懂,使用更方便。我将自己在学习和探索过程中遇到的问题和解决的经验在这里与大家分享,希望能为初学者提供一些帮助。

1. 运行detect.py 时,出现RuntimeError:Invalid DISPLAY variable

解决方法:给detect.py的 import matplotlib 后面line22加

plt.switch_backend(‘agg’)
2. 训练时出现 UserWarning: indexing with dtype torch.uint8 is now deprecated, please use a dtype torch.bool instead

解决方法:将utils/utils.py 第269行

ByteTensor = torch.cuda.ByteTensor if pred_boxes.is_cuda else torch.ByteTensor

修改为:

BoolTensor = torch.cuda.BoolTensor if pred_boxes.is_cuda else torch.BoolTensor

并将278, 279行修改为:

obj_mask = BoolTensor(nB, nA, nG, nG).fill_(0)
noobj_mask = BoolTensor(nB, nA, nG, nG).fill_(1)
3. Out of memory tried to allocate xxxx bytes

解决方法:将train.py中batch_size调小。

4. OSError: image file is truncated (98 bytes not processed)

解决方法:给train.py中加这两行代码

from PIL import ImageFile
ImageFile.LOAD_TRUNCATED_IMAGES = True
5. Traceback (most recent call last): File “train_yolov3.py”, line 176, in ap_table += [[c, class_names[c], “%.5f” % AP[i]]]
IndexError: list index out of range

后来发现是因为自己的*.names文件中最后一行少了一个换行符 ~~~~~~~~愚蠢至极

6. 训练第一个epoch时,test.py中ValueError: not enough values to unpack (expected 3, got 0)

解决方法修改代码增加判断条件

7. AttributeError: module ‘tensor board.summary._tf.summary’ has no attribute ‘FileWriter’

原因:tensorflow版本问题
解决方案修改utils/logger.py

8. metric_table = [[“Metrics”, *[f"YOLO Layer {i}" for i in range(len(model.yolo_layers))]]]
SyntaxError: invalid syntax

解决方案:使用python3.6以上版本

[1] https://github.com/eriklindernoren/PyTorch-YOLOv3
[2] https://pjreddie.com/darknet/yolo/

  • 6
    点赞
  • 25
    收藏
    觉得还不错? 一键收藏
  • 8
    评论
评论 8
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值