coco数据集 解析下载 独立标注转换汇总标注

68 篇文章 27 订阅

目录

coco2017数据集 百度云链接

标签,预测的时候没有background:

json独立标注转汇总标注:


coco2017数据集 百度云链接

数据集包括train数据,val验证数据集,test验证数据集。物体检测和keypoints身体关键点的检测。

链接: https://pan.baidu.com/s/1CTYQFpXy8aGDGEY9yyz-jg 提取码: 4v1i

这个也可能有,没试过:

COCO 数据集的使用,以及下载链接_业精于勤荒于嬉-行成于思而毁于随的博客-CSDN博客_coco下载

http://images.cocodataset.org/zips/train2017.zip 
http://images.cocodataset.org/annotations/annotations_trainval2017.zip

http://images.cocodataset.org/zips/val2017.zip 
http://images.cocodataset.org/annotations/stuff_annotations_trainval2017.zip

http://images.cocodataset.org/zips/test2017.zip 
http://images.cocodataset.org/annotations/image_info_test2017.zip 
 

标签,预测的时候没有background:

class_name = [
    '__background__', 'person', 'bicycle', 'car', 'motorcycle', 'airplane',
    'bus', 'train', 'truck', 'boat', 'traffic light', 'fire hydrant',
    'stop sign', 'parking meter', 'bench', 'bird', 'cat', 'dog', 'horse',
    'sheep', 'cow', 'elephant', 'bear', 'zebra', 'giraffe', 'backpack',
    'umbrella', 'handbag', 'tie', 'suitcase', 'frisbee', 'skis',
    'snowboard', 'sports ball', 'kite', 'baseball bat', 'baseball glove',
    'skateboard', 'surfboard', 'tennis racket', 'bottle', 'wine glass',
    'cup', 'fork', 'knife', 'spoon', 'bowl', 'banana', 'apple', 'sandwich',
    'orange', 'broccoli', 'carrot', 'hot dog', 'pizza', 'donut', 'cake',
    'chair', 'couch', 'potted plant', 'bed', 'dining table', 'toilet', 'tv',
    'laptop', 'mouse', 'remote', 'keyboard', 'cell phone', 'microwave',
    'oven', 'toaster', 'sink', 'refrigerator', 'book', 'clock', 'vase',
    'scissors', 'teddy bear', 'hair drier', 'toothbrush'
]

“背景”,“人”,“自行车”,“汽车”,“摩托车”,“飞机”,

“公共汽车”、“火车”、“卡车”、“船”、“红绿灯”、“消防栓”,

“停车标志”、“停车计时器”、“长凳”、“鸟”、“猫”、“狗”、“马”,

“绵羊”、“奶牛”、“大象”、“熊”、“斑马”、“长颈鹿”、“背包”,

“雨伞”、“手提包”、“领带”、“手提箱”、“飞盘”、“滑雪板”,

“滑雪板”、“运动球”、“风筝”、“棒球棒”、“棒球手套”,

“滑板”、“冲浪板”、“网球拍”、“瓶子”、“酒杯”,

“杯子”,“叉子”,“刀子”,“勺子”,“碗”,“香蕉”,“苹果”,“三明治”,

“橘子”、“西兰花”、“胡萝卜”、“热狗”、“比萨饼”、“甜甜圈”、“蛋糕”,

“椅子”、“沙发”、“盆栽”、“床”、“餐桌”、“卫生间”、“电视”,

“笔记本电脑”、“鼠标”、“遥控器”、“键盘”、“手机”、“微波炉”,

“烤箱”、“烤面包机”、“水槽”、“冰箱”、“书”、“时钟”、“花瓶”,

“剪刀”、“泰迪熊”、“吹风机”、“牙刷”

voc标签:

VOC_CLASSES = ('__background__',  # always index 0
               'aeroplane', 'bicycle', 'bird', 'boat',
               'bottle', 'bus', 'car', 'cat', 'chair',
               'cow', 'diningtable', 'dog', 'horse',
               'motorbike', 'person', 'pottedplant',
               'sheep', 'sofa', 'train', 'tvmonitor')

json独立标注转汇总标注:

import glob
import json
import os

import cv2
import numpy as np

if __name__ == '__main__':

    json_dict = {"images": [], "type": "instances", "annotations": [], "categories": []}

    categories = {'good':0}

    json_file='val.json'
    dir_ar=''

    img_to = r'D:\work\lbg\yolov5_track\data_fire_smoke\val/'

    from_labels = glob.glob(img_to + "/*.json")
    bnd_id=0
    for f_label_file in from_labels:
        base_name = os.path.basename(f_label_file)
        to_val = json.load(open(f_label_file, 'r'))
        imagePath = to_val['imagePath']
        to_shapes = to_val['shapes']
        img = cv2.imread(img_to + imagePath)

        image_id = ""
        height,width=img.shape[:2]
        image = {"file_name": img_to + imagePath, "height": height, "width": width, "id": image_id, }
        # json_dict["images"].append(image)

        for to_shape in to_shapes:
            box2 = to_shape['points'][0] + to_shape['points'][1]

            points = np.array(to_shape["points"])
            xmin = (min(points[:, 0]) if min(points[:, 0]) > 0 else 0)
            xmax = (max(points[:, 0]) if max(points[:, 0]) > 0 else 0)
            ymin = (min(points[:, 1]) if min(points[:, 1]) > 0 else 0)
            ymax = (max(points[:, 1]) if max(points[:, 1]) > 0 else 0)
            assert xmax > xmin
            assert ymax > ymin
            # cv2.rectangle(img, (int(xmin), int(ymin)), (int(xmax), int(ymax)), (0, 0, 255), 2)

            category_id = 0

            o_width = abs(xmax - xmin)
            o_height = abs(ymax - ymin)
            ann = {"area": o_width * o_height, "iscrowd": 0, "image_id": image_id, "bbox": [xmin, ymin, o_width, o_height], "category_id": category_id, "id": bnd_id, "ignore": 0, "segmentation": [], }
            json_dict["annotations"].append(ann)
            bnd_id = bnd_id + 1

        for cate, cid in categories.items():
            cat = {"supercategory": "none", "id": cid, "name": cate}
            json_dict["categories"].append(cat)

        os.makedirs(os.path.dirname(json_file), exist_ok=True)
        json_fp = open(json_file, "w")
        json_str = json.dumps(json_dict)
        json_fp.write(json_str)
        json_fp.close()

  • 1
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 打赏
    打赏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

AI算法网奇

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

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

余额充值