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)

相关推荐
电商API&Tina1 小时前
【电商API】淘宝/天猫拍立淘(按图搜索商品)API 全解析
大数据·开发语言·数据库·人工智能·json·图搜索算法
winfredzhang10 小时前
实战复盘:如何用 HTML+JS+AI 打造一款“影迹”智能影视管理系统
javascript·html·json·加载·搜索·保存·电影接口
流沙QS21 小时前
JSON序列化/反序列化工具改进版
java·json
曹牧1 天前
JSON文本格式化
json
ChindongX1 天前
garbage at the end of the document
qt·json
_xaboy1 天前
开源Vue组件-动态表单组件设计,告别重复CRUD,JSON一键生成表单
前端·vue.js·低代码·开源·json
一晌小贪欢1 天前
Python JSON 处理最佳实践:从入门到构建健壮的容错系统
开发语言·python·json·字典·python字典·python办公
yangminlei2 天前
Spring MVC 响应机制综合实践:页面、数据、JSON 与响应配置
spring·json·mvc
静小谢2 天前
前端mock假数据工具JSON Server使用笔记
前端·笔记·json
辰阳星宇2 天前
python代码修复字符串json数据格式问题,并将其按照字典形式读取
windows·python·json