在使用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)