labelme数据转mask_rcnn数据格式

# coding: utf-8
import argparse
import json
import os
import os.path as osp
import warnings
import numpy as np
import PIL.Image
import yaml
from labelme import utils def main():
json_file='E:/数据集/json/'
list = os.listdir(json_file)
for i in range(0, len(list)):
path = os.path.join(json_file, list[i])
if os.path.isfile(path):
data = json.load(open(path))
img = utils.img_b64_to_arr(data['imageData'])
lbl, lbl_names = utils.labelme_shapes_to_label(img.shape, data['shapes'])
captions = ['%d: %s' % (l, name) for l, name in enumerate(lbl_names)]
lbl_viz = utils.draw_label(lbl, img, captions)
out_dir = osp.basename(list[i]).replace('.', '_')
out_dir = osp.join(osp.dirname(list[i]), out_dir)
if not osp.exists(out_dir):
os.mkdir(out_dir)
PIL.Image.fromarray(img).save(osp.join(out_dir, 'img.png'))
PIL.Image.fromarray(lbl).save(osp.join(out_dir, 'label.png'))
PIL.Image.fromarray(lbl_viz).save(osp.join(out_dir, 'label_viz.png'))
with open(osp.join(out_dir, 'label_names.txt'), 'w') as f:
for lbl_name in lbl_names:
f.write(lbl_name + '\n')
warnings.warn('info.yaml is being replaced by label_names.txt')
info = dict(label_names=lbl_names)
with open(osp.join(out_dir, 'info.yaml'), 'w') as f:
yaml.safe_dump(info, f, default_flow_style=False)
print('Saved to: %s' % out_dir) # In[2]: if __name__ == '__main__':
main()

Labelme数据转mask_rcnn数据格式的更多相关文章

  1. 关于form表单或者Ajax向后台发送数据时,数据格式的探究

    最近在做一个资产管理系统项目,其中有一个部分是客户端向服务端发送采集到的数据的,服务端是Django写的,客户端需要用rrequests模块模拟发送请求 假设发送的数据是这样的: data = {'s ...

  2. hive 压缩 差不多出来数据 各种压缩 数据格式

    待学习 DeprecatedLzoTextInputFormat

  3. treeGrid树形数据表格的json数据格式说明

    在使用easyUI 的treeGrid的时候,很多时候我们从数据库取出来的数据treeGrid却不能读取显示成一个树:如下 { menuCode: "a00", menuName: ...

  4. 计算机系统之汇编---IA32处理器数据格式及数据操作

    计算机系统之汇编---IA32处理器数据格式及数据操作 IA32数据格式: Intel用术语"字"表示16位数据类型,因此.称32位数为"双字",称64位数为& ...

  5. NPOI操作EXCEL(三)——反射机制进行excel表格数据的解析

    我们先来回忆回忆上篇文章讲到的通过xml配置文件实现excel批量模板解析的整体思路: 1.对每个excel模板制定xml配置规则集,实现xml配置文件的解析服务 2.为每个excel模板制定DTO, ...

  6. MICAPS数据文件格式

    MICAPS系统的数据结构是建立在文件系统基础上的.其特点是: l  利用目录来区分不同的数据来源.要素和层次,即不同的数据来源.要素和层次的数据要放在不同的目录中.同一目录中的数据只能有时次或时效上 ...

  7. SpringMVC 数据转换 & 数据格式化 & 数据校验

    数据绑定流程 1. Spring MVC 主框架将 ServletRequest 对象及目标方法的入参实例传递给 WebDataBinderFactory 实例,以创建 DataBinder 实例对象 ...

  8. [整理]S-Record数据格式解析

    S-Reord是一种由摩托罗拉公司创建的文件格式(不得不说,摩托罗拉厉害啊,SPI和S-Record都是他们创造的).S-Record的基本字符为ASCII字符,用以表示相应的十六进制数据.该数据格式 ...

  9. Dojo Data Store——统一数据访问接口

    原文地址:http://www.infoq.com/cn/articles/wq-dojo-data-store 无论在传统的桌面应用还是在主流的互联网应用中,数据始终占据着软件应用中的核心地位.当下 ...

随机推荐

  1. 适用于在线服务的A/B测试方法论

    适用于在线服务的A/B测试方法论 简介: 这篇文章旨在介绍适用于为在线服务进行A/B测试(A/B Test)的方法论.中文网络中目前还缺乏全面的入门级介绍. 我将首先讨论在线服务业进行A/B测试所考虑 ...

  2. 《The One !团队》:BETA Scrum metting2

    项目 内容 作业所属课程 所属课程 作业要求 作业要求 团队名称 < The One !> 作业学习目标 (1)掌握软件黑盒测试技术:(2)学会编制软件项目总结PPT.项目验收报告:(3) ...

  3. CheckList 如何梳理可减少上线的验证时间(总结篇)

    对CheckList的执行发起的思考? (1)功能越来越多,CheckList越补充越多,执行CheckList时间越来越长,如何减少上线的验证时间?(2)减少上线验证的时间外,如何保证质量?上线后少 ...

  4. 查看mysql日志文件

    开启mysql日志 /etc/mysql/mysql.conf.d/mysqld.cnf sudo vi /etc/mysql/mysql.conf.d/mysqld.cnf 找到第68,69行 前面 ...

  5. CloudCompare 的简单的使用说明

    来自:https://blog.csdn.net/datase/article/details/79797795 File open:打开 save:保存 Global Shift settings: ...

  6. 错误信息: The server cannot or will not process the request due to something that is perceived to be a client error

    错误原因:在提交的表单中有 date 类型的数据,也就是不能传输日期类型的数据. 嗯!我知道,去吧!

  7. Zookeeper选举(fastleaderelection算法)

    1.选举相关概念: 选票:(myid,zxid,当前节点选取轮次,被推举服务器选举轮次,状态(looking)). 选举发生情况:启动时选举,运行时选举. 外部投票:其他服务器发送来的投票. 内部投票 ...

  8. Fiddler拦截请求

    bpu (breakpoint url ) Create a request breakpoint for URIs containing the specified string. Setting ...

  9. Linux 常用命令1 pwd、ls、cd、tab、清屏、重定向、转义、管道、touch、mkdir、tree、cat、more、rmdir、rm、grep、help、man、history、find、cp、mv、tar、gz

    版权声明:本文为博主引用文章,未经博主及作者允许不得转载.  声明: 涉及的命令:pwd.ls.cd.tab.清屏.重定向.转义.管道.touch.mkdir.tree.cat.more.rmdir. ...

  10. H3CNE学习1 课程简介

    一.认证对比 二.企业网架构