labelImg数据标注工具
本文主要内容分为以下两大类:
a.配置安装;
b.安装出现的一些问题;(问题千奇百怪,若出现其他问题,可以一起交流探讨)
- 安装环境:Ubuntu/Linux下的安装:
(1)克隆labelImg
git clone https://github.com/tzutalin/labelImg.git
(2) Python 2 + Qt4安装
(建议使用Python 2.7和Qt4安装。Python 3和Qt5安装容易出问题。)
cd ~/labelImg
sudo apt-get install pyqt4-dev-tools(我在Mac没装apt-get依赖库,所以无法安装该步骤,以下有mac版的安装步骤)
sudo pip install lxml
make qt4py2
python labelImg.py
python labelImg.py [IMAGE_PATH] [PRE-DEFINED CLASS FILE]
Mac下安装pyqt4:https://www.cnblogs.com/v-BigdoG-v/p/7264162.html
安装pyqt4的步骤:
(1)安装qt;
(2)安装SIP;
(3)安装pyqt4;
//mac下安装qt4
brew install cartr/qt4/pyqt
qmake (安装完我输qmake没反应,需要到qt的安装路径去找#/usr/local/Cellar/qt/5.9.1/bin/qmake)
//安装SIP,下载(sip-4.18.1.tar.gz);网址:https://riverbankcomputing.com/software/sip/download
tar -xzf sip-4.18.1.tar.gz
cd sip-4.18.1
python configure.py -d /Library/Python/2.7/site-packages --arch=x86_64
make
sudo make install
如果 sudo make install 的时候报如下错误
cp -f sip /System/Library/Frameworks/Python.framework/Versions/2.7/bin/sip
cp: /System/Library/Frameworks/Python.framework/Versions/2.7/bin/sip: Operation not permitted
make[1]: *** [install] Error 1
make: *** [install] Error 2
#解决方法
#重启 Mac
#按住 Command + R 直到出现苹果 Logo
#进入 Recoverary 模式
#菜单栏 > 实用工具 > 终端
#输入 csrutil disable (如果想再次改回来,输入 csrutil enable)
#重启 Mac
-
添加自定义类别 修改文件labelImg/data/predefined_classes.txt
//我只检测一类,直接将txt修改成一类; mark
-
使用labelImg进行图像标注 用labelImg标注生成PASCAL VOC格式的xml标记文件;
python labelImg.py
PASCAL VOC标记文件如下:
转换成yolo格式的txt文档为:
0 0.493750 0.109375 0.125000 0.215074
x = x_center/width = 295/1000 = 0.2950
y = y_center/height = 324/654 = 0.4954
w = (xmax - xmin)/width = 216/1000 = 0.2160
h = (ymax - ymin)/height = 606/654 = 0.9266
class_id: 类别的id编号
-
以下安装时出现的问题:
(1)安装环境:python3+Linux(错误很多,建议用python2+pyqt4)
(2安装qt测试安装结果,需要正确找到 qmake 的路径cd /usr/local/Cellar/qt/5.12.1/bin/qmake -------5.12.1为你下载的qt的版本号;如果不知道在qt目录下ls查看便可;
(3)安装pyqt4时出现报错:
Error: This version of PyQt4 and the commercial version of Qt have incompatible licenses.
解决方法:注释掉configure-ng.py下面语句即可:-------该语句在2545行;
if introspecting and target_config.qt_licensee not in OPEN_SOURCE_LICENSEES and ltype == 'GPL':
error(
"This version of PyQt4 and the commercial version of Qt have "
"incompatible licenses.")
(3)
python configure-ng.py -q /usr/local/bin/qmake -d /Library/Python/2.7/site-packages/ --sip /System/Library/Frameworks/Python.framework/Versions/2.7/bin/sip
---------------------该路径需根据自己安装的路径进行修改;
---------------------我的为:/usr/local/Cellar/qt/5.12.1/bin/qmake
python configure-ng.py -q /usr/local/Cellar/qt/5.12.1/bin/qmake -d /Library/Python/2.7/site-packages/ --sip /System/Library/Frameworks/Python.framework/Versions/2.7/bin/sip
(4)编译出现如下错误,重新安装qt4:brew install cartr/qt4/pyqt