labelme 修改后的json文件 ,imageData 值改为null的脚本

import os

import json

def set_image_data_to_null(directory):

for filename in os.listdir(directory):

if filename.endswith('.json'):

file_path = os.path.join(directory, filename)

with open(file_path, 'r', encoding='utf-8') as file:

data = json.load(file)

将 imageData 设置为 None,在JSON文件中会显示为 null

if 'imageData' in data:

data['imageData'] = None

保存修改后的文件

with open(file_path, 'w', encoding='utf-8') as file:

json.dump(data, file, indent=4)

替换以下路径为你的JSON文件所在的文件夹路径

directory_path = 'path_to_your_directory'

set_image_data_to_null(directory_path)

相关推荐
Kiyra4 小时前
LLM 的 JSON 不靠谱:结构化输出的重试与修复实战
开发语言·python·json
易生一世6 小时前
JWT详解
json·证书·jwt·token·ai skills
原来是猿1 天前
JSON 序列化与反序列化 —— 用 Jsoncpp 打造自己的网络协议
网络·网络协议·json
愈努力俞幸运2 天前
json schema
json
神所夸赞的夏天2 天前
如何获取多层json数据,存成dictionary,并取最大最小值
java·前端·json
web3.08889993 天前
天猫API接口详解:商品详情与关键词搜索商品指南及代码示例
python·json
老神在在0013 天前
jsonshema小点
python·json
阿Y加油吧4 天前
RAG 必学:ANN 检索、HNSW 算法与 Milvus 核心概念详解
数据库·mysql·json
likerhood5 天前
Fastjson中的JSON.parseObject()详细讲解
java·json
老神在在0015 天前
JSON Schema
测试工具·json