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 ...
随机推荐
- pve 导入 ova
匆忙记录 Proxmox includes qm importdisk as command. Extract your ova: tar -xvf *.ova Create a new VM wit ...
- PHP var_dump() 函数
var_dump() 函数用于输出变量的相关信息 <?php $b = 3.1; $c = true; var_dump($b, $c); ?> 输出 float(3.1) bool(tr ...
- Vue 一个组件引用另一个组件
有些时候需要这么做,比如,我想在首页加载轮播组件,但是又不想全局注册(因为不是每个页面都需要轮播功能) 方法1: <template> <div> <!-- 3.在tem ...
- Git的使用(1) —— 版本库
1. 简介 Git作为一个分布式版本控制系统,其优点是不需要一直连接远端版本库就可以使用. 故其为实现分布版本控制专门设计了一整套的存储区间和语句,用来实现. (1) 本地版本库:建立在本机磁盘上的文 ...
- 设计模式-Iterator
本文参(chao)考(xi)<图解设计模式> 结城浩 (作者) 杨文轩 (译者) 1.Iterator 模式 迭代器作用于集合,是用来遍历集合元素的对象. 迭代器模式提供一种方法顺序访问一 ...
- Thingsboard Docker关闭后重启服务创建network出错
因为个人想验证一下thingsboard的数据是否是保存在postgres中,就将postgres容器停止,后想重启则无法重启 我干脆将整个系统删除后重新再来一次,在试的时候发现无法重新创建容器 Cr ...
- 服务端高并发分布式架构 ESB 企业服务总线
服务端高并发分布式架构演进之路 - 个人文章 - SegmentFault 思否 https://segmentfault.com/a/1190000018626163 ESB 企业服务总线讲解 ht ...
- Chaos Engineering 混沌工程 Chaos Monkey vs Chaos xxx vs Chaos Blade
Chaos Engineering的历史.原则以及实践https://www.infoq.cn/article/chaos-engineering-the-history-principles-and ...
- git如何删除远程tag?
答: 分为两步: 1. 删除本地tag git tag -d tag-name 2. 删除远程tag git push origin :refs/tags/tag-name
- 廖雪峰Git教程1
转自:https://www.liaoxuefeng.com/wiki/896043488029600 [安装Git] 最早Git是在Linux上开发的,很长一段时间内,Git也只能在Linux和Un ...