制作coco格式数据集,用于mask rcnn训练

本文介绍了如何将仅包含polypoints四个顶点的原始数据集转换为适用于Mask R-CNN训练的COCO格式。通过mmdetection框架,详细展示了数据预处理步骤和训练过程。
摘要由CSDN通过智能技术生成

mmdetection跑通maskrcnn
https://github.com/open-mmlab/mmdetection
mmdetection说明文档
原格式为只包含polypoints的四个顶点,转化为用于训练mask rcnn的coco格式数据集。

"""
https://github.com/wusaifei/prepare_detection_dataset/blob/master/labelme2coco.py
"""
import os
import json
import numpy as np
import cv2

classname_to_id = {
   "card": 1}


def order_points_clock(pts):
    pts = np.array(pts).reshape((-1, 2))
    xSorted = pts[np.argsort(pts[:, 0]), :]
    leftMost = xSorted[:2, :]
    rightMost = xSorted[2:, :]
    leftMost = leftMost[np.argsort(leftMost[:, 1]), :]
    (tl, bl) = leftMost
    rightMost = rightMost[np.argsort(rightMost[:, 1]), :]
    (tr, br) = rightMost
    return np.array([tl, tr, br, bl], dtype=np.int32)


class MyEncoder(json.JSONEncoder):
    def default(self, obj):
        if isinstance(obj, np.integer):
            return int(obj)
        elif isinstance(obj, np.floating)
  • 0
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值