国产 无码 综合区,色欲AV无码国产永久播放,无码天堂亚洲国产AV,国产日韩欧美女同一区二区

使用LabelMe標(biāo)注目標(biāo)檢測數(shù)據(jù)集并轉(zhuǎn)換為COCO2017格式

這篇具有很好參考價(jià)值的文章主要介紹了使用LabelMe標(biāo)注目標(biāo)檢測數(shù)據(jù)集并轉(zhuǎn)換為COCO2017格式。希望對大家有所幫助。如果存在錯(cuò)誤或未考慮完全的地方,請大家不吝賜教,您也可以點(diǎn)擊"舉報(bào)違法"按鈕提交疑問。

1、labelme標(biāo)注

當(dāng)你安裝好labelme啟動(dòng)后,open dir開始標(biāo)注,選擇Create Rectangle
coco labelme,ML離不開的數(shù)據(jù)集,目標(biāo)檢測,python,人工智能
拖拽畫框,然后選擇類別(沒有就直接輸入會(huì)自動(dòng)新建),標(biāo)注好一幅圖后點(diǎn)擊next image會(huì)彈框提示保存json文件,保存即可。

當(dāng)你將所有圖像標(biāo)注完后,點(diǎn)擊Next Image是沒有反應(yīng)的(因?yàn)闆]有Next圖了),此時(shí)直接x掉labelme軟件即可

如果你將json文件保存在圖像文件夾中,則應(yīng)當(dāng)有以下結(jié)構(gòu):

  • img1.jpg
  • img1.json
  • img2.jpg
  • img2.json

2、轉(zhuǎn)為coco格式

假設(shè)我有一個(gè)mycoco的數(shù)據(jù)集,是符合coco2017數(shù)據(jù)集格式的,那么他的目錄結(jié)構(gòu)應(yīng)該如下,在mycoco文件夾下有4個(gè)文件夾:annotations(存放train、val和test的標(biāo)注信息)、train(存放train集圖片)、val(存放val集圖片)、test(存放test集圖片)
coco labelme,ML離不開的數(shù)據(jù)集,目標(biāo)檢測,python,人工智能

現(xiàn)在我們已經(jīng)用labelme標(biāo)注好的信息,如何轉(zhuǎn)換為上面的coco結(jié)構(gòu)呢?

#!/usr/bin/env python
# coding: utf-8
# Copyright (c) 2019 PaddlePaddle Authors. All Rights Reserved.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
#     http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.

import argparse
import glob
import json
import os
import os.path as osp
import shutil
import xml.etree.ElementTree as ET

import numpy as np
import PIL.ImageDraw
from tqdm import tqdm
import cv2

label_to_num = {}
categories_list = []
labels_list = []


class MyEncoder(json.JSONEncoder):
    def default(self, obj):
        if isinstance(obj, np.integer):
            return int(obj)
        elif isinstance(obj, np.floating):
            return float(obj)
        elif isinstance(obj, np.ndarray):
            return obj.tolist()
        else:
            return super(MyEncoder, self).default(obj)


def images_labelme(data, num):
    image = {}
    image['height'] = data['imageHeight']
    image['width'] = data['imageWidth']
    image['id'] = num + 1
    if '\\' in data['imagePath']:
        image['file_name'] = data['imagePath'].split('\\')[-1]
    else:
        image['file_name'] = data['imagePath'].split('/')[-1]
    return image


def images_cityscape(data, num, img_file):
    image = {}
    image['height'] = data['imgHeight']
    image['width'] = data['imgWidth']
    image['id'] = num + 1
    image['file_name'] = img_file
    return image


def categories(label, labels_list):
    category = {}
    category['supercategory'] = 'component'
    category['id'] = len(labels_list) + 1
    category['name'] = label
    return category


def annotations_rectangle(points, label, image_num, object_num, label_to_num):
    annotation = {}
    seg_points = np.asarray(points).copy()
    seg_points[1, :] = np.asarray(points)[2, :]
    seg_points[2, :] = np.asarray(points)[1, :]
    annotation['segmentation'] = [list(seg_points.flatten())]
    annotation['iscrowd'] = 0
    annotation['image_id'] = image_num + 1
    annotation['bbox'] = list(
        map(float, [
            points[0][0], points[0][1], points[1][0] - points[0][0], points[1][
                1] - points[0][1]
        ]))
    annotation['area'] = annotation['bbox'][2] * annotation['bbox'][3]
    annotation['category_id'] = label_to_num[label]
    annotation['id'] = object_num + 1
    return annotation


def annotations_polygon(height, width, points, label, image_num, object_num,
                        label_to_num):
    annotation = {}
    annotation['segmentation'] = [list(np.asarray(points).flatten())]
    annotation['iscrowd'] = 0
    annotation['image_id'] = image_num + 1
    annotation['bbox'] = list(map(float, get_bbox(height, width, points)))
    annotation['area'] = annotation['bbox'][2] * annotation['bbox'][3]
    annotation['category_id'] = label_to_num[label]
    annotation['id'] = object_num + 1
    return annotation


def get_bbox(height, width, points):
    polygons = points
    mask = np.zeros([height, width], dtype=np.uint8)
    mask = PIL.Image.fromarray(mask)
    xy = list(map(tuple, polygons))
    PIL.ImageDraw.Draw(mask).polygon(xy=xy, outline=1, fill=1)
    mask = np.array(mask, dtype=bool)
    index = np.argwhere(mask == 1)
    rows = index[:, 0]
    clos = index[:, 1]
    left_top_r = np.min(rows)
    left_top_c = np.min(clos)
    right_bottom_r = np.max(rows)
    right_bottom_c = np.max(clos)
    return [
        left_top_c, left_top_r, right_bottom_c - left_top_c,
        right_bottom_r - left_top_r
    ]


def deal_json(ds_type, img_path, json_path):
    data_coco = {}
    images_list = []
    annotations_list = []
    image_num = -1
    object_num = -1
    for img_file in os.listdir(img_path):
        img_label = os.path.splitext(img_file)[0]
        if img_file.split('.')[
                -1] not in ['bmp', 'jpg', 'jpeg', 'png', 'JPEG', 'JPG', 'PNG']:
            continue
        label_file = osp.join(json_path, img_label + '.json')
        print('Generating dataset from:', label_file)
        image_num = image_num + 1
        with open(label_file) as f:
            data = json.load(f)
            if ds_type == 'labelme':
                images_list.append(images_labelme(data, image_num))
            elif ds_type == 'cityscape':
                images_list.append(images_cityscape(data, image_num, img_file))
            if ds_type == 'labelme':
                for shapes in data['shapes']:
                    object_num = object_num + 1
                    label = shapes['label']
                    if label not in labels_list:
                        categories_list.append(categories(label, labels_list))
                        labels_list.append(label)
                        label_to_num[label] = len(labels_list)
                    p_type = shapes['shape_type']
                    if p_type == 'polygon':
                        points = shapes['points']
                        annotations_list.append(
                            annotations_polygon(data['imageHeight'], data[
                                'imageWidth'], points, label, image_num,
                                                object_num, label_to_num))

                    if p_type == 'rectangle':
                        (x1, y1), (x2, y2) = shapes['points']
                        x1, x2 = sorted([x1, x2])
                        y1, y2 = sorted([y1, y2])
                        points = [[x1, y1], [x2, y2], [x1, y2], [x2, y1]]
                        annotations_list.append(
                            annotations_rectangle(points, label, image_num,
                                                  object_num, label_to_num))
            elif ds_type == 'cityscape':
                for shapes in data['objects']:
                    object_num = object_num + 1
                    label = shapes['label']
                    if label not in labels_list:
                        categories_list.append(categories(label, labels_list))
                        labels_list.append(label)
                        label_to_num[label] = len(labels_list)
                    points = shapes['polygon']
                    annotations_list.append(
                        annotations_polygon(data['imgHeight'], data[
                            'imgWidth'], points, label, image_num, object_num,
                                            label_to_num))
    data_coco['images'] = images_list
    data_coco['categories'] = categories_list
    data_coco['annotations'] = annotations_list
    return data_coco


def voc_get_label_anno(ann_dir_path, ann_ids_path, labels_path):
    with open(labels_path, 'r') as f:
        labels_str = f.read().split()
    labels_ids = list(range(1, len(labels_str) + 1))

    with open(ann_ids_path, 'r') as f:
        ann_ids = [lin.strip().split(' ')[-1] for lin in f.readlines()]

    ann_paths = []
    for aid in ann_ids:
        if aid.endswith('xml'):
            ann_path = os.path.join(ann_dir_path, aid)
        else:
            ann_path = os.path.join(ann_dir_path, aid + '.xml')
        ann_paths.append(ann_path)

    return dict(zip(labels_str, labels_ids)), ann_paths


def voc_get_image_info(annotation_root, im_id):
    filename = annotation_root.findtext('filename')
    assert filename is not None
    img_name = os.path.basename(filename)

    size = annotation_root.find('size')
    width = float(size.findtext('width'))
    height = float(size.findtext('height'))

    image_info = {
        'file_name': filename,
        'height': height,
        'width': width,
        'id': im_id
    }
    return image_info


def voc_get_coco_annotation(obj, label2id):
    label = obj.findtext('name')
    assert label in label2id, "label is not in label2id."
    category_id = label2id[label]
    bndbox = obj.find('bndbox')
    xmin = float(bndbox.findtext('xmin'))
    ymin = float(bndbox.findtext('ymin'))
    xmax = float(bndbox.findtext('xmax'))
    ymax = float(bndbox.findtext('ymax'))
    assert xmax > xmin and ymax > ymin, "Box size error."
    o_width = xmax - xmin
    o_height = ymax - ymin
    anno = {
        'area': o_width * o_height,
        'iscrowd': 0,
        'bbox': [xmin, ymin, o_width, o_height],
        'category_id': category_id,
        'ignore': 0,
    }
    return anno


def voc_xmls_to_cocojson(annotation_paths, label2id, output_dir, output_file):
    output_json_dict = {
        "images": [],
        "type": "instances",
        "annotations": [],
        "categories": []
    }
    bnd_id = 1  # bounding box start id
    im_id = 0
    print('Start converting !')
    for a_path in tqdm(annotation_paths):
        # Read annotation xml
        ann_tree = ET.parse(a_path)
        ann_root = ann_tree.getroot()

        img_info = voc_get_image_info(ann_root, im_id)
        output_json_dict['images'].append(img_info)

        for obj in ann_root.findall('object'):
            ann = voc_get_coco_annotation(obj=obj, label2id=label2id)
            ann.update({'image_id': im_id, 'id': bnd_id})
            output_json_dict['annotations'].append(ann)
            bnd_id = bnd_id + 1
        im_id += 1

    for label, label_id in label2id.items():
        category_info = {'supercategory': 'none', 'id': label_id, 'name': label}
        output_json_dict['categories'].append(category_info)
    output_file = os.path.join(output_dir, output_file)
    with open(output_file, 'w') as f:
        output_json = json.dumps(output_json_dict)
        f.write(output_json)


def widerface_to_cocojson(root_path):
    train_gt_txt = os.path.join(root_path, "wider_face_split", "wider_face_train_bbx_gt.txt")
    val_gt_txt = os.path.join(root_path, "wider_face_split", "wider_face_val_bbx_gt.txt")
    train_img_dir = os.path.join(root_path, "WIDER_train", "images")
    val_img_dir = os.path.join(root_path, "WIDER_val", "images")
    assert train_gt_txt
    assert val_gt_txt
    assert train_img_dir
    assert val_img_dir
    save_path = os.path.join(root_path, "widerface_train.json")
    widerface_convert(train_gt_txt, train_img_dir, save_path)
    print("Wider Face train dataset converts sucess, the json path: {}".format(save_path))
    save_path = os.path.join(root_path, "widerface_val.json")
    widerface_convert(val_gt_txt, val_img_dir, save_path)
    print("Wider Face val dataset converts sucess, the json path: {}".format(save_path))


def widerface_convert(gt_txt, img_dir, save_path):
    output_json_dict = {
        "images": [],
        "type": "instances",
        "annotations": [],
        "categories": [{'supercategory': 'none', 'id': 0, 'name': "human_face"}]
    }
    bnd_id = 1  # bounding box start id
    im_id = 0
    print('Start converting !')
    with open(gt_txt) as fd:
        lines = fd.readlines()

    i = 0
    while i < len(lines):
        image_name = lines[i].strip()
        bbox_num = int(lines[i + 1].strip())
        i += 2
        img_info = get_widerface_image_info(img_dir, image_name, im_id)
        if img_info:
            output_json_dict["images"].append(img_info)
            for j in range(i, i + bbox_num):
                anno = get_widerface_ann_info(lines[j])
                anno.update({'image_id': im_id, 'id': bnd_id})
                output_json_dict['annotations'].append(anno)
                bnd_id += 1
        else:
            print("The image dose not exist: {}".format(os.path.join(img_dir, image_name)))
        bbox_num = 1 if bbox_num == 0 else bbox_num
        i += bbox_num
        im_id += 1
    with open(save_path, 'w') as f:
        output_json = json.dumps(output_json_dict)
        f.write(output_json)


def get_widerface_image_info(img_root, img_relative_path, img_id):
    image_info = {}
    save_path = os.path.join(img_root, img_relative_path)
    if os.path.exists(save_path):
        img = cv2.imread(save_path)
        image_info["file_name"] = os.path.join(os.path.basename(
            os.path.dirname(img_root)), os.path.basename(img_root),
            img_relative_path)
        image_info["height"] = img.shape[0]
        image_info["width"] = img.shape[1]
        image_info["id"] = img_id
    return image_info


def get_widerface_ann_info(info):
    info = [int(x) for x in info.strip().split()]
    anno = {
        'area': info[2] * info[3],
        'iscrowd': 0,
        'bbox': [info[0], info[1], info[2], info[3]],
        'category_id': 0,
        'ignore': 0,
        'blur': info[4],
        'expression': info[5],
        'illumination': info[6],
        'invalid': info[7],
        'occlusion': info[8],
        'pose': info[9]
    }
    return anno


def main():
    parser = argparse.ArgumentParser(
        formatter_class=argparse.ArgumentDefaultsHelpFormatter)
    parser.add_argument(
        '--dataset_type',
        help='the type of dataset, can be `voc`, `widerface`, `labelme` or `cityscape`')
    parser.add_argument('--json_input_dir', help='input annotated directory')
    parser.add_argument('--image_input_dir', help='image directory')
    parser.add_argument(
        '--output_dir', help='output dataset directory', default='./')
    parser.add_argument(
        '--train_proportion',
        help='the proportion of train dataset',
        type=float,
        default=1.0)
    parser.add_argument(
        '--val_proportion',
        help='the proportion of validation dataset',
        type=float,
        default=0.0)
    parser.add_argument(
        '--test_proportion',
        help='the proportion of test dataset',
        type=float,
        default=0.0)
    parser.add_argument(
        '--voc_anno_dir',
        help='In Voc format dataset, path to annotation files directory.',
        type=str,
        default=None)
    parser.add_argument(
        '--voc_anno_list',
        help='In Voc format dataset, path to annotation files ids list.',
        type=str,
        default=None)
    parser.add_argument(
        '--voc_label_list',
        help='In Voc format dataset, path to label list. The content of each line is a category.',
        type=str,
        default=None)
    parser.add_argument(
        '--voc_out_name',
        type=str,
        default='voc.json',
        help='In Voc format dataset, path to output json file')
    parser.add_argument(
        '--widerface_root_dir',
        help='The root_path for wider face dataset, which contains `wider_face_split`, `WIDER_train` and `WIDER_val`.And the json file will save in this path',
        type=str,
        default=None)
    args = parser.parse_args()
    try:
        assert args.dataset_type in ['voc', 'labelme', 'cityscape', 'widerface']
    except AssertionError as e:
        print(
            'Now only support the voc, cityscape dataset and labelme dataset!!')
        os._exit(0)

    if args.dataset_type == 'voc':
        assert args.voc_anno_dir and args.voc_anno_list and args.voc_label_list
        label2id, ann_paths = voc_get_label_anno(
            args.voc_anno_dir, args.voc_anno_list, args.voc_label_list)
        voc_xmls_to_cocojson(
            annotation_paths=ann_paths,
            label2id=label2id,
            output_dir=args.output_dir,
            output_file=args.voc_out_name)
    elif args.dataset_type == "widerface":
        assert args.widerface_root_dir
        widerface_to_cocojson(args.widerface_root_dir)
    else:
        try:
            assert os.path.exists(args.json_input_dir)
        except AssertionError as e:
            print('The json folder does not exist!')
            os._exit(0)
        try:
            assert os.path.exists(args.image_input_dir)
        except AssertionError as e:
            print('The image folder does not exist!')
            os._exit(0)
        try:
            assert abs(args.train_proportion + args.val_proportion \
                    + args.test_proportion - 1.0) < 1e-5
        except AssertionError as e:
            print(
                'The sum of pqoportion of training, validation and test datase must be 1!'
            )
            os._exit(0)

        # Allocate the dataset.
        total_num = len(glob.glob(osp.join(args.json_input_dir, '*.json')))
        if args.train_proportion != 0:
            train_num = int(total_num * args.train_proportion)
            out_dir = args.output_dir + '/train'
            if not os.path.exists(out_dir):
                os.makedirs(out_dir)
        else:
            train_num = 0
        if args.val_proportion == 0.0:
            val_num = 0
            test_num = total_num - train_num
            out_dir = args.output_dir + '/test'
            if args.test_proportion != 0.0 and not os.path.exists(out_dir):
                os.makedirs(out_dir)
        else:
            val_num = int(total_num * args.val_proportion)
            test_num = total_num - train_num - val_num
            val_out_dir = args.output_dir + '/val'
            if not os.path.exists(val_out_dir):
                os.makedirs(val_out_dir)
            test_out_dir = args.output_dir + '/test'
            if args.test_proportion != 0.0 and not os.path.exists(test_out_dir):
                os.makedirs(test_out_dir)
        count = 1
        for img_name in os.listdir(args.image_input_dir):
            if count <= train_num:
                if osp.exists(args.output_dir + '/train/'):
                    shutil.copyfile(
                        osp.join(args.image_input_dir, img_name),
                        osp.join(args.output_dir + '/train/', img_name))
            else:
                if count <= train_num + val_num:
                    if osp.exists(args.output_dir + '/val/'):
                        shutil.copyfile(
                            osp.join(args.image_input_dir, img_name),
                            osp.join(args.output_dir + '/val/', img_name))
                else:
                    if osp.exists(args.output_dir + '/test/'):
                        shutil.copyfile(
                            osp.join(args.image_input_dir, img_name),
                            osp.join(args.output_dir + '/test/', img_name))
            count = count + 1

        # Deal with the json files.
        if not os.path.exists(args.output_dir + '/annotations'):
            os.makedirs(args.output_dir + '/annotations')
        if args.train_proportion != 0:
            train_data_coco = deal_json(args.dataset_type,
                                        args.output_dir + '/train',
                                        args.json_input_dir)
            train_json_path = osp.join(args.output_dir + '/annotations',
                                       'instance_train.json')
            json.dump(
                train_data_coco,
                open(train_json_path, 'w'),
                indent=4,
                cls=MyEncoder)
        if args.val_proportion != 0:
            val_data_coco = deal_json(args.dataset_type,
                                      args.output_dir + '/val',
                                      args.json_input_dir)
            val_json_path = osp.join(args.output_dir + '/annotations',
                                     'instance_val.json')
            json.dump(
                val_data_coco,
                open(val_json_path, 'w'),
                indent=4,
                cls=MyEncoder)
        if args.test_proportion != 0:
            test_data_coco = deal_json(args.dataset_type,
                                       args.output_dir + '/test',
                                       args.json_input_dir)
            test_json_path = osp.join(args.output_dir + '/annotations',
                                      'instance_test.json')
            json.dump(
                test_data_coco,
                open(test_json_path, 'w'),
                indent=4,
                cls=MyEncoder)


if __name__ == '__main__':
    """
    python tools/x2coco.py \
                --dataset_type labelme \
                --json_input_dir ./labelme_annos/ \
                --image_input_dir ./labelme_imgs/ \
                --output_dir ./mycoco/ \
                --train_proportion 0.8 \
                --val_proportion 0.2 \
                --test_proportion 0.0
    """
    main()

上面的代碼是從paddledetection拿來的(不得不說百度的的小腳本還是挺多的),通過命令行參數(shù):

python tools/x2coco.py \
            --dataset_type labelme \		
            --json_input_dir ./labelme_annos/ \
            --image_input_dir ./labelme_imgs/ \
            --output_dir ./mycoco/ \
            --train_proportion 0.8 \
            --val_proportion 0.2 \
            --test_proportion 0.0
  • dataset_type:是將labelme轉(zhuǎn)為coco,鎖著這里默認(rèn)就是labelme
  • json_input_dir:指向labelme的json文件所在路徑
  • image_input_dir:指向labelme的img文件所在路徑(在這里json和img都是相同的路徑)
  • output_dir :轉(zhuǎn)為coco后輸出的文件夾路徑
  • train_proportion、val_proportion、test_proportion:劃分?jǐn)?shù)據(jù)集比例,總之三者之和必須為1

成功執(zhí)行后就能看到mycoco文件夾:
coco labelme,ML離不開的數(shù)據(jù)集,目標(biāo)檢測,python,人工智能
注意:雖然現(xiàn)在目錄結(jié)構(gòu)上和coco一致了,但是在很多開源目標(biāo)檢測項(xiàng)目中,默認(rèn)的文件名字不太一樣,比如有的文件夾為train2017、val2017和test2017,或者annotations中的文件名為instances_train.json(多了一個(gè)s),請結(jié)合實(shí)際情況修改即可

3、標(biāo)簽可視化

經(jīng)過labelme的標(biāo)注和轉(zhuǎn)為coco格式后,我們希望可視化coco數(shù)據(jù)集,可以使用以下代碼:

import cv2
import os
from pycocotools.coco import COCO


labels=['eye','noise','mouth']  # 分類標(biāo)簽名
img_path = 'mycoco/train' # 比如我需要可視化train集
annFile = 'mycoco/annotations\instances_train.json'  # 指定train集的json文件
save_path = 'mycoco/train_vis'   # 可視化結(jié)果的保存路徑

if not os.path.exists(save_path):
    os.makedirs(save_path)

def draw_rectangle(coordinates, image, image_name,color=(0,255,0),thickness=1,fontScale=0.5):
    """

    @param coordinates: 所有框的信息[[left,top,right,bottom],[left,top,right,bottom],...]
    @param image:
    @param image_name:
    @param color: 框和文字的顏色,默認(rèn)綠色
    @param thickness: 框線條的粗細(xì)
    @param fontScale: 字體大小
    @return:
    """
    for coordinate in coordinates:  # 遍歷每一個(gè)框信息
        left, top, right, bottom = map(int, coordinate[:-1])
        label=coordinate[-1]
        cv2.rectangle(image, (left, top), (right, bottom), color, thickness)
        cv2.putText(image, str(label), (left, top), cv2.FONT_HERSHEY_SIMPLEX, fontScale, color, thickness)

    cv2.imwrite(save_path + '/' + image_name, image)


coco = COCO(annFile)
imgIds = coco.getImgIds()  # 獲取每張圖片的序號(hào)

for imgId in imgIds:
    img = coco.loadImgs(imgId)[0]   #加載圖片信息
    image_name = img['file_name']   # 獲取圖片名字
    annIds = coco.getAnnIds(imgIds=img['id'], catIds=[], iscrowd=None)  # 根據(jù)圖片id獲取與該id相關(guān)聯(lián)的anno的序號(hào)
    anns = coco.loadAnns(annIds)    # 根據(jù)anno序號(hào)獲取anno信息

    coordinates = []
    img_raw = cv2.imread(os.path.join(img_path, image_name))
    for j in range(len(anns)):
        coordinate = anns[j]['bbox']    # 遍歷每一個(gè)anno,獲取到框信息,[left,top,width,heigh]
        coordinate[2] += coordinate[0]  # 計(jì)算得到right
        coordinate[3] += coordinate[1]  # 計(jì)算得到bottom
        coordinate.append(labels[anns[j]['category_id']-1])   # 追加分類標(biāo)簽,形成[left,top,right,bottom,label]
        coordinates.append(coordinate)  # [[left,top,right,bottom],[left,top,right,bottom],...]

    draw_rectangle(coordinates, img_raw, image_name)

就會(huì)得到標(biāo)注信息繪制后的圖:
coco labelme,ML離不開的數(shù)據(jù)集,目標(biāo)檢測,python,人工智能文章來源地址http://www.zghlxwxcb.cn/news/detail-678945.html

到了這里,關(guān)于使用LabelMe標(biāo)注目標(biāo)檢測數(shù)據(jù)集并轉(zhuǎn)換為COCO2017格式的文章就介紹完了。如果您還想了解更多內(nèi)容,請?jiān)谟疑辖撬阉鱐OY模板網(wǎng)以前的文章或繼續(xù)瀏覽下面的相關(guān)文章,希望大家以后多多支持TOY模板網(wǎng)!

本文來自互聯(lián)網(wǎng)用戶投稿,該文觀點(diǎn)僅代表作者本人,不代表本站立場。本站僅提供信息存儲(chǔ)空間服務(wù),不擁有所有權(quán),不承擔(dān)相關(guān)法律責(zé)任。如若轉(zhuǎn)載,請注明出處: 如若內(nèi)容造成侵權(quán)/違法違規(guī)/事實(shí)不符,請點(diǎn)擊違法舉報(bào)進(jìn)行投訴反饋,一經(jīng)查實(shí),立即刪除!

領(lǐng)支付寶紅包贊助服務(wù)器費(fèi)用

相關(guān)文章

  • 偽裝目標(biāo)檢測中數(shù)據(jù)集的標(biāo)注格式:COCO和VOC

    1.OSFormer中提供的COD10K的json格式,是coco的格式,但由于偽裝目標(biāo)檢測任務(wù)的特殊性,標(biāo)注信息中還有一個(gè)segmentation段 首先將一整個(gè)json文件分解: 然后轉(zhuǎn)化為VOC格式: 這樣生成的xml文件,沒有之前COD10K標(biāo)注的segmentation信息,還需要進(jìn)一步考慮,在轉(zhuǎn)換為xml的腳本中加上識(shí)別

    2024年04月27日
    瀏覽(89)
  • labelme目標(biāo)檢測數(shù)據(jù)類型轉(zhuǎn)換

    labelme目標(biāo)檢測數(shù)據(jù)類型轉(zhuǎn)換

    LabelMe是一個(gè)開源的在線圖像標(biāo)注工具,旨在幫助用戶創(chuàng)建和標(biāo)記圖像數(shù)據(jù)集。它提供了一個(gè)用戶友好的界面,讓用戶可以直觀地在圖像上繪制標(biāo)記框、多邊形、線條等,以標(biāo)識(shí)和注釋圖像中的對象或區(qū)域。 GitHub:https://github.com/wkentaro/labelme 經(jīng)過labelme標(biāo)注工具對圖像中的目標(biāo)

    2024年02月04日
    瀏覽(17)
  • 目標(biāo)檢測數(shù)據(jù)集格式轉(zhuǎn)換:將labelme格式轉(zhuǎn)為YOLO以及VOC格式

    目標(biāo)檢測數(shù)據(jù)集格式轉(zhuǎn)換:將labelme格式轉(zhuǎn)為YOLO以及VOC格式

    一個(gè)目標(biāo)檢測項(xiàng)目需要自己找圖片標(biāo)注數(shù)據(jù)進(jìn)行訓(xùn)練,訓(xùn)練需要YOLO格式,但數(shù)據(jù)增廣需要VOC格式,該文記錄如何將labelme標(biāo)注的數(shù)據(jù)格式轉(zhuǎn)為YOLO格式,再從YOLO格式轉(zhuǎn)為VOC格式,只作為自己用的記錄,如果你剛好也需要這么干,或者需要文中提到的某一種轉(zhuǎn)換,也可以參考一下

    2024年02月08日
    瀏覽(33)
  • 目標(biāo)檢測標(biāo)注文件yolov5(txt)格式轉(zhuǎn)coco(json)格式詳解及代碼實(shí)現(xiàn)

    目標(biāo)檢測標(biāo)注文件yolov5(txt)格式轉(zhuǎn)coco(json)格式詳解及代碼實(shí)現(xiàn)

    Reference:https://blog.csdn.net/qq_39686950/article/details/119153685 前言 正好自己做目標(biāo)檢測任務(wù)更換模型需要使用不同格式的標(biāo)注文件,所以在網(wǎng)上找了半天類似博文,發(fā)現(xiàn)大多都只有代碼或者解釋不全,對新手不夠友好,我在轉(zhuǎn)換的過程中就debug了半天才轉(zhuǎn)換成功,所以寫下這篇博文

    2024年02月04日
    瀏覽(103)
  • 人工智能學(xué)習(xí)07--pytorch20--目標(biāo)檢測:COCO數(shù)據(jù)集介紹+pycocotools簡單使用

    人工智能學(xué)習(xí)07--pytorch20--目標(biāo)檢測:COCO數(shù)據(jù)集介紹+pycocotools簡單使用

    如:天空 coco包含pascal voc 的所有類別,并且對每個(gè)類別的標(biāo)注目標(biāo)個(gè)數(shù)也比pascal voc的多。 一般使用coco數(shù)據(jù)集預(yù)訓(xùn)練好的權(quán)重來遷移學(xué)習(xí)。 如果僅僅針對目標(biāo)檢測object80類而言,有些圖片并沒有標(biāo)注信息,或者有錯(cuò)誤標(biāo)注信息。所以在實(shí)際的訓(xùn)練過程中,需要對這些數(shù)據(jù)進(jìn)行

    2024年02月12日
    瀏覽(96)
  • Labelme使用——數(shù)據(jù)集標(biāo)注詳解

    Labelme使用——數(shù)據(jù)集標(biāo)注詳解

    ?1、Labelme的安裝: Windows下首先安裝Anaconda,安裝教程:Windows下Anaconda的下載與安裝_一諾長安的博客-CSDN博客 安裝成功后,電計(jì)電腦左下角“開始”,找到Anaconda3(64-bit?)下的Anaconda Prompt,并打開。 ?查看python版本:輸入python或者python -V ?創(chuàng)建虛擬環(huán)境:conda create -n labelm

    2024年02月08日
    瀏覽(17)
  • 批量轉(zhuǎn)換labelme標(biāo)注后json文件為圖片

    批量轉(zhuǎn)換labelme標(biāo)注后json文件為圖片

    本文的代碼可實(shí)現(xiàn)批量轉(zhuǎn)換指定文件夾中的所有文件,抽取對應(yīng)的圖片至文件夾,標(biāo)注圖片轉(zhuǎn)單通道以及實(shí)現(xiàn)分割區(qū)域在原圖上的顯示。 文章內(nèi)容參考labelme批量制作數(shù)據(jù)集教程,寫這個(gè)博客我主要是想自己加深一下印象,另外梳理一下代碼,記錄一下我自己遇到的問題,如

    2024年02月03日
    瀏覽(15)
  • ubuntu20.04系統(tǒng)安裝使用labelme標(biāo)注數(shù)據(jù)集

    ubuntu20.04系統(tǒng)安裝使用labelme標(biāo)注數(shù)據(jù)集

    請參考:Mediapipe+VSCode+Anaconda 實(shí)時(shí)檢測手部關(guān)鍵點(diǎn)并保存視頻_苦瓜湯補(bǔ)鈣的博客-CSDN博客 1.打開終端創(chuàng)建虛擬環(huán)境 ??輸入“y”,然后回車。 ?2.激活虛擬環(huán)境,開始安裝 ?1、啟動(dòng) 2、點(diǎn)擊【open】,選擇圖片;【Edit Polygons】---- 【Create Polygons】 ?3、可以選擇自動(dòng)保存 ?

    2024年02月16日
    瀏覽(22)
  • 數(shù)據(jù)集學(xué)習(xí)筆記(六):目標(biāo)檢測和圖像分割標(biāo)注軟件介紹和使用,并轉(zhuǎn)換成YOLO系列可使用的數(shù)據(jù)集格式

    數(shù)據(jù)集學(xué)習(xí)筆記(六):目標(biāo)檢測和圖像分割標(biāo)注軟件介紹和使用,并轉(zhuǎn)換成YOLO系列可使用的數(shù)據(jù)集格式

    labelImg是一個(gè)開源的圖像標(biāo)注工具,用于創(chuàng)建圖像標(biāo)注數(shù)據(jù)集。它提供了一個(gè)簡單易用的界面,允許用戶通過繪制邊界框或者創(chuàng)建多邊形來標(biāo)注圖像中的對象。它支持多種常見的標(biāo)注格式,如Pascal VOC、YOLO和COCO等。 使用labelImg,用戶可以加載圖像文件夾,逐個(gè)標(biāo)注圖像中的對

    2024年02月10日
    瀏覽(31)
  • 目標(biāo)檢測任務(wù)中常用的數(shù)據(jù)集格式(voc、coco、yolo)

    目標(biāo)檢測任務(wù)中常用的數(shù)據(jù)集格式(voc、coco、yolo)

    VOC數(shù)據(jù)集(Annotation的格式是xmI) Pascal VOC數(shù)據(jù)集是目標(biāo)檢測的常用的大規(guī)模數(shù)據(jù)集之一,從05年到12年都會(huì)舉辦比賽,比賽任務(wù)task: 分類Classification 目標(biāo)檢測Object Detection 語義分割Class Segmentation 實(shí)例分割Object Segmentation Action Classification(專注于人體動(dòng)作的一種分類) Person Layout(

    2024年02月14日
    瀏覽(28)

覺得文章有用就打賞一下文章作者

支付寶掃一掃打賞

博客贊助

微信掃一掃打賞

請作者喝杯咖啡吧~博客贊助

支付寶掃一掃領(lǐng)取紅包,優(yōu)惠每天領(lǐng)

二維碼1

領(lǐng)取紅包

二維碼2

領(lǐng)紅包