labelme工具解析json文件

本文介绍如何处理使用labelme工具时遇到的json解析问题。由于json文件编码格式不符,导致出现json.decoder.JSONDecodeError。解决方案包括修改json编码格式或转换文件编码类型,如将utf-8转为ansi或cp936(GBK)。同时,解释了UTF-8和GBK/CP936编码的区别。
摘要由CSDN通过智能技术生成

由于自己的处理数据需求和labelme的直接使用处理还有差距,所以特此开发了新的工具,鸣谢我的合作伙伴,由于labelme工具解析json开源,则采用使得数据组织格式和标准json相同的方式。

解析代码如下:

修改文件为:D:\Users\Pangzhennan\Anaconda3\envs\labelme\Lib\site-packages\labelme\cli\json_to_dataset.py

此处路径同批量操作文件的代码。

# -*- coding: utf-8 -*-
import argparse
import json
import os
import os.path as osp
import warnings

import PIL.Image
import yaml

from labelme import utils
import base64


def main():
    warnings.warn("This script is aimed to demonstrate how to convert the\n"
                  "JSON file to a single image dataset, and not to handle\n"
                  "multiple JSON files to generate a real-use dataset.")
    parser = argparse.ArgumentParser()
    parser.add_argument('json_file')
    parser.add_argument('-o', '--out', default=None)
    args = parser.parse_args()

    json_file = args.j
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值