How I can fix this error in yolov5 python?

141 Views Asked by At

I want to train my yolov5 with a dataset but when I run this command in windows 10 command prompt I get this error:

I run this command (windows 10):

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

error from command prompt:

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

my yaml dataset file:

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']

one of the xml file:

<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>

dataset link: https://www.kaggle.com/datasets/skhalili/iraniancarnumberplate

How I can fix this error?

0

There are 0 best solutions below