美文网首页
图像标注工具labelme

图像标注工具labelme

作者: 丙吉 | 来源:发表于2023-08-13 17:07 被阅读0次
模型训练时需要数据和标注
图像的数据标注很多,今天用的是labelme,看文档就可以上手用了。
1。代码下载地址:

https://github.com/wkentaro/labelme

2。安装:看readme中的安装和基本命令就可以。
我是windows环境的,新建了个环境,然后安装labelme即可
# python3
conda create --name=labelme python=3
source activate labelme
# conda install -c conda-forge pyside2
# conda install pyqt
# pip install pyqt5  # pyqt5 can be installed via pip on python3
pip install labelme
# or you can install everything by conda command
# conda install labelme -c conda-forge
3。基本命令
# 在命令行输入labelme即可打开一个界面,在此可以打开需要标注的图像;
labelme  # just open gui

# tutorial (single image example)
cd examples/tutorial
labelme apc2016_obj3.jpg  # specify image file
labelme apc2016_obj3.jpg -O apc2016_obj3.json  # close window after the save
labelme apc2016_obj3.jpg --nodata  # not include image data but relative image path in JSON file
labelme apc2016_obj3.jpg \
  --labels highland_6539_self_stick_notes,mead_index_cards,kong_air_dog_squeakair_tennis_ball  # specify label list

# semantic segmentation example
cd examples/semantic_segmentation
labelme data_annotated/  # Open directory to annotate all images in it
labelme data_annotated/ --labels labels.txt  # specify label list with a file
# 快速查看标注图像
labelme_draw_json apc2016_obj3.json
# 把json数据转成图像和标签(生成文件夹,里面有四个文件)
labelme_export_json apc2016_obj3.json -o apc2016_obj3_json

查看生成的Label PNG数据

# see load_label_png.py also.
>>> import numpy as np
>>> import PIL.Image

>>> label_png = 'apc2016_obj3_json/label.png'
>>> lbl = np.asarray(PIL.Image.open(label_png))
>>> print(lbl.dtype)
dtype('uint8')
>>> np.unique(lbl)
array([0, 1, 2, 3], dtype=uint8)
>>> lbl.shape
(907, 1210)

或直接查看label png图片

labelme_draw_label_png apc2016_obj3_json/label.png

相关文章

网友评论

      本文标题:图像标注工具labelme

      本文链接:https://www.haomeiwen.com/subject/zzafmdtx.html