labelme2coco问题:TypeError: Object of type 'int64' is not JSON serializable
最近在做MaskRCNN
在自己的数据(labelme)转为COCOjson格式遇到问题:TypeError: Object of type 'int64' is not JSON serializable
原因是numpy的数据类型不能被json兼容
最简单的做法是自己写一个序列类
class MyEncoder(json.JSONEncoder):
def default(self, obj):
if isinstance(obj, numpy.integer):
return int(obj)
elif isinstance(obj, numpy.floating):
return float(obj)
elif isinstance(obj, numpy.ndarray):
return obj.tolist()
else:
return super(MyEncoder, self).default(obj)
it looks like
jsonis telling you that anintisn't serializable, but really, it's telling you that this particular np.int32 (or whatever type you actually have) isn't serializable.The easiest workaround here is probably to write your own serializer
labelme2coco问题:TypeError: Object of type 'int64' is not JSON serializable的更多相关文章
- TypeError: Object of type 'int64' is not JSON serializable
错误类型:TypeError: Object of type 'int64' is not JSON serializable 错误场景:对Numpy和Pandas结果进行json.dumps报错 错 ...
- TypeError: Object of type 'int32' is not JSON serializable ——已解决
将模型用flask封装,返回json时报错:TypeError: Object of type 'int32' is not JSON serializable 网上搜索出的解决方案:重写json.J ...
- TypeError: Object of type 'int32' is not JSON serializable
将模型用flask封装,返回json时报错:TypeError: Object of type 'int32' is not JSON serializable 网上搜索出的解决方案:重写json.J ...
- TypeError: Object of type 'ListSerializer' is not JSON serializable
问题: 解决:ser.data是json数据,你想要的
- typeerror object of type ‘decimal‘ is not json serializable jsonify
当使用flask的jsonify返回json数据时,由于数据库有些字段类型使用decimal,而jsonify无法处理 解决方案 导入下面的包即可解决 pip install simplejson
- TypeError: Object of type 'datetime' is not JSON serializable
我的描述:我在flask框架中引用orm查数据库并返回数据,出现此类问题,如下图: 解决方案: 1.从表面意思看,就是说datetime时间类型无法被序列化.于是我百度了网上的同事的解答,大多说是时间 ...
- celery 4.1下报kombu.exceptions.EncodeError: Object of type 'bytes' is not JSON serializable 处理方式
#python代码如下 from celery import Celeryimport subprocess app = Celery('tasks', broker='redis://localho ...
- Object of type 'ListSerializer' is not JSON serializable “listserializer”类型的对象不可JSON序列化
Object of type 'ListSerializer' is not JSON serializable “listserializer”类型的对象不可JSON序列化 一般原因为 序列化的对象 ...
- Object of type 'ndarray' is not JSON serializable
Object of type 'ndarray' is not JSON serializable import numpy as np import json arr=np.asarray([345 ...
随机推荐
- jmeter非GUI界面常用参数详解
压力测试或者接口自动化测试常常用到的jmeter非GUI参数,以下记录作为以后的参考 讲解:非GUI界面,压测参数讲解(欢迎加入QQ群一起讨论性能测试:537188253) -h 帮助 -n 非GUI ...
- 读取中文文件到CString
CString strFileName = _T("D:\\ai\\100.json"); CFile file; file.Open(strFileName, CFile:: ...
- 大数据学习之路之Hadoop
Hadoop介绍 一.简介 Hadoop是一个开源的分布式计算平台,用于存储大数据,并使用MapReduce来处理.Hadoop擅长于存储各种格式的庞大的数据,任意的格式甚至非结构化的处理.两个核心: ...
- etcd,flannel,docker relationship---and k8s
journalctl -xe voidcn.com/article/p-qufvdmpq-bqn.html etcd more etcd.confETCD_NAME=default ETCD_DATA ...
- TThread.Queue和TThread.Synchronize的区别
TThread.Queue和TThread.Synchronize的区别 效果上:二者的作用都是让业务代码在主线程中执行,差别: Synchronize是阻塞,Queue是非阻塞 代码上 两个方法最终 ...
- CheatEngine查看PE header
先打开进程,炉石传说. 然后选择MemoryViewer 在MemoryViewer界面,Tools菜单,然后选择Dissect PE headers 然后查看mono.dll的信息 0x357A0是 ...
- H2数据库函数及数据类型概述
一.H2数据库常用数据类型 INT类型:对应java.lang.Integer REAL类型:对应java.lang.Float DOUBLE类型:对应java.lang.Double DECIMAL ...
- FFmpeg编译:mac下编译iOS平台的FFmpeg库(支持armv7, arm64, i386, x86_64)
环境:FFmpeg 3.4.6Xcode 10.3macOS 10.14.6iOS SDK 12.4 一.准备工作 1. 下载FFmpeg我这里使用的是3.4.6版本的FFmpeg,可以从FFmpeg ...
- mongodb的开机自启动
一.背景 Linux轻松的在rc.local中写上启动脚本,reboot~发现没有启动成功.这不科学啊,查看日志发现“permission denied” 二.解决 Linux系统下,使用自定配置文件 ...
- 小D课堂 - 零基础入门SpringBoot2.X到实战_第三节SpringBoot热部署devtool和配置文件自动注入实战_14、SpringBoot2.x使用Dev-tool热部署
学习笔记 热部署 每次修改了代码都需要关闭应用重启 热部署就是有一个插件会监听我们应用的代码文件是否有变化,如果有变化就会有其他的类加载器加载 主要的依赖 复制到我们的pom.xml里面 安装完成ja ...