用FLIR热数据集跑yolov5 个人踩坑大全
版本:yolov5-v5.0
环境:python3.8+anaconda3_2020.7+cuda10.1.105
数据集:FLIR_ADAS_1_3.tar
1、问题:ImportError: The _imagingft C module is not installed
在测试YOLO v5时出现错误提示:
ImportError: The _imagingft C module is not installed
经查是pillow库的问题
解决
windows系统
卸载pillow,重新安装
pip uninstall pillow
pip3 install pillow
加上 --no-cache-dir参数:
pip3 install pillow --no-cache-dir
Ubuntu系统
卸载同上
然后安装devel
sudo apt-get install libtiff-devel libjpeg-devel libzip-devel freetype-devel lcms2-devel libwebp-devel tcl-devel tk-devel
最后重新安装。
注:适用于代码中导入语句为:
from PIL import ImageFont
2、问题:train: Scanning ‘data\labels\train.cache’ images and labels… 0 found, 1000 missing, 0 empty, 0 corrupted: 100%
解决
(1)数据集格式不对
正确voc格式如下:train文件夹含images和labels两个文件夹,同样的,valid文件夹、test文件夹也都含images和labels两个文件夹
(2)yolov5数据集格式的label要求txt格式。
FLIR数据集自带label存放在一个.json文件中,需要转成txt标签。
(3)images和labels名称必须一一对应。
我之前的labels在文件名前多加了label字样,最后导致标签全部missing,查了好久。
3、问题:
解决
torch包环境、pycharm库和yolov5需求版本不同,用清华源最快解决
pip install opencv-python==4.2.0.32 -i https://pypi.tuna.tsinghua.edu.cn/simple
4、问题:subprocess.CalledProcessError: Command ‘pip install ‘google-auth<2,>=1.6.3’’ returned non-zero exit status 1.
必须把tensorboard卸载之后再下载google-auth,不然报错解决不了。
pip uninstall google-auth
pip uninstall tensorboard
pip install --upgrade google-auth
pip install tensorboard
5、问题:FileNotFoundError: [Errno 2] No such file or directory: ‘yolov5s.pt’ Download error: [WinError 10060] 由于连接方在一段时间后没有正确答复或连接的主机没有反应,连接尝试失败。 ERROR: Download failure: yolov5s.pt missing, try downloading from https://github.com/ultralytics/yolov5/releases/
网速太慢,建议直接下载权重文件放在weights文件夹下。
yolov5l.pt yolov5m.pt yolov5s.pt yolov5n.pt yolov5x.pt
分享给你们了,自取。网上都付费。
百度网盘链接:https://pan.baidu.com/s/1af4C3qlYU4cQFRkHHWX_1Q
提取码:f3rw
6、问题:AttributeError: Can’t get attribute ‘SPPF’ on <module ‘models.common’ from ‘F:\gra\yolov5-v5.0\models\common.py’>
修改一下那个models文件夹下的common.py
添加下面代码即可
import warnings
class SPPF(nn.Module):
# Spatial Pyramid Pooling - Fast (SPPF) layer for YOLOv5 by Glenn Jocher
def __init__(self, c1, c2, k=5): # equivalent to SPP(k=(5, 9, 13))
super().__init__()
c_ = c1 // 2 # hidden channels
self.cv1 = Conv(c1, c_, 1, 1)
self.cv2 = Conv(c_ * 4, c2, 1, 1)
self.m = nn.MaxPool2d(kernel_size=k, stride=1, padding=k // 2)
def forward(self, x):
x = self.cv1(x)
with warnings.catch_warnings():
warnings.simplefilter('ignore') # suppress torch 1.9.0 max_pool2d() warning
y1 = self.m(x)
y2 = self.m(y1)
return self.cv2(torch.cat([x, y1, y2, self.m(y2)], 1))
7、问题:OSError: [WinError 1455] 页面文件太小,无法完成操作。 Error loading “D:\Anaconda3_2020\envs\torch\lib\site-packages\torch\lib\caffe2_detectron_ops_gpu.dll” or one of its dependencies.
解决
网上搜的是删除这个文件,但我试过了,删了这个.dll文件还有其他.dll文件报错。最根本原因是电脑显存不够了,跑不动了。我的电脑配置是i7-9750H+rtx2060+8G,batch=4电脑直接跑爆炸,显示器直接缓存不足。我跑的还是yolov5s.yaml,想象不到跑l的时候的样子哈哈。
废话不多说,我的解决办法是把train.py里面的配置文件batch_size改成1,把datasets.py文件中的num_workers线程改成0。可能笔记本跑不动多线程。