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)

相关推荐
A__tao5 小时前
JSON 转 Java 实体类工具(支持嵌套与注释解析)
java·python·json
迷路爸爸1807 小时前
VSCode / Cursor 中 LaTeX Workshop 的 settings.json 配置:编译与 SyncTeX 跳转
ide·vscode·json·latex
吴声子夜歌1 天前
Node.js——JSON-Server轻量级RESTful API
node.js·json·restful·json-server
呆萌的代Ma1 天前
解决n8n的输入内容报错JSON parameter needs to be valid JSON
json·n8n
ID_180079054734 天前
Python 实现亚马逊商品详情 API 数据准确性校验(极简可用 + JSON 参考)
java·python·json
代码AI弗森4 天前
配置文件战争:TOML/YAML/JSON 为何成为不同框架的“专属标配”?
json
lifewange4 天前
CNode API v1 完整接口文档(JSON 规范整理)
java·前端·json
测试修炼手册5 天前
[测试技术] 深入理解 JSON Web Token (JWT)
前端·json
九转成圣5 天前
Java 性能优化实战:如何将海量扁平数据高效转化为类目字典树?
java·开发语言·json
小袁拒绝摆烂5 天前
多表关联大平层转JSON树形结构
java·json