1. 数据集配置问题
train: WARNING: D:\dataSet\test\images\train\0001.jpg: ignoring corrupt image/label:
train文件的配置
我这里是数据集的yaml文件路径配置的问题,YOLOv5加载数据时,会将你的路径中的images字符串替换成labels来找txt标记文件,值得注意的是这些标记文件名要和对应图片同名。
# parent
# ├── yolov5
# └── dataset
# └── train
# └── images
# └── labels
# └── val
# └── images
# └── labels
# └── test
# └── images
train: ../dataset/train/images/
val: ../dataset/val/images/
test: ../dataset/test/images/
# Classes
names:
0: cattle
1: horse
#文件摆放也可如下,yaml要配置正确路径(../代表上一级目录)
# ├── yolov5
# └── dataset
# └── images
# └── images
# └── labels
# └── trains
# └── images
# └── labels
# └── test
# └── images
2. 在离线模式下,无字体文件的问题
Downloading https://ultralytics.com/assets/Arial.ttf to C:\Users\93sa003\AppData\Roaming\Ultralytics\Arial.ttf...
COMET INFO: Couldn't find a Git repository in 'D:\\file\\test\\yolov5-master' nor in any parent directory. Set `COMET_GIT_DIRECTORY` if your Git Repository is elsewhere.
下载该字体文件后直接放到你项目包中即可
https://ultralytics.com/assets/Arial.ttf
3. 加载数据可视化wandb工具的问题
wandb: (1) Create a W&B account
wandb: (2) Use an existing W&B account
wandb: (3) Don't visualize my results
wandb: Enter your choice: (30 second timeout)
你可在Wandb 网站 (https://wandb.ai/),申请一个秘钥(免费),并在有网的情况下输入。
也可选择修改源码部分,让wandb不启动,如下。
将_init_.py中以下代码注释,并加上wandb = None
try:
import wandb
assert hasattr(wandb, '__version__') # verify package import not local dir
if pkg.parse_version(wandb.__version__) >= pkg.parse_version('0.12.2') and RANK in {0, -1}:
try:
wandb_login_success = wandb.login(timeout=30)
except wandb.errors.UsageError: # known non-TTY terminal issue
wandb_login_success = False
if not wandb_login_success:
wandb = None
except (ImportError, AssertionError):
wandb = None
# try:
# import wandb
# assert hasattr(wandb, '__version__') # verify package import not local dir
# if pkg.parse_version(wandb.__version__) >= pkg.parse_version('0.12.2') and RANK in {0, -1}:
# try:
# wandb_login_success = wandb.login(timeout=30)
# except wandb.errors.UsageError: # known non-TTY terminal issue
# wandb_login_success = False
# if not wandb_login_success:
# wandb = None
# except (ImportError, AssertionError):
# wandb = None
wandb = None
然后,将wandb_untils.py中以下代码注释,并加上wandb = None
try:
import wandb
assert hasattr(wandb, '__version__') # verify package import not local dir
LOGGER.warning(DEPRECATION_WARNING)
except (ImportError, AssertionError):
wandb = None
# try:
# import wandb
# assert hasattr(wandb, '__version__') # verify package import not local dir
# LOGGER.warning(DEPRECATION_WARNING)
# except (ImportError, AssertionError):
# wandb = None
wandb = None
如何你和我一样用了VScode编译器记得ctrl+S保存。
4. out of mermory 内存溢出
可以尝试将训练的--batch 数据量调小一点,比如由32调成16,8或4之类的小一点的数。当然你选择提示电脑硬件(用GPU时,要考虑显存,而用CPU跑时,要多考虑内存)。
python train.py --img 640 --batch 32 --epoch 100 --data data/horse.yaml --cfg models/yolov5s.yaml --weights weights/yolov5s.pt
python train.py --img 640 --batch 8 --epoch 100 --data data/horse.yaml --cfg models/yolov5s.yaml --weights weights/yolov5s.pt
5. 虚拟环境中出现多个libiomp5md.dll的问题
OMP: Hint This means that multiple copies of the OpenMP runtime have been linked into the program. That is dangerous, since it can degrade performance or cause incorrect results. The best thing to do is to ensure that only a single OpenMP runtime is linked into the process, e.g. by avoiding static linking of the OpenMP runtime in any library. As an unsafe, unsupported, undocumented workaround you can set the environment variable KMP_DUPLICATE_LIB_OK=TRUE to allow the program to continue to execute, but that may cause crashes or silently produce incorrect results. For more information, please see http://www.intel.com/software/products/support/.
"C:\Users\93sa003\AppData\Local\Continuum\anaconda2\envs\yolo5\Lib\site-packages\torch\lib\libiomp5md.dll"
网上解决方法:
import os
os.environ["KMP_DUPLICATE_LIB_OK"]="TRUE
我的解决方法,将多余 libiomp5md.dll 删掉
本问题出现主要是因为某个包含了名为libiomp5md.dll的文件,与Anaconda环境中的同一个文件出现了某种冲突,所以需要删除一个。
在你的虚拟环境目录下搜索 libiomp5md.dll
比如我的 C:\Users\93sa003\AppData\Local\Continuum\anaconda2,在该文件夹anacondas文件夹下搜索,删除Anaconda包中libiomp5md.dll这个文件.
这里参考其他博主的方法