如何在yolov5 python中修复此错误?

How I can fix this error in yolov5 python?

提问人:Arian Riyahi 提问时间:11/14/2023 更新时间:11/14/2023 访问量:28

问:

我想用数据集训练我的 yolov5,但是当我在 windows 10 命令提示符下运行此命令时,出现此错误:

我运行以下命令(windows 10):

python train.py --img 415 --batch 16 --epochs 30 --data dataset.yaml --weights yolov5s.pt --cache

命令提示符下出错:

Traceback (most recent call last):
  File "C:\Users\arian\AppData\Local\Programs\Python\Python311\Lib\site-packages\git\__init__.py", line 166, in <module>
    refresh()
  File "C:\Users\arian\AppData\Local\Programs\Python\Python311\Lib\site-packages\git\__init__.py", line 153, in refresh
    if not Git.refresh(path=path):
           ^^^^^^^^^^^^^^^^^^^^^^
  File "C:\Users\arian\AppData\Local\Programs\Python\Python311\Lib\site-packages\git\cmd.py", line 391, 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 warning 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|none|n|0: for no warning or exception
    - warn|w|warning|1: for a printed warning
    - error|e|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 "C:\Users\arian\OneDrive\Desktop\Automatic\yolov5\yolov5-master\train.py", line 72, in <module>
    GIT_INFO = check_git_info()
               ^^^^^^^^^^^^^^^^
  File "C:\Users\arian\AppData\Local\Programs\Python\Python311\Lib\contextlib.py", line 81, in inner
    return func(*args, **kwds)
           ^^^^^^^^^^^^^^^^^^^
  File "C:\Users\arian\OneDrive\Desktop\Automatic\yolov5\yolov5-master\utils\general.py", line 370, in check_git_info
    import git
  File "C:\Users\arian\AppData\Local\Programs\Python\Python311\Lib\site-packages\git\__init__.py", line 168, 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 warning 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|none|n|0: for no warning or exception
    - warn|w|warning|1: for a printed warning
    - error|e|raise|r|2: for a raised exception

Example:
    export GIT_PYTHON_REFRESH=quiet

我的 YAML 数据集文件:

train: C:\Users\arian\OneDrive\Desktop\Automatic\yolov5\yolov5-master\dataset\train
val: C:\Users\arian\OneDrive\Desktop\Automatic\yolov5\yolov5-master\dataset\validation

nc: 1

names: ['palak']

XML 文件之一:

<annotation>
    <folder>car</folder>
    <filename>1.jpg</filename>
    <path>C:\Users\am\Desktop\sanaz\car\1.jpg</path>
    <source>
        <database>Unknown</database>
    </source>
    <size>
        <width>312</width>
        <height>416</height>
        <depth>3</depth>
    </size>
    <segmented>0</segmented>
    <object>
        <name>car</name>
        <pose>Unspecified</pose>
        <truncated>0</truncated>
        <difficult>0</difficult>
        <bndbox>
            <xmin>31</xmin>
            <ymin>235</ymin>
            <xmax>98</xmax>
            <ymax>265</ymax>
        </bndbox>
    </object>
</annotation>

数据集链接:https://www.kaggle.com/datasets/skhalili/iraniancarnumberplate

如何修复此错误?

Python 数据集 yolov5

评论


答: 暂无答案