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?json?is telling you that an?intisn'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

?

轉載于:https://www.cnblogs.com/BambooEatPanda/p/10444332.html

本文來自互聯網用戶投稿,該文觀點僅代表作者本人,不代表本站立場。本站僅提供信息存儲空間服務,不擁有所有權,不承擔相關法律責任。
如若轉載,請注明出處:http://www.pswp.cn/news/278262.shtml
繁體地址,請注明出處:http://hk.pswp.cn/news/278262.shtml
英文地址,請注明出處:http://en.pswp.cn/news/278262.shtml

如若內容造成侵權/違法違規/事實不符,請聯系多彩編程網進行投訴反饋email:809451989@qq.com,一經查實,立即刪除!

相關文章

如何在Windows 10的命令提示符中更改目錄

One of the first things you’ll need to learn as you become more familiar with Command Prompt on Windows 10 is how to change directories in the operating system’s file system. There are a few ways you can do this, so we’ll walk you through them. 隨著您對…

jQuery 購物車

html代碼 <!--shoppingCar start--> <table id"TB"> <tr> <td colspan"7" class"title"> <div class"img_box"> <div class"logo_box"> <img src"img/jd…

MySQL優化總結

2019獨角獸企業重金招聘Python工程師標準>>> 從這幾天看MySQL性能優化來看&#xff0c;基本的思路就是分分分&#xff0e;&#xff0e;&#xff0e; 1&#xff0c;分讀&#xff0c;用緩存來分攤讀表的壓力; 2&#xff0c;讀寫分離&#xff0c;主從分離&#xff0c;寫…

瘋狂java講義

封裝&#xff1a; 封裝&#xff1a;將對象狀態信息隱藏在對象內部&#xff0c;不允許外部程序直接訪問對象內部信息&#xff0c;而是用類所提供的方法訪問和操作。訪問控制符&#xff1a;private&#xff08;當前類訪問權&#xff09; ,protected&#xff08;子類訪問&#xff…

將背景色添加到Word 2007文檔中

Instead of using the standard white background with Word documents, here is how to add some background color to spice up your documents. 代替在Word文檔中使用標準的白色背景&#xff0c;這是如何添加一些背景顏色來為文檔增添色彩。 Open your word document and ch…

jquery實現增刪改(偽)-老男孩作業day13

使用jquery進行&#xff0c;文件的編寫&#xff0c;實現自增id,刪除&#xff0c;添加&#xff0c;編輯模式。 jquery放在本地&#xff0c;src"jquery_js.js" 可以改成其他&#xff0c;或者在線的路徑 readme<!DOCTYPE html> <html lang"en"> &…

uoj#119. 【UR #8】決戰圓錐曲線(線段樹+復雜度分析)

題解 傳送門 題解 然而要我來說我感覺只是個爆搜啊…… //minamoto #include<bits/stdc.h> #define R register #define ll long long #define ls (p<<1) #define rs (p<<1|1) #define fp(i,a,b) for(R int ia,Ib1;i<I;i) #define fd(i,a,b) for(R int ia…

如何在Raspberry Pi上設置兩因素身份驗證

Kiklas/ShutterstockKiklas /快門The Raspberry Pi is everywhere now, which is why it’s caught the eye of threat actors and cybercriminals. We’ll show you how to secure your Pi with two-factor authentication. Raspberry Pi現在無處不在&#xff0c;這就是為什么…

Laravel Passport里的授權類型介紹

本文來自pilishen.com----原文鏈接; 歡迎來和pilishen一起學習php&Laravel&#xff1b;學習群&#xff1a;109256050OAuth2是一個安全框架&#xff0c;控制著程序受保護部分的準入&#xff0c;主要是控制不同的客戶端如何來調取API&#xff0c;保證它們在請求相應資源的時候…

vue 開發環境搭建

1.創建vue項目 1.node js 生成項目&#xff0c;編譯項目 2.hbuilder 開發環境 1.下載安裝node js http://nodejs.cn/download/ 確認是否安裝成功 如果安裝不了 代碼錯誤2503 解決方法&#xff1a; 管理員命令運行cmd; cd\ cd C:\Users\Administrator\Desktop msiexec/package n…

iphone視圖放大_如何將iPhone用作放大鏡

iphone視圖放大It’s a common problem: Some things are just too hard to see. Usually, they’re too far away, too dark, or too small. With a feature called Magnifier, your iPhone can function as a magnifying glass and sight aid. Here’s how to use it. 這是一…

chmod權限

本文引用:https://www.cnblogs.com/zhangym/p/5826200.html linux數字權限解釋 644 第一位代表文件所有者的權限,第二位代表同組用戶的權限&#xff0c;第三位代表其他用戶的權限. 讀取權限等于4,用r表示;寫入權限2,用w表示;執行權限1,用x表示. 通過4、2、1組合,得到以下幾種權…

輸出最大值MXNet實現

網絡結構&#xff0c;輸入為2個數&#xff0c;先經過10個節點的全連接層&#xff0c;再經過10個節點的ReLu&#xff0c;再經過10個節點的全連接層&#xff0c;再經過1個節點的全連接層&#xff0c;最后輸出。 #-*-coding:utf-8-*- import logging import math import random im…

discord linux_如何在Discord中應用文本格式

discord linuxDiscord allows for text-and audio-based chatting between gamers and other like-minded individuals. If you want to make a bigger impact on Discord, you can use formatting to jazz up your text-based messages. Here’s how. Discord允許游戲玩家和其…

一張圖看懂阿里云網絡產品[十二]云企業網

2019獨角獸企業重金招聘Python工程師標準>>> 摘要&#xff1a; 阿里云致力于為用戶提供優質、高效、穩定的網絡傳輸環境&#xff0c;云企業網&#xff08;Cloud Enterprise Network&#xff09;將提供一種能夠快速構建混合云和分布式業務系統的全球網絡&#xff0c;…

# 2019-2020.3 《java程序設計》第一周學習總結

2019-2020-3 《Java 程序設計》第一周學習總結 在本周的學習中&#xff0c;學習到了好多也收獲了好多&#xff0c;從最基礎的安裝虛擬機開始&#xff0c;根據老師的博客中的教程一步一步的進行&#xff0c;在這過程中也遇到了好多問題&#xff0c;因為是初步接觸Linux系統&…

聊聊Java反射

反射是Java最重要的特性。通過Java反射可以在運行時知道一個類的所有成員和方法&#xff0c;知道一個對象的類類型、成員和方法的所有信息&#xff0c;進而調用對象的方法或生成對象的代理或包裝類。Java是面向對象語言&#xff0c;除了靜態變量或原始數據類型外都是完全面向對…

01. 把存儲過程結果集SELECT INTO到臨時表

原文:01. 把存儲過程結果集SELECT INTO到臨時表在開發過程中&#xff0c;很多時候要把結果集存放到臨時表中&#xff0c;常用的方法有兩種。 一. SELECT INTO 1. 使用select into會自動生成臨時表&#xff0c;不需要事先創建 select * into #temp from sysobjects select * fro…

day5學python 基礎+裝飾器內容

基礎裝飾器內容 遞歸特性# 1.必須有一個明確的結束條件# 2.每次進入更深一層遞歸時&#xff0c;問題規模相比上次遞歸應有所減少# 3.遞歸效率不高 def run(n):print(n)if int(n/2)>0:return run(n / 2)print("-->",n) run(10) 局部變量與全局變量知識 1.全局變…

如何在Windows 10上跳過回收站以刪除文件

Windows 10 normally sends files you delete to the Recycle Bin. They’ll be kept until you empty it—or, in some cases, until Windows 10 automatically empties your Recycle Bin. Here’s how to skip the Recycle Bin and delete files immediately. Windows 10通常…