毕业设计周记9

本文档记录了作者在毕业设计中使用mmdetection工具箱进行对象检测的学习过程,包括安装、使用方法以及通过调整正负样本选取、数据增强和更换骨干网提升算法性能的尝试。尽管训练结果AP在40%左右,但作者认识到优化之路仍长。
摘要由CSDN通过智能技术生成

mmdetection

前言

前面我都是基于官方提供的FCOS算法代码进行训练的,最近才发现有个好东西mmdetection:一款基于PyTorch的开源对象检测工具箱,它提供了已公开发表的多种视觉检测核心模块,通过这些模块的组合,可以迅速搭建出各种著名的检测框架。直接起飞,接下来记录下我学习熟悉这个工具箱看的资料总结。

安装

安装官方网站地址:https://github.com/open-mmlab/mmdetection.git   提供的安装说明即可

我选择的是Docker安装,提供了一个Dockerfile来构建映像。这里提供一篇博客指导。

使用

mmdetection中文使用文档:https://mmdetection.readthedocs.io/en/latest/index.html

mmdetection整体构建流程和思想:https://zhuanlan.zhihu.com/p/337375549  https://zhuanlan.zhihu.com/p/341954021 (这个知乎博主有图有文字,说明也很清楚)

算法说明:https://blog.csdn.net/Skies_/article/details/109550241

使用fcos训练cowc数据集。后面要根据下面两张图(转载)所示的ticks,提高算法性能:

提高

1.正负样本的选取--ATSS

mmdetection有实现,更改一些配置可以开始训练。 

2.数据增强--MixUp

在mmdet/datasets/pipelines/transforms.py中 加入以下代码

@PIPELINES.register_module()
class MixUp(object):
    def __init__(self, p=0.3, lambd=0.5):
        self.lambd = lambd
        self.p = p
        self.img2 = None
        self.boxes2 = None
        self.labels2 = None

    def __call__(self, results):
        img1, boxes1, labels1 = [
            results[k] for k in ('img', 'gt_bboxes', 'gt_labels')
        ]

        if random.random() < self.p and self.img2 is not None and img1.shape[1] == self.img2.shape[1]:
            # print("********** start mixup **********")
            # print('label:', labels1,self.labels2)
            # print('boxes:', boxes1,self.boxes2)
            # self.lambd = np.random.beta(2, 2)
            # self.lambd = np.random.beta(1.5,1.5)

            height = max(img1.shape[0], self.img2.shape[0])
            width = max(img1.shape[1], self.img2.shape[1])
            mixup_image = np.zeros([height, width, 3], dtype='float32')
            mixup_image[:img1.shape[0], :img1.shape[1], :] = img1.astype('float32') * self.lambd
            mixup_image[:self.img2.shape[0], :self.img2.shape[1], :] += self.img2.astype('float32') * (1. - self.lambd)
            mixup_image = mixup_image.astype('uint8')
            # mixup_image = np.zeros([height, width, 3])

            # mixup_image[:img1.shape[0], :img1.shape[1], :] = img1 * self.lambd
            # mixup_image[:self.img2.shape[0], :self.img2.shape[1], :] += self.img2 * (1. - self.lambd) # �ϲ�
            # y1 = np.vstack((boxes1, np.full((boxes1.shape[0], 1), self.lambd)))
            # y2 = np.hstack((self.boxes2, np.full((self.boxes2.sh
  • 1
    点赞
  • 6
    收藏
    觉得还不错? 一键收藏
  • 2
    评论
评论 2
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值