将json文件放入一个文件夹内。运行json2gray.py:
#!/usr/bin/python
# -*- coding: UTF-8 -*-
# !H:\Anaconda3\envs\new_labelme\python.exe
import argparse
import json
import os
import os.path as osp
import base64
import warnings
import PIL.Image
import yaml
from labelme import utils
import cv2
import numpy as np
from skimage import img_as_ubyte
# from sys import argv
def main():
warnings.warn("This script is aimed to demonstrate how to convert the\n"
"JSON file to a single image dataset, and not to handle\n"
"multiple JSON files to generate a real-use dataset.")
json_file = "./make1" ###json所在文件夹
# freedom
list_path = os.listdir(json_file)
print('freedom =', json_file)
for i in range(0, len(list_path)):
path = os.path.join(json_file, list_path[i])
if os.path.isfile(path):
data = json.load