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)

相关推荐
嵌R式小Z2 天前
JSON&cJSON
json
tan77º3 天前
【项目】分布式Json-RPC框架 - 项目介绍与前置知识准备
linux·网络·分布式·网络协议·tcp/ip·rpc·json
Yn3124 天前
在 Python 中使用 json 模块的完整指南
开发语言·python·json
陈涛5757 天前
5个最好用的 JSON 工具推荐:让数据处理变得简单高效
json
bkspiderx7 天前
pb2json.hpp 文档:Protobuf 与 JSON 通用转换工具类
json·protobuf·protobuf与json转换
万粉变现经纪人8 天前
何解决PyCharm中pip install安装Python报错ModuleNotFoundError: No module named ‘json’问题
python·pycharm·json·beautifulsoup·scikit-learn·matplotlib·pip
晨欣8 天前
orjson 与 json:实战对比与选型指南(含示例)(GPT-5 回答)
gpt·json
Pi_Qiu_9 天前
Python初学者笔记第二十二期 -- (JSON数据解析)
笔记·python·json
mon_star°9 天前
有趣的 npm 库 · json-server
前端·npm·json
ID_180079054739 天前
淘宝拍立淘按图搜索API接口功能详细说明
大数据·python·json·图搜索算法