1 配置
1.1 資源下載
MIT分割標定工具:http://labelme2.csail.mit.edu/Release3.0/index.php?message=1
python版本:https://github.com/wkentaro/labelme
1.2 python版本配置
首先安裝Anaconda,安裝後,在命令窗口用conda list測試conda命令是否有效,如果結果爲一空行,則在 Anaconda2\Scripts\conda-script.py 中添加:
if sys.getdefaultencoding() != 'gbk':
reload(sys)
sys.setdefaultencoding('gbk')
然後運行:
conda create --name=labelme python=2.7
activate labelme
conda install pyqt
pip install labelme
注:根據Anaconda版本,修改對應python版本
1.3 遇到的問題
(1)conda install pyqt 出錯:
An error occurred while installing package '' defaults::qt-5.6.2-vc9_6
解決:http://blog.csdn.net/u013863751/article/details/72330041
(2)pip install labelme 出錯:
failed building wheel for scikit-image
解決: http://www.cnblogs.com/harvey888/p/5467276.html
(3)pip install ***出錯:
UnicodeDecodeError: 'ascii' codec can't decode byte 0xb9 in position...
解決:在Anaconda2\Lib\site.py中添加:
if sys.getdefaultencoding() != 'gbk':
reload(sys)
sys.setdefaultencoding('gbk')
(4)pip install scikit-image安裝成功後,還出現錯誤(2):
解決:把命令窗口命令切換到 Anaconda2\Scripts,再運行命令 pip install labelme
2 使用
(1)Annotation
Run labelme --help for detail.
labelme # Open GUI
labelme static/apc2016_obj3.jpg # Specify file
labelme static/apc2016_obj3.jpg -O static/apc2016_obj3.json # Close window after the save
The annotations are saved as a JSON file. The file includes the image itself.
(2)Visualization
To view the json file quickly, you can use utility script:
python scripts/labelme_draw_json static/apc2016_obj3.json
labelme_draw_json源碼爲python,也可以通過修改,用python IDE運行:
#!/usr/bin/env python
import argparse
import json
import matplotlib.pyplot as plt
from labelme import utils
def main():
parser = argparse.ArgumentParser()
parser.add_argument('json_file')
args = parser.parse_args()
json_file = args.json_file
data = json.load(open(json_file))
img = utils.img_b64_to_array(data['imageData'])
lbl, lbl_names = utils.labelme_shapes_to_label(img.shape, data['shapes'])
lbl_viz = utils.draw_label(lbl, img, lbl_names)
plt.imshow(lbl_viz)
plt.show()
if __name__ == '__main__':
main()
(3)Convert to Dataset
To convert the json to set of image and label, you can run following:
python scripts/labelme_json_to_dataset static/apc2016_obj3.json