【YOLOV5】

@ YOLOV5

下载代码并配置环境

Python>=3.6.0

$ git clone https://github.com/ultralytics/yolov5
$ cd yolov5
$ pip install -r requirements.txt

检测

运行代码 detect.py

python detect.py --source 0 img.jpg 

训练

我的电脑配置低,用的CPU,batch_size改为4才能跑下去

python train.py --data coco.yaml --cfg yolov5s.yaml --weights '' --batch-size 16

遇到的问题

1、wandb 未注册异常: wandb.errors.UsageError

解决方法:

pip install wandb
wandb init 
# 点击出现的网址进行注册,并获取api key
wandb login
# 将用户名及 wandb login 输入

2、coco128.zip 数据下载失败

解决方法:

打开get_coco128.sh文件,复制链接coco128.zipzh直接在浏览器中下载,速度更快

3、libiomp5md.dll 报错

OMP: Error #15: Initializing libiomp5md.dll, but found libiomp5md.dll already initialized.
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/.
OMP: Error #15: Initializing libiomp5md.dll, but found libiomp5md.dll already initialized.
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/.
OMP: Error #15: Initializing libiomp5md.dll, but found libiomp5md.dll already initialized.
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/.
OMP: Error #15: Initializing libiomp5md.dll, but found libiomp5md.dll already initialized.
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/.
OMP: Error #15: Initializing libiomp5md.dll, but found libiomp5md.dll already initialized.
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/.

解决方法:

我是用conda创建一个yolov55的虚拟环境,
在anaconda3\envs\yolov55的目录下搜索libiomp5md.dll, 发现有该目录下存在两个libiomp5md.dll文件。
将D:\softmax\anaconda3\envs\yolov55\Library\bin目录下的libiomp5md.dll文件剪切到别的文件夹下。我是放到C盘文档下,并备份之前存在的路径。问题解决。

4、CUDA error

Traceback (most recent call last):
  File "D:\Projects\yolov5\train.py", line 629, in <module>
    main(opt)
  File "D:\Projects\yolov5\train.py", line 526, in main
    train(opt.hyp, opt, device, callbacks)
  File "D:\Projects\yolov5\train.py", line 424, in train
    model=attempt_load(f, device).half(),
  File "D:\Projects\yolov5\models\experimental.py", line 98, in attempt_load
    model.append(ckpt['ema' if ckpt.get('ema') else 'model'].float().fuse().eval())  # FP32 model
  File "D:\Projects\yolov5\models\yolo.py", line 222, in fuse
    m.conv = fuse_conv_and_bn(m.conv, m.bn)  # update conv
  File "D:\Projects\yolov5\utils\torch_utils.py", line 205, in fuse_conv_and_bn
    fusedconv.weight.copy_(torch.mm(w_bn, w_conv).view(fusedconv.weight.shape))
RuntimeError: CUDA error: CUBLAS_STATUS_NOT_INITIALIZED when calling `cublasCreate(handle)`

解决方法

batch_size=64 的值设置的太大了,GPU没那么厉害,改成16,解决。

你可能感兴趣的:(yolov5,python)