修改labelme标注文件json中的类别名

对labelme标注文件中的类别名进行修改

import codecs
import cv2
import shutil
import os
import json
import numpy as np
import random
import xml.etree.ElementTree as ET
path = "xxxxx" #json路径
info_all = os.listdir(path)
for info in info_all:
    if info.endswith('.json'):
        json_path = os.path.join(path, info_name)
        with open(json_path, "r", encoding='gb2312') as f:
            desc = json.load(f)
        for key, value in desc.items():
            if key == 'imagePath':
                desc['imagePath'] = 'xxx' #修改类别名
        with open(json_path, 'w') as dump_f:
            json.dump(desc, dump_f, indent=4)

猜你喜欢

转载自blog.csdn.net/qq_41980080/article/details/131374156