yolov5训练自己的数据集-错误记录

本文介绍了在Ubuntu 16.04环境下使用PyTorch版本的YOLOv5进行数据集训练时遇到的问题,包括TLS连接错误、yaml解析错误、图片尺寸不匹配、学习率调度顺序和类型转换错误的处理。提供了解决方案并强调了正确代码执行的重要性。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >


环境介绍: ubantu16.04,pytorch,yolov5-v4
用yolov5训练自己的数据集!


1.

问题描述:gnutls_handshake() failed: The TLS connection was non-properly terminated.
subprocess.CalledProcessError: Command 'if [ -d .git ]; then git fetch && gi
错误定位:

    if opt.global_rank in [-1, 0]:
        check_git_status()

欠妥的办法:查了一些资料,未能找到有效解决方案,索性先不做检查,即注释掉这行代码
欠妥办法可能带来的影响:目前还不清楚
可以参考的东西:Git gnutls_handshake() failed解决办法 - 青山牧云人 - 博客园

2.

问题描述:yaml.scanner.ScannerError: while scanning a simple key  in "data/coco.yaml", line 18, column 1 could not find expected ':'  in "data/coco.yaml", line 20, column 1
错位定位:

 data_dict = yaml.load(f, Loader=yaml.FullLoader) 

 错误原因:.yaml文件中的键和值没有用空格隔开,
 解决方式:键和值之间添加空格,我这里是 nc:1,修改完之后是 nc: 1

3.

问题描述:Images sizes do not match. This will causes images to be display incorrectly in the UI.

4.

问题描述:UserWarning: Detected call of `lr_scheduler.step()` before `optimizer.step()`. In PyTorch 1.1.0 and later, you should call them in the opposite order: `optimizer.step()` before `lr_scheduler.step()`.  Failure to do this will result in PyTorch skipping the first value of the learning rate schedule. 

问题分析:UserWarning:检测到在'optimizer.step()'之前调用'lr_scheduler.step()'。在PyTorch 1.1.0及更高版本中,应该以相反的顺序调用它们:`optimizer.step()`在`lr_scheduler.step()之前。否则将导致PyTorch跳过学习率计划的第一个值。
解决方式:先调用optimizer.step() 再调用lr_scheduler.step()。

5.

问题描述:TypeError: int() can't convert non-string with explicit base
错误定位:

def color_list():
    # Return first 10 plt colors as (r,g,b) https://stackoverflow.com/questions/51350872/python-from-color-name-to-rgb
    def hex2rgb(h):
        return tuple(int(h[1 + i:1 + i + 2], 16) for i in (0, 2, 4))

    return [hex2rgb(h) for h in plt.rcParams['axes.prop_cycle'].by_key()['color']]

解决方式:把上述代码替换为

def color_list():
    # Return first 10 plt colors as (r,g,b) https://stackoverflow.com/questions/51350872/python-from-color-name-to-rgb
    def hex2rgb(h):
        return tuple(int(h[1 + i:1 + i + 2], 16) for i in (0, 2, 4))

    return [hex2rgb(h) for h in matplotlib.colors.TABLEAU_COLORS.values()]

可以参考的东西:TypeError: int() can't convert non-string with explicit base · Issue #2066 · ultralytics/yolov5 · GitHub

评论 19
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值