根据自己txt数据集制作 coco 类似的json文件

自己的数据标签为txt文件,格式如下:

Scene/Video/video0067/image_2860.png 7 1 368 342 100 91 1 468 355 64 72 1 700 216 43 46 1 712 149 35 38 1 771 115 28 32 1 790 140 21 20 1 643 65 11 13

图片路径 该图中框数(根据框数,后面的数5个一组,依次为:标志位 左上角x点 左上角y点 框宽 框高)

txt to coco annotations json代码如下:
 

# -*- coding: UTF-8 -*-
import cv2
import json
import sys
 
# process bar
def process_bar(count, total, status=''):
    bar_len = 60
    filled_len = int(round(bar_len * count / float(total)))
 
    percents = round(100.0 * count / float(total), 1)
    bar = '=' * filled_len + '-' * (bar_len - filled_len)
 
    sys.stdout.write('[%s] %s%s ...%s\r' % (bar, percents, '%', status))
    sys.stdout.flush()
 
root_path = "data_with_box_example/"
images, categories, annotations = [], [], []
 
category_dict = {"people": 1}
 
for cat_n in category_dict:
    categories.append({"supercategory": "", "id": category_dict[cat_n], "name": cat_n})
 
with open("l
评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值