COCO和VOC数据集的转换:VOC2COCO和COCO2VOC

2023-11-05

VOC2COCO

方法一

参考自博客
数据格式的转换实际是将VOC的annotation标注文件转化为COCO的json文件
注:下面代码包含通过txt文件生成通过文件夹生成两种方法
1 通过txt文件生成 :按照VOC数据集下ImageSets/Main中的已划分好的trian.txt,test.txt,val.txt进行转化,生成对应的3个json文件;
2 通过文件夹生成 :将annotation文件夹里的xml文件全部转化成一个json文件,一个annotation文件夹转化成一个json文件,要想生成3个trian.json,test.json,val.json文件,需要有3个对应的annotation文件夹(可手动按比例创建3个annotation文件夹,也可写个程序划分annotation文件夹)

import xml.etree.ElementTree as ET
import os
import json
 
coco = dict()
coco['images'] = []
coco['type'] = 'instances'
coco['annotations'] = []
coco['categories'] = []
 
category_set = dict()
image_set = set()
#注意具体应用中,类别索引是从0开始,还是从1开始。
#若从1开始(包含背景的情况)下一句代码需改成category_item_id = 0 
category_item_id = -1
image_id = 20180000000
annotation_id = 0
 
def addCatItem(name):
    global category_item_id
    category_item = dict()
    category_item['supercategory'] = 'none'
    category_item_id += 1
    category_item['id'] = category_item_id
    category_item['name'] = name
    coco['categories'].append(category_item)
    category_set[name] = category_item_id
    return category_item_id
 
def addImgItem(file_name, size):
    global image_id
    if file_name is None:
        raise Exception('Could not find filename tag in xml file.')
    if size['width'] is None:
        raise Exception('Could not find width tag in xml file.')
    if size['height'] is None:
        raise Exception('Could not find height tag in xml file.')
    image_id += 1
    image_item = dict()
    image_item['id'] = image_id
    image_item['file_name'] = file_name
    image_item['width'] = size['width']
    image_item['height'] = size['height']
    coco['images'].append(image_item)
    image_set.add(file_name)
    return image_id
 
def addAnnoItem(object_name, image_id, category_id, bbox):
    global annotation_id
    annotation_item = dict()
    annotation_item['segmentation'] = []
    seg = []
    # bbox[] is x,y,w,h
    # left_top
    seg.append(bbox[0])
    seg.append(bbox[1])
    # left_bottom
    seg.append(bbox[0])
    seg.append(bbox[1] + bbox[3])
    # right_bottom
    seg.append(bbox[0] + bbox[2])
    seg.append(bbox[1] + bbox[3])
    # right_top
    seg.append(bbox[0] + bbox[2])
    seg.append(bbox[1])
 
    annotation_item['segmentation'].append(seg)
 
    annotation_item['area'] = bbox[2] * bbox[3]
    annotation_item['iscrowd'] = 0
    annotation_item['ignore'] = 0
    annotation_item['image_id'] = image_id
    annotation_item['bbox'] = bbox
    annotation_item['category_id'] = category_id
    annotation_id += 1
    annotation_item['id'] = annotation_id
    coco['annotations'].append(annotation_item)
 
def _read_image_ids(image_sets_file):
    ids = []
    with open(image_sets_file) as f:
        for line in f:
            ids.append(line.rstrip())
    return ids
 
"""通过txt文件生成"""
#split ='train' 'va' 'trainval' 'test'
def parseXmlFiles_by_txt(data_dir,json_save_path,split='train'):
    print("hello")
    labelfile=split+".txt"
    image_sets_file = data_dir + "/ImageSets/Main/"+labelfile
    ids=_read_image_ids(image_sets_file)
 
    for _id in ids:
        xml_file=data_dir + f"/Annotations/{_id}.xml"
 
        bndbox = dict()
        size = dict()
        current_image_id = None
        current_category_id = None
        file_name = None
        size['width'] = None
        size['height'] = None
        size['depth'] = None
 
        tree = ET.parse(xml_file)
        root = tree.getroot()
        if root.tag != 'annotation':
            raise Exception('pascal voc xml root element should be annotation, rather than {}'.format(root.tag))
 
        # elem is <folder>, <filename>, <size>, <object>
        for elem in root:
            current_parent = elem.tag
            current_sub = None
            object_name = None
 
            if elem.tag == 'folder':
                continue
 
            if elem.tag == 'filename':
            #若xml文件名和文件里'filename'标签的内容不一致,而xml文件名是正确的,
            #即,(标注错误),则用xml文件名赋给file_name,即,下面一句代码换成file_name = _id + '.jpg'
                file_name = elem.text
                if file_name in category_set:
                    raise Exception('file_name duplicated')
 
            # add img item only after parse <size> tag
            elif current_image_id is None and file_name is not None and size['width'] is not None:
                if file_name not in image_set:
                    current_image_id = addImgItem(file_name, size)
                    print('add image with {} and {}'.format(file_name, size))
                else:
                    raise Exception('duplicated image: {}'.format(file_name))
                    # subelem is <width>, <height>, <depth>, <name>, <bndbox>
            for subelem in elem:
                bndbox['xmin'] = None
                bndbox['xmax'] = None
                bndbox['ymin'] = None
                bndbox['ymax'] = None
 
                current_sub = subelem.tag
                if current_parent == 'object' and subelem.tag == 'name':
                    object_name = subelem.text
                    if object_name not in category_set:
                        current_category_id = addCatItem(object_name)
                    else:
                        current_category_id = category_set[object_name]
 
                elif current_parent == 'size':
                    if size[subelem.tag] is not None:
                        raise Exception('xml structure broken at size tag.')
                    size[subelem.tag] = int(subelem.text)
 
                # option is <xmin>, <ymin>, <xmax>, <ymax>, when subelem is <bndbox>
                for option in subelem:
                    if current_sub == 'bndbox':
                        if bndbox[option.tag] is not None:
                            raise Exception('xml structure corrupted at bndbox tag.')
                        bndbox[option.tag] = int(option.text)
 
                # only after parse the <object> tag
                if bndbox['xmin'] is not None:
                    if object_name is None:
                        raise Exception('xml structure broken at bndbox tag')
                    if current_image_id is None:
                        raise Exception('xml structure broken at bndbox tag')
                    if current_category_id is None:
                        raise Exception('xml structure broken at bndbox tag')
                    bbox = []
                    # x
                    bbox.append(bndbox['xmin'])
                    # y
                    bbox.append(bndbox['ymin'])
                    # w
                    bbox.append(bndbox['xmax'] - bndbox['xmin'])
                    # h
                    bbox.append(bndbox['ymax'] - bndbox['ymin'])
                    print('add annotation with {},{},{},{}'.format(object_name, current_image_id, current_category_id,
                                                                   bbox))
                    addAnnoItem(object_name, current_image_id, current_category_id, bbox)
    json.dump(coco, open(json_save_path, 'w'))
 
"""直接从xml文件夹中生成"""
def parseXmlFiles(xml_path,json_save_path):
    for f in os.listdir(xml_path):
        if not f.endswith('.xml'):
            continue
 
        bndbox = dict()
        size = dict()
        current_image_id = None
        current_category_id = None
        file_name = None
        size['width'] = None
        size['height'] = None
        size['depth'] = None
 
        xml_file = os.path.join(xml_path, f)
        print(xml_file)
 
        tree = ET.parse(xml_file)
        root = tree.getroot()
        if root.tag != 'annotation':
            raise Exception('pascal voc xml root element should be annotation, rather than {}'.format(root.tag))
 
        # elem is <folder>, <filename>, <size>, <object>
        for elem in root:
            current_parent = elem.tag
            current_sub = None
            object_name = None
 
            if elem.tag == 'folder':
                continue
 
            if elem.tag == 'filename':
                file_name = elem.text
                if file_name in category_set:
                    raise Exception('file_name duplicated')
 
            # add img item only after parse <size> tag
            elif current_image_id is None and file_name is not None and size['width'] is not None:
                if file_name not in image_set:
                    current_image_id = addImgItem(file_name, size)
                    print('add image with {} and {}'.format(file_name, size))
                else:
                    raise Exception('duplicated image: {}'.format(file_name))
                    # subelem is <width>, <height>, <depth>, <name>, <bndbox>
            for subelem in elem:
                bndbox['xmin'] = None
                bndbox['xmax'] = None
                bndbox['ymin'] = None
                bndbox['ymax'] = None
 
                current_sub = subelem.tag
                if current_parent == 'object' and subelem.tag == 'name':
                    object_name = subelem.text
                    if object_name not in category_set:
                        current_category_id = addCatItem(object_name)
                    else:
                        current_category_id = category_set[object_name]
 
                elif current_parent == 'size':
                    if size[subelem.tag] is not None:
                        raise Exception('xml structure broken at size tag.')
                    size[subelem.tag] = int(subelem.text)
 
                # option is <xmin>, <ymin>, <xmax>, <ymax>, when subelem is <bndbox>
                for option in subelem:
                    if current_sub == 'bndbox':
                        if bndbox[option.tag] is not None:
                            raise Exception('xml structure corrupted at bndbox tag.')
                        bndbox[option.tag] = int(option.text)
 
                # only after parse the <object> tag
                if bndbox['xmin'] is not None:
                    if object_name is None:
                        raise Exception('xml structure broken at bndbox tag')
                    if current_image_id is None:
                        raise Exception('xml structure broken at bndbox tag')
                    if current_category_id is None:
                        raise Exception('xml structure broken at bndbox tag')
                    bbox = []
                    # x
                    bbox.append(bndbox['xmin'])
                    # y
                    bbox.append(bndbox['ymin'])
                    # w
                    bbox.append(bndbox['xmax'] - bndbox['xmin'])
                    # h
                    bbox.append(bndbox['ymax'] - bndbox['ymin'])
                    print('add annotation with {},{},{},{}'.format(object_name, current_image_id, current_category_id,
                                                                   bbox))
                    addAnnoItem(object_name, current_image_id, current_category_id, bbox)
    json.dump(coco, open(json_save_path, 'w'))
 
 
 
if __name__ == '__main__':
    #通过txt文件生成
    # voc_data_dir="E:/VOCdevkit/VOC2007"#整个数据集文件夹所在路径
    # json_save_path="E:/VOCdevkit/voc2007trainval.json"#生成后的文件存放路径和生成文件的名字
    # parseXmlFiles_by_txt(voc_data_dir,json_save_path,"trainval")
 
    #通过文件夹生成
    ann_path="E:/VOCdevkit/VOC2007/Annotations"
    json_save_path="E:/VOCdevkit/test.json"
    parseXmlFiles(ann_path,json_save_path)
 
 
 

方法二
与方法一的区别:可根据需求调节划分训练,测试,验证数据集的比例,通过一个包含全部xml的annotion文件夹,直接生成3个json文件

# coding:utf-8
# 运行前请先做以下工作:
# pip install lxml
# 将所有的图片及xml文件存放到xml_dir指定的文件夹下,并将此文件夹放置到当前目录下
#

import os
import glob
import json
import shutil
import numpy as np
import xml.etree.ElementTree as ET

START_BOUNDING_BOX_ID = 1
save_path = "."


def get(root, name):
    return root.findall(name)


def get_and_check(root, name, length):
    vars = get(root, name)
    if len(vars) == 0:
        raise NotImplementedError('Can not find %s in %s.' % (name, root.tag))
    if length and len(vars) != length:
        raise NotImplementedError('The size of %s is supposed to be %d, but is %d.' % (name, length, len(vars)))
    if length == 1:
        vars = vars[0]
    return vars


def convert(xml_list, json_file):
    json_dict = {"images": [], "type": "instances", "annotations": [], "categories": []}
    categories = pre_define_categories.copy()
    bnd_id = START_BOUNDING_BOX_ID
    all_categories = {}
    for index, line in enumerate(xml_list):
        # print("Processing %s"%(line))
        xml_f = line
        tree = ET.parse(xml_f)
        root = tree.getroot()

        filename = os.path.basename(xml_f)[:-4] + ".jpg"
        image_id = 20190000001 + index
        size = get_and_check(root, 'size', 1)
        width = int(get_and_check(size, 'width', 1).text)
        height = int(get_and_check(size, 'height', 1).text)
        image = {'file_name': filename, 'height': height, 'width': width, 'id': image_id}
        json_dict['images'].append(image)
        #  Currently we do not support segmentation
        segmented = get_and_check(root, 'segmented', 1).text
        assert segmented == '0'
        for obj in get(root, 'object'):
            category = get_and_check(obj, 'name', 1).text
            if category in all_categories:
                all_categories[category] += 1
            else:
                all_categories[category] = 1
            if category not in categories:
                if only_care_pre_define_categories:
                    continue
                new_id = len(categories) + 1
                print(
                    "[warning] category '{}' not in 'pre_define_categories'({}), create new id: {} automatically".format(
                        category, pre_define_categories, new_id))
                categories[category] = new_id
            category_id = categories[category]
            bndbox = get_and_check(obj, 'bndbox', 1)
            xmin = int(float(get_and_check(bndbox, 'xmin', 1).text))
            ymin = int(float(get_and_check(bndbox, 'ymin', 1).text))
            xmax = int(float(get_and_check(bndbox, 'xmax', 1).text))
            ymax = int(float(get_and_check(bndbox, 'ymax', 1).text))
            assert (xmax > xmin), "xmax <= xmin, {}".format(line)
            assert (ymax > ymin), "ymax <= ymin, {}".format(line)
            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': 'food', 'id': cid, 'name': cate}
        json_dict['categories'].append(cat)
    json_fp = open(json_file, 'w')
    json_str = json.dumps(json_dict)
    json_fp.write(json_str)
    json_fp.close()
    print("------------create {} done--------------".format(json_file))
    print("find {} categories: {} -->>> your pre_define_categories {}: {}".format(len(all_categories),
                                                                                  all_categories.keys(),
                                                                                  len(pre_define_categories),
                                                                                  pre_define_categories.keys()))
    print("category: id --> {}".format(categories))
    print(categories.keys())
    print(categories.values())


if __name__ == '__main__':
    # 定义你自己的类别
    classes = ['aaa', 'bbb', 'ccc', 'ddd', 'eee', 'fff']
    pre_define_categories = {}
    for i, cls in enumerate(classes):
        pre_define_categories[cls] = i + 1
    # 这里也可以自定义类别id,把上面的注释掉换成下面这行即可
    # pre_define_categories = {'a1': 1, 'a3': 2, 'a6': 3, 'a9': 4, "a10": 5}
    only_care_pre_define_categories = True  # or False

    # 保存的json文件
    save_json_train = 'train_food.json'
    save_json_val = 'val_food.json'
    save_json_test = 'test_food.json'

    # 初始文件所在的路径
    xml_dir = "./image_and_xml"
    xml_list = glob.glob(xml_dir + "/*.xml")
    xml_list = np.sort(xml_list)

    # 打乱数据集
    np.random.seed(100)
    np.random.shuffle(xml_list)

    # 按比例划分打乱后的数据集
    train_ratio = 0.8
    val_ratio = 0.1
    train_num = int(len(xml_list) * train_ratio)
    val_num = int(len(xml_list) * val_ratio)
    xml_list_train = xml_list[:train_num]
    xml_list_val = xml_list[train_num: train_num+val_num]
    xml_list_test = xml_list[train_num+val_num:]

    # 将xml文件转为coco文件,在指定目录下生成三个json文件(train/test/food)
    convert(xml_list_train, save_json_train)
    convert(xml_list_val, save_json_val)
    convert(xml_list_test, save_json_test)

    # # 将图片按照划分后的结果进行存放
    # if os.path.exists(save_path + "/annotations"):
    #     shutil.rmtree(save_path + "/annotations")
    # os.makedirs(save_path + "/annotations")
    # if os.path.exists(save_path + "/images_divide/train"):
    #     shutil.rmtree(save_path + "/images_divide/train")
    # os.makedirs(save_path + "/images_divide/train")
    # if os.path.exists(save_path + "/images_divide/val"):
    #     shutil.rmtree(save_path + "/images_divide/val")
    # os.makedirs(save_path + "/images_divide/val")
    # if os.path.exists(save_path + "/images_divide/test"):
    #     shutil.rmtree(save_path + "/images_divide/test")
    # os.makedirs(save_path + "/images_divide/test")

    # # 按需执行,生成3个txt文件,存放相应的文件名称
    # f1 = open("./train.txt", "w")
    # for xml in xml_list_train:
    #     img = xml[:-4] + ".jpg"
    #     f1.write(os.path.basename(xml)[:-4] + "\n")
    #     shutil.copyfile(img, save_path + "/images_divide/train/" + os.path.basename(img))
    #
    # f2 = open("val.txt", "w")
    # for xml in xml_list_val:
    #     img = xml[:-4] + ".jpg"
    #     f2.write(os.path.basename(xml)[:-4] + "\n")
    #     shutil.copyfile(img, save_path + "/images_divide/val/" + os.path.basename(img))
    #
    # f3 = open("test.txt", "w")
    # for xml in xml_list_val:
    #     img = xml[:-4] + ".jpg"
    #     f2.write(os.path.basename(xml)[:-4] + "\n")
    #     shutil.copyfile(img, save_path + "/images_divide/test/" + os.path.basename(img))
    #
    # f1.close()
    # f2.close()
    # f3.close()

    print("-" * 50)
    print("train number:", len(xml_list_train))
    print("val number:", len(xml_list_val))
    print("test number:", len(xml_list_val))


COCO2VOC

参考http://blog.csdn.net/ouyangfushu/article/details/79543575
包括对COCO,VOC数据集的简介

本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)

COCO和VOC数据集的转换:VOC2COCO和COCO2VOC 的相关文章

  • CPU虚拟化技术

    基本概念 物理CPU数量 实际服务器插槽上的CPU个数 核 一块CPU上面能处理数据的芯片组的数量 超线程 在一个实体芯片组中提供两个逻辑线程 逻辑CPU数量 物理CPU数量 核 超线程 若支持超线程 该值为2 vCPU 虚机分配的CPU
  • KOA框架编程25 文件下载

    目录 1 前言 2 文件下载 1 前言 koa这个框架确实好玩 跟express相比有比较大的不一样 express更像是一个大杂烩 所有的功能都冗杂在一块 而koa更像是一个灵活性很高个体 所有的功能都以独立组件的形式存在 2 文件下载
  • vite + vue报错:TypeError: The argument ‘id‘ must be a non-empty string. Received ‘‘

    vite vue项目开发环境运行正常 打包后报错 知道是图片的原因导致报错 却不知道具体原因是啥 用了电脑系统路径的图片 如 home xxx aa png file home xxx aa png base64等等 网上找这种情况 一般都
  • java多线程同步以及线程间通信

    文章目录 1 线程同步问题的产生 2 解决线程同步的两种典型方案 2 1 通过锁 Lock 对象的方式解决线程安全问题 2 2 synchronied关键字 2 2 1 同步方法 2 2 2 同步块 2 2 3 通过synchronied关
  • 若依框架富文本框的实现

    若依框架富文本框的实现 前端部分 引入summernote的js跟css

随机推荐

  • RestTemple调用接口,上传文件form-data方式

    前端调用后台服务上传文件 后端使用restTemple调用接口把文件传到其他服务上去 RequestMapping test public void upload MultipartFile file String originalFile
  • gcc编译时 warning:incompatible implicit declaration of built-in function ‘xxx’

    报错是因为我们没有添加该函数所在头文件 可通过man xxx来查询xxx函数所在的头文件 添加后即可
  • leetcode712. 两个字符串的最小ASCII删除和(最短非公共子序列)

    传送门 题目 给定两个字符串s1 s2 找到使两个字符串相等所需删除字符的ASCII值的最小和 输入 s1 sea s2 eat 输出 231 解释 在 sea 中删除 s 并将 s 的值 115 加入总和 在 eat 中删除 t 并将 1
  • 流利说 Level 5 全文

    Level 5 Unit 1 1 4 Listening Lesson 1 Jessica s Class Reunion1 2 Vocabulary Lesson 3 Actions and Change Lesson 4 Types o
  • Qt C++中的关键字explicit

    最近在复习QT 准备做项目了 QT Creator 默认生成的代码 explicit Dialog QWidget parent 0 中 有这么一个关键字explicit 用来修饰构造函数 以前在Windows下写程序的时候 基本上没有碰到
  • 【PHP】【组件使用】【phpexcel】【phpexcel导入导出】

    PHP 组件使用 phpexcel phpexcel导入导出 一 前提 PHP 7 3 tp3 2 tp5版本及以上的可能需要修改 二 phpexcel包引入 composer require phpoffice phpexcel 三 复用
  • pscp --windows上下载远程SSH服务器实用工具

    1 下载pscp exe pscp exe 工具下载地址 下载完后 复制粘贴到C Windows System32目录下 以便我们来调用 或者将下载文件的路径添加到系统环境变量中 2 pscp工具使用 1 上传本地文件到SSH服务器 将本地
  • 2019年个人总结

    今天是今年的最后 一天 写个个人总结 对自己一年来的工作进行总结 通过分析和研究进而肯定成绩并找出问题 得出经验和教训 2019年自己的前端方面 移动端 完成了好艺的app项目 协会的微官网 好艺的app转为公众号 学生开学统计项目等 其中
  • Python10个与数学有关的简单实例代码

    注意 我用的python2 7 大家如果用Python3 0以上的版本 请记得在print 函数哦 如果因为版本问题评论的 不做回复哦 1 题目 有1 2 3 4个数字 能组成多少个互不相同且无重复数字的三位数 都是多少 程序分析 可填在百
  • Javascript之BOM与DOM讲解

    文章转载自 https blog csdn net qq877507054 article details 51395830 一 Javascript组成 JavaScript的实现包括以下3个部分 ECMAScript 核心 描述了JS的
  • 项目开发中常用的十六进制方式打印实现

    在项目开发中 比如网络开发 多媒体播放开发等 常常用到将接受数据和发送数据或者需要解析的数据 用打印方式呈现 方便自己定位问题 在这个时候 printf难免没有满足我们的需要了 因为printf bufdata s n bufdata 是用
  • keil Error: Could not load file解决方法

    1 你点完建造文件 然后进行调试 不会出错 2 不要点编译文件 编译后文件调试状态关闭了 再调试 这样就会出这个错误
  • js-基础知识(一)

    1 在html中引入js的两种方法 1 页面内嵌 2 外部引入 为符合web标准 w3c标准中的一项 结构 样式 行为相分离 通常会采用外部引入
  • mmsegment数据pipeline操作(七)

    目录 1 数据项配置 2 voc数据集传入参数 3 CustomDataset数据读取 4 self pipeline results 4 1 读图 4 2 数据增广 4 3 格式转换 4 4 测试 5 扩展和使用自定义管道 1 数据项配置
  • 计算机专业留学动机信范文,出国留学,如何写好动机信(Motivation Letter)?

    一篇好的动机信最重要的是简洁易懂 用最简洁的语言展示申请者最突出的优点 浙大毕业后在美国 UIUC 和欧洲 KTH CTH EPFL NTNU 留学 PhD 另外由于在之前的工作中也参与系里招生 帮老板评审申请材料 参与系里招生会议 经手的
  • 数据结构之线性表预习

    1 简述线性表中顺序存储结构的含义及主要元素 描述顺序存储结构需要三个属性 1 存储空间的起始位置 数组 data 它的存储位置就是存储空间的存储位置 2 线性表的最大存储容量 3 线性表的当前长度 数组长度 与 线性表长度区别 数组长度
  • 编程新手导论

    第二部分 导论 这一部分主要是关于编程的导论 要懂得一点思想具备一点常识 设计 编码 与软工 编程与思想 这一章解释了三种思想 原语 抽象 组合 和软件开发的二个重要过程 软件工程的相关概念 是编程入门的关键 要懂得一点领域内的数学 数学与
  • python3读取图片并灰度化图片的四种方法(OpenCV、PIL.Image、TensorFlow方法)总结

    在处理图像的时候经常是读取图片以后把图片转换为灰度图 作为一个刚入坑的小白 我在这篇博客记录了四种处理的方法 首先导入包 import numpy as np import cv2 import tensorflow as tf from
  • 【网络】IP协议相关的技术(DNS、ARP、ICMP、DHCP)简析

    1 DNS 域名解析协议 TCP IP中使用IP地址和端口号来确定网络上的一台主机的一个程序 但是IP地址不方便记忆 于是人们发明了一种叫主机名的东西 是一个字符串 并且使用hosts文件来描述主机名和IP地址的关系 DNS协议是将域名转换
  • COCO和VOC数据集的转换:VOC2COCO和COCO2VOC

    VOC2COCO 方法一 参考自博客 数据格式的转换实际是将VOC的annotation标注文件转化为COCO的json文件 注 下面代码包含通过txt文件生成和通过文件夹生成两种方法 1 通过txt文件生成 按照VOC数据集下ImageS