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)

相关推荐
键盘鼓手苏苏18 小时前
Flutter for OpenHarmony 实战:Flutter Rust Bridge — 极致计算性能方案
开发语言·后端·flutter·华为·rust·json·harmonyos
攻城狮的梦20 小时前
go中json数据的转化
json
Dxy12393102161 天前
Python检查JSON格式错误的多种方法
前端·python·json
秃了也弱了。2 天前
python修复json神器:json-repair包(用于大模型返回json不规范)
python·json
I'm Jie2 天前
【已解决】SqlAlchemy 插入 MySQL JSON 字段时 None 变为 ‘null‘ 字符串,WHERE IS NULL 失效
数据库·python·mysql·json·fastapi·sqlalchemy
Hui Baby2 天前
Spring Boot 中使用 JSONPath 高效处理 JSON 数据
spring boot·python·json
Hui Baby2 天前
SpringBoot + JSON 字段 + MySQL 8.0 函数索引:灵活存储半结构化数据,查询不慢
spring boot·mysql·json
Dxy12393102163 天前
Python 将 JSON 字符串转换为字典
前端·python·json
一个天蝎座 白勺 程序猿3 天前
破译JSON密码:KingbaseES全场景JSON数据处理实战指南
数据库·sql·json·kingbasees·金仓数据库
叫我龙翔3 天前
【计网】从零开始掌握序列化 --- JSON实现协议 + 设计 传输\会话\应用 三层结构
服务器·网络·c++·json