LabelImg是一个图形图像注释工具。 它是用Python编写的,并使用Qt作为其图形界面。 注释以PASCAL VOC格式保存为XML文件,这是ImageNet使用的格式。 详细内容见https://github.com/tzutalin/labelImg。
系统为Ubuntu,Python版本不同,安装方式也不同。 Python 2 + Qt4
sudo apt-get install pyqt4-dev-tools sudo pip install lxml git clone https://github.com/tzutalin/labelImg.git cd labelImg make all python labelImg.py #打开labelImg python labelImg.py [IMAGE_PATH] [PRE-DEFINED CLASS FILE]Python 3 + Qt5
sudo apt-get install pyqt5-dev-tools sudo pip3 install lxml git clone https://github.com/tzutalin/labelImg.git cd labelImg make all python3 labelImg.py #打开labelImg python3 labelImg.py [IMAGE_PATH] [PRE-DEFINED CLASS FILE]使用方法很简单。
Open可导入单张图片。Open Dir可打开文件夹目录,然后可以用Next Image和Prev Image查看所有图片。Change Save Dir可以更改xml文件保存的路径。Verify Image可更改xml文件的内容。Save可保存xml文件。下图为标注一张图片后的效果。
保存的xml文件内容如下:
<annotation> <folder>桌面</folder> <filename>d3738a0d75.jpg</filename> <path>/home/qq/桌面/d3738a0d75.jpg</path> <source> <database>Unknown</database> </source> <size> <width>0</width> <height>0</height> <depth>3</depth> </size> <segmented>0</segmented> <object> <name>person</name> <pose>Unspecified</pose> <truncated>0</truncated> <difficult>0</difficult> <bndbox> <xmin>65</xmin> <ymin>55</ymin> <xmax>222</xmax> <ymax>350</ymax> </bndbox> </object> <object> <name>person</name> <pose>Unspecified</pose> <truncated>1</truncated> <difficult>0</difficult> <bndbox> <xmin>215</xmin> <ymin>1</ymin> <xmax>374</xmax> <ymax>350</ymax> </bndbox> </object> </annotation>在https://tzutalin.github.io/labelImg/下载Linux版本的文件,解压后运行。 导入图片,标注,保存,会报以下错误。所以建议用以上的方式安装。
Traceback (most recent call last): File "labelImg/labelImg.py", line 1151, in openFile File "labelImg/labelImg.py", line 928, in loadFile File "posixpath.py", line 105, in splitext File "genericpath.py", line 91, in _splitext AttributeError: 'QString' object has no attribute 'rfind' Traceback (most recent call last): File "labelImg/labelImg.py", line 1166, in saveFile File "labelImg/labelImg.py", line 1187, in _saveFile File "labelImg/labelImg.py", line 713, in saveLabels UnicodeEncodeError: 'ascii' codec can't encode characters in position 14-15: ordinal not in range(128)