用 yolov3 训练自己的数据集

下载 AlexeyAB 的 darknet

git clone https://github.com/AlexeyAB/darknet.git

满足依赖

依赖条件:

  • Windows or Linux
  • CMake >= 3.8 for modern CUDA

升级 Cmake

  1. 下载源码
  2. 编译

     ./bootstrap && make && sudo make install
    

第一次尝试

第一次打算使用 labelImg 标注后,再使用 darknet 训练数据。但在github上找到了由 AlexeyAB 实现的项目,可以在windows和linux平台上使用,于是打算转向AlexeyAB的项目,试试训练自己的数据集

  1. 下载图像标注工具 labelImg

     git clone https://github.com/tzutalin/labelImg.git
    
  2. 安装 labelImg

     sudo apt-get install pyqt5-dev-tools
     sudo pip3 install -r requirements/requirements-linux-python3.txt
     make qt5py3
    

    在安装 pyqt5 的过程中,出现如下错误:

     Collecting sip<4.20,>=4.19.4 (from pyqt5==5.10.1->-r requirements/requirements-linux-python3.txt (line 1))
     ERROR: Could not find a version that satisfies the requirement sip<4.20,>=4.19.4 (from pyqt5==5.10.1->-r requirements/requirements-linux-python3.txt (line 1)) (from versions: none)
     ERROR: No matching distribution found for sip<4.20,>=4.19.4 (from pyqt5==5.10.1->-r requirements/requirements-linux-python3.txt (line 1))
    

    这个问题似乎是因为python版本导致的,参考Stack Overflow。我只能打开一个py3.6的虚拟环境来运行了。果然如此,我切换到py3.6环境之后,再运行一切正常。

  3. 标注

     python3 labelImg.py
     python3 labelImg.py [IMAGE_PATH] [PRE-DEFINED CLASS FILE]
    

    在运行 python3 labelImg.py 时,遇到了如下错误:

     This application failed to start because it could not find or load the Qt platform plugin "xcb" in "".
     Available platform plugins are: eglfs, linuxfb, minimal, minimalegl, offscreen, vnc, xcb.
     Reinstalling the application may fix this problem.
     [1]    20833 abort (core dumped)  python labelImg.py
    

    原因是没有安装 Qt 软件,从 QT 网站上下载源码并编译安装

    参考 stackover 首先安装 QT 编译所需依赖:

     sudo apt-get install bison build-essential flex gperf gyp \
     libasound2-dev libbz2-dev libcap-dev libcups2-dev libdrm-dev \
     libegl1-mesa-dev libfontconfig1-dev libgcrypt11-dev \
     libglu1-mesa-dev libicu-dev libnss3-dev libpci-dev libpulse-dev \
     libssl-dev libudev-dev libxcomposite-dev libxcursor-dev \
     libxdamage-dev libxrandr-dev libxtst-dev ninja python ruby
    
     cd <path>/<source_package>
     ./configure -release -opensource -confirm-license -shared \
     -no-sql-sqlite -qt-zlib -qt-libpng -qt-libjpeg -qt-freetype\
     -icu -openssl -qt-xcb -opengl -gui -widgets -nomake examples
     make -j 4
     make install