语义分割学习笔记(二)——Windows下 Lableme 配置

来源:互联网 发布:淘宝优惠券从哪里来的 编辑:程序博客网 时间:2024/06/10 08:35

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.7activate labelmeconda install pyqtpip 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 GUIlabelme static/apc2016_obj3.jpg  # Specify filelabelme 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 pythonimport argparseimport jsonimport matplotlib.pyplot as pltfrom labelme import utilsdef 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


阅读全文
1 0
原创粉丝点击