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