import os
json_folder = r"G:\test 2\1" #这个路径包含了图像和对应的json文件,就是上面截图的路径
# 获取文件夹内的文件名
FileNameList = os.listdir(json_folder)
# 激活labelme环境
os.system("activate ame=labelme")
for i in range(len(FileNameList)):
# 判断当前文件是否为json文件
if(os.path.splitext(FileNameList[i])[1] == ".json"):
json_file = json_folder + "\\" + FileNameList[i]
# 将该json文件转为png
os.system("labelme_json_to_dataset " + json_file)
>
[WARNING] json_to_dataset:main:15 - This script is aimed to demonstrate how to convert the JSON file to a single image dataset.
[WARNING] json_to_dataset:main:19 - It won't handle multiple JSON files to generate a real-use dataset.
usage: labelme_json_to_dataset [-h] [-o OUT] json_file
labelme_json_to_dataset: error: unrecognized arguments: 2\1\马尔康1(1).json