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)

相关推荐
会编程的土豆8 小时前
Gin 中 `c.BindJSON` 与 `c.JSON` 详细讲解
c语言·json·gin
ID_180079054731 天前
企业级实战:淘宝商品详情 API简要说明,json数据返回参考
json
学习3人组1 天前
业务主表+JSON自定义字段
java·spring boot·json
Car121 天前
在vscode中添加一个tasks.json实现 rt thread的scons编译功能
vscode·json·build·scons
学习3人组1 天前
基于 主表 + JSON 自定义字段的条件查询
json
XMYX-02 天前
28 - Go JSON 数据操作
开发语言·golang·json
Promise微笑2 天前
Geo专家于磊:Json-LD优化实战SOP与双核四驱体系
大数据·人工智能·重构·json
专注VB编程开发20年2 天前
json和python元组,列表,字典对比
开发语言·python·json·php
奇树谦2 天前
深度解析 compile_commands.json:源码到目标码映射的核心枢纽
json
alwaysrun2 天前
C++之轻量级JSON序列库jsoncpp
c++·json·编程语言