将使用labelme的标注文件.json批量转为mask.png图片
在使用labelme标注后会得到json格式的文件,将单个json标注文件转为mask.png的终端命令:
conda activate labelme #激活labelme环境
labelme_json_to_dataset E:\your\json\file\0001.json
实现这个功能的是Labelme安装目录下的..\Scripts\labelme_json_to_dataset.exe,使用Python循环调用程序即可批量转换:
# -- coding: utf-8 --**
import os
import glob
path = r'E:\path\to\your\json\files' # 这里是指.json文件所在文件夹的路径
json_file = glob.glob(os.path.join(path, "*.json"))
for file in json_file:
os.system("D:\Anaconda\envs\labelme\Scripts\labelme_json_to_dataset.exe " + file)