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)

相关推荐
程序员大阳1 天前
副队长JavaScript教程(65)-详解JSON:轻量级数据交换格式
javascript·json·序列化·反序列化·stringify·parse
光影6272 天前
Unittest单元测试基础速记
测试工具·单元测试·json·测试覆盖率
ZLongTeng2 天前
EIDE的launch.json文件
json
梦想不只是梦与想2 天前
Python 中的 json 模块
python·json·对象转字符串
步行cgn2 天前
JSON.stringify 详解:把 JavaScript 对象变成 JSON 字符串
开发语言·javascript·json
阿正的梦工坊2 天前
深入理解 JSON-RPC 2.0:轻量级远程调用协议详解
rpc·json
腾讯数据架构师2 天前
任务跑完怎么直接出图表?CubeStudio 任务可视化 ECharts 数据格式实操(CSV/JSON + metric.json,11 种图表一键渲染)
前端·json·echarts·数据可视化
救救孩子把2 天前
结构化输出为何“格式正确、答案错误”?JSON Schema 的能力边界
android·java·json·agent·agent服务
霸道流氓气质3 天前
智能表单生成器:结构化输出契约、JSON Schema 驱动渲染与 EAV/JSONB 混合存储的 Vue3 + Spring AI 生产级实战
人工智能·spring·json
SEO_juper3 天前
Bash 交叉验证 robots.txt 和 sitemap:两个文件自相矛盾,页面永远收录不了
开发语言·python·node.js·json·bash