標註工具labelImg在Ubuntu系統的安裝和使用
阿新 • • 發佈:2019-01-01
前言
LabelImg是一個圖形影象註釋工具。
它是用Python編寫的,並使用Qt作為其圖形介面。
註釋以PASCAL VOC格式儲存為XML檔案,這是ImageNet使用的格式。
詳細內容見https://github.com/tzutalin/labelImg。
安裝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]
使用labelImg
使用方法很簡單。
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>
遇到的問題
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)