paper: https://arxiv.org/abs/1911.09070
code: https://github.com/SonwYang/efficientdet
前言
谷歌大脑团队的研究者发现,EfficientNets 的效率超过之前常用的主干网络。于是研究者将 EfficientNet 主干网络和 BiFPN、复合缩放结合起来,开发出新型目标检测器 EfficientDet,其准确率优于之前的目标检测器,同时参数量和 FLOPS 比它们少了一个数量级。
下图展示了 EfficientDet 的整体架构,大致遵循单阶段检测器范式。谷歌大脑团队的研究者将在 ImageNet 数据集上预训练的 EfficientNet 作为主干网络,将 BiFPN 作为特征网络,接受来自主干网络的 level 3-7 特征 {P3, P4, P5, P6, P7},并重复应用自上而下和自下而上的双向特征融合。然后将融合后的特征输入边界框/类别预测网络,分别输出目标类别和边界框预测结果。
基于遥感影像的操场检测
数据集链接:https://github.com/RSIA-LIESMARS-WHU/RSOD-Dataset-
dataset3.py
- 相关数据集格式为pascal_voc;
- 初始化参数image_dir为图片的路径;
- 初始化参数image_size为图片resize后的大小,如512
该数据生成器加载后的影像为
config.py
import torch
import glob
class Config(object):
root = 'J:/dl_dataset/object_detection/playground/JPEGImages'
class_dict = {'playground': 1}
model_name = 'tf_efficientdet_d5'
phi = model_name.split("_")[-1]
bench_task = 'train'
image_size = 512
initial_checkpoint = glob.glob(f'./model_data/tf_efficientdet_{phi}*.pth')[0]
batch_size = 2
num_workers = 0
n_epochs = 30
lr = 0.001
num_classes = 1
folder = f'effdet_{phi}-cutmix-augmix'
verbose = True
verbose_step = 1
step_scheduler = False # do scheduler.step after optimizer.step
validation_scheduler = True # do scheduler.step after validation stage loss
SchedulerClass = torch.optim.lr_scheduler.ReduceLROnPlateau
scheduler_params = dict(
mode='min',
factor=0.5,
patience=3,
verbose=False,
threshold=0.0001,
threshold_mode='abs',
cooldown=0,
min_lr=1e-8,
eps=1e-08
)
配置完config后,直接main.py即可开展模型训练。
config_eval.py
测试图片路径
class Config(object):
DATA_ROOT_PATH = 'J:/dl_dataset/object_detection/playground/test'
在predict.py中,设置模型和加载模型参数,预测结果如下图所示。