yolov5训练自己的数据集问题排除

本文详细描述了在yolov5v6.0环境中遇到的四个问题:git配置错误、数据读取异常、Git仓库查找失败和数据集路径设置错误,以及对应的解决策略。
摘要由CSDN通过智能技术生成

PS:笔者以下问题都是基于在yolov5-v6.0版本出现

问题1:在运行train.py时出现以下报错


D:\ProgramData\Anaconda3\envs\yolov5\python.exe D:/yxt/yolov5-master/train.py
Traceback (most recent call last):
  File "D:\ProgramData\Anaconda3\envs\yolov5\lib\site-packages\git\__init__.py", line 140, in <module>
    refresh()
  File "D:\ProgramData\Anaconda3\envs\yolov5\lib\site-packages\git\__init__.py", line 127, in refresh
    if not Git.refresh(path=path):
  File "D:\ProgramData\Anaconda3\envs\yolov5\lib\site-packages\git\cmd.py", line 455, in refresh
    raise ImportError(err)
ImportError: Bad git executable.
The git executable must be specified in one of the following ways:
    - be included in your $PATH
    - be set via $GIT_PYTHON_GIT_EXECUTABLE
    - explicitly set via git.refresh()

All git commands will error until this is rectified.

This initial message can be silenced or aggravated in the future by setting the
$GIT_PYTHON_REFRESH environment variable. Use one of the following values:
    - quiet|q|silence|s|silent|none|n|0: for no message or exception
    - warn|w|warning|log|l|1: for a warning message (logged at level CRITICAL, displayed by default)
    - error|e|exception|raise|r|2: for a raised exception

Example:
    export GIT_PYTHON_REFRESH=quiet


The above exception was the direct cause of the following exception:

Traceback (most recent call last):
  File "D:/yxt/yolov5-master/train.py", line 100, in <module>
    GIT_INFO = check_git_info()
  File "D:\ProgramData\Anaconda3\envs\yolov5\lib\contextlib.py", line 75, in inner
    return func(*args, **kwds)
  File "D:\yxt\yolov5-master\utils\general.py", line 375, in check_git_info
    import git
  File "D:\ProgramData\Anaconda3\envs\yolov5\lib\site-packages\git\__init__.py", line 142, in <module>
    raise ImportError("Failed to initialize: {0}".format(_exc)) from _exc
ImportError: Failed to initialize: Bad git executable.
The git executable must be specified in one of the following ways:
    - be included in your $PATH
    - be set via $GIT_PYTHON_GIT_EXECUTABLE
    - explicitly set via git.refresh()

All git commands will error until this is rectified.

This initial message can be silenced or aggravated in the future by setting the
$GIT_PYTHON_REFRESH environment variable. Use one of the following values:
    - quiet|q|silence|s|silent|none|n|0: for no message or exception
    - warn|w|warning|log|l|1: for a warning message (logged at level CRITICAL, displayed by default)
    - error|e|exception|raise|r|2: for a raised exception

Example:
    export GIT_PYTHON_REFRESH=quiet


Process finished with exit code 1

解决方法:

通过查询网友的解释,可能时因为yolov5的获取方式时直接下载的zip导致的,不是通过git方式下载会出现这个问题,可以通过以下解决

在cmd.py中
import os
os.environ["GIT_PYTHON_REFRESH"] = "quiet"
import signal

问题2:

    data = self.stream.read(size)
UnicodeDecodeError: 'gbk' codec can't decode byte 0x80 in position 234: illegal multibyte sequence
COMET INFO: Couldn't find a Git repository in 'D:\\yxt\\yolov5-master' nor in any parent directory. Set `COMET_GIT_DIRECTORY` if your Git Repository is elsewhere.
COMET WARNING: Unknown error exporting current conda environment

解决方法:

 在修改自己的数据集时,往往时通过复制coco128.yaml文件再修改得到,这时候自己的yaml文件中可能存在不能解释的字符,以下两种方式都可以解决,

第一种:

# parent
# ├── yolov5
# └── datasets
#     └── coco128  ← downloads here (7 MB)

第二种,也可以修改成如下所示:

# parent
# |--yolov5
# |--datasets
#     |--coco128 <- downloads here (7 MB)

问题3:

COMET INFO: Couldn't find a Git repository in 'D:\\yxt\\yolov5-master' nor in any parent directory. Set `COMET_GIT_DIRECTORY` if your Git Repository is elsewhere.
COMET WARNING: Unknown error exporting current conda environment

解决方法:

这个报错暂时未修改,因为没有影响到训练。 

问题4:

raise Exception("Dataset not found ❌") Exception: Dataset not found ❌

解决方法:

这种问题通常是设置的数据集路径不对

要注意路径的datasets通常时与yolov5的工程路径在同一级目录下,不能放到yolov5工程目录下,修改目录即可以解决。

  • 20
    点赞
  • 17
    收藏
    觉得还不错? 一键收藏
  • 5
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论 5
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值