labelme标注数据
使用labelme标注生成json后缀的文件,对于多个类别且每个类别有多个的数据,在由json文件生成掩膜图像时,要确保类别名称顺序正确。
import argparse
import json
import os
import os.path as osp
import warnings
import copy
import numpy as np
import PIL.Image
from skimage import io
import yaml
from labelme import utils
import codecs
json_path = "/home/ubuntu/Documents/labelme/"
out_dir1 = "/home/ubuntu/Documents/labelme_output/"
list = os.listdir(json_path)
for i in range(0, len(list)):
json_file = os.path.join(json_path, list[i])
filename = list[i][:-5] # .json
if os.path.isfile(json_file):
# with open(json_file, 'r',encoding="utf8", errors='ignore') as f:
# data = json.load(f)
data = json.load(open(json_file))
img = utils.image.img_b64_to_arr(data['imageData'])
lbl, lbl_names = utils.shape.labelme_shapes_to_label(img.shape, data['shapes']) # labelme_shapes_to_label
# modify labels according to NAME_LABEL_MAP
# modify labels according to NAME_LABEL_MAP
labelname = {
}