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)

相关推荐
数据知道3 小时前
PostgreSQL实战:详解如何用Python优雅地从PG中存取处理JSON
python·postgresql·json
缘空如是18 小时前
基础工具包之JSON 工厂类
java·json·json切换
墨痕诉清风1 天前
CVS文件转Json格式
json·python3·cvs
数研小生1 天前
1688商品列表API:高效触达批发电商海量商品数据的技术方案
大数据·python·算法·信息可视化·json
devmoon1 天前
快速了解兼容 Ethereum 的 JSON-RPC 接口
开发语言·网络·rpc·json·区块链·智能合约·polkadot
九转成圣1 天前
告别肉眼解析!Java 递归实现 JSON 全路径自动化探测工具
java·自动化·json
JQLvopkk1 天前
C# 实现Http Json格式 Post 、Get 方法请求 winform服务器
http·c#·json
小高Baby@2 天前
JSON、bind、form
数据结构·json
阿蒙Amon2 天前
TypeScript学习-第11章:配置文件(tsconfig.json)
学习·typescript·json
一起养小猫2 天前
Flutter for OpenHarmony 进阶:Timer组件与倒计时系统深度解析
android·网络·笔记·flutter·json·harmonyos