以下链接是个人关于mmdetection(Foveabox-目标检测框架)所有见解,如有错误欢迎大家指出,我会第一时间纠正。有兴趣的朋友可以加微信:a944284742相互讨论技术。若是帮助到了你什么,一定要记得点赞!因为这是对我最大的鼓励。
文
末
附
带
\color{blue}{文末附带}
文末附带
公
众
号
−
\color{blue}{公众号 -}
公众号−
海
量
资
源
。
\color{blue}{ 海量资源}。
海量资源。
目标检测00-00:mmdetection(Foveabox为例)-目录-史上最新无死角讲解
前言
该章节的内容比较单调,把 cfg 文件注释单独作为一篇博客列出来,是为了大家方便查找和分析(如果有错误的地方,需要大家及时指出)。本人在进行测试训练的时候,就是使用该配置,对应的数据集已经在前面的博客公布了。
m
m
d
e
t
e
c
t
i
o
n
的
c
o
n
f
i
g
文
件
不
能
存
在
中
文
注
释
,
所
以
我
提
供
了
两
个
版
本
,
即
:
注
释
版
本
,
和
非
注
释
版
\color{red}{mmdetection 的 config 文件不能存在中文注释,所以我提供了两个版本,即:注释版本,和非注释版}
mmdetection的config文件不能存在中文注释,所以我提供了两个版本,即:注释版本,和非注释版 复制
非
注
释
的
代
码
\color{blue}{非注释的代码 }
非注释的代码 到 configs/foveabox/my_fovea_r50_fpn_4x4_2x_coco.py (自行创建)之中。
注释版本:
dataset_type
= 'MyCocoDataset'
data_root
= './data/coco_meter/'
model
= dict(
type='FOVEA',
pretrained
='torchvision://resnet50',
backbone
=dict(
type='ResNet',
depth
=50,
num_stages
=4,
out_indices
=(0, 1, 2, 3),
frozen_stages
=1,
norm_cfg
=dict(type='BN', requires_grad
=True),
norm_eval
=True,
style
='pytorch'),
neck
=dict(
type='FPN',
in_channels
=[256, 512, 1024, 2048],
out_channels
=256,
start_level
=1,
num_outs
=5,
add_extra_convs
='on_input'),
bbox_head
=dict(
type='FoveaHead',
num_classes
=1,
in_channels
=256,
stacked_convs
=4,
feat_channels
=256,
strides
=[8, 16, 32, 64, 128],
base_edge_list
=[16, 32, 64, 128, 256],
scale_ranges
=((1, 64), (32, 128), (64, 256), (128, 512), (256, 2048)),
sigma
=0.4,
with_deform
=False,
loss_cls
=dict(
type='FocalLoss',
use_sigmoid
=True,
gamma
=1.50,
alpha
=0.4,
loss_weight
=1.0),
loss_bbox
=dict(type='SmoothL1Loss', beta
=0.11, loss_weight
=1.0)))
train_cfg
= dict()
test_cfg
= dict(
nms_pre
=1000,
score_thr
=0.05,
nms
=dict(type='nms', iou_threshold
=0.5),
max_per_img
=100)
img_norm_cfg
= dict(
mean
=[123.675, 116.28, 103.53],
std
=[58.395, 57.12, 57.375],
to_rgb
=True)
train_pipeline
= [
dict(type='LoadImageFromFile'),
dict(type='LoadAnnotations', with_bbox
=True),
dict(type='Resize', img_scale
=(640, 480), keep_ratio
=True),
dict(type='RandomFlip', flip_ratio
=0.5),
dict(type='Normalize', **img_norm_cfg
),
dict(type='Pad', size_divisor
=32),
dict(type='DefaultFormatBundle'),
dict(type='Collect', keys
=['img', 'gt_bboxes', 'gt_labels']),
]
test_pipeline
= [
dict(type='LoadImageFromFile'),
dict(
type='MultiScaleFlipAug',
img_scale
=(640, 480),
flip
=False,
transforms
=[
dict(type='Resize', keep_ratio
=True),
dict(type='RandomFlip'),
dict(type='Normalize', **img_norm_cfg
),
dict(type='Pad', size_divisor
=32),
dict(type='ImageToTensor', keys
=['img']),
dict(type='Collect', keys
=['img']),
])
]
data
= dict(
samples_per_gpu
=2,
workers_per_gpu
=2,
train
=dict(
type=dataset_type
,
ann_file
=data_root
+ 'annotations/train.json',
img_prefix
=data_root
+ 'train/',
pipeline
=train_pipeline
),
val
=dict(
type=dataset_type
,
ann_file
=data_root
+ 'annotations/test.json',
img_prefix
=data_root
+ 'test/',
pipeline
=test_pipeline
),
test
=dict(
type=dataset_type
,
ann_file
=data_root
+ 'annotations/test.json',
img_prefix
=data_root
+ 'test/',
pipeline
=test_pipeline
))
optimizer
= dict(type='SGD',
lr
=0.002,
momentum
=0.9,
weight_decay
=0.0001)
optimizer_config
= dict(grad_clip
=None)
lr_config
= dict(
policy
='step',
warmup
='linear',
warmup_iters
=500,
warmup_ratio
=0.001,
step
=[100, 150])
total_epochs
= 200
log_config
= dict(
interval
=50,
hooks
=[
dict(type='TextLoggerHook'),
])
dist_params
= dict(backend
='nccl')
log_level
= 'INFO'
load_from
= None
resume_from
= None
workflow
= [('train', 1)]
checkpoint_config
= dict(interval
=10)
evaluation
= dict(interval
=10, metric
='bbox', classwise
=True)
非注释版
dataset_type
= 'MyCocoDataset'
data_root
= './data/coco_meter/'
model
= dict(
type='FOVEA',
pretrained
='torchvision://resnet50',
backbone
=dict(
type='ResNet',
depth
=50,
num_stages
=4,
out_indices
=(0, 1, 2, 3),
frozen_stages
=1,
norm_cfg
=dict(type='BN', requires_grad
=True),
norm_eval
=True,
style
='pytorch'),
neck
=dict(
type='FPN',
in_channels
=[256, 512, 1024, 2048],
out_channels
=256,
start_level
=1,
num_outs
=5,
add_extra_convs
='on_input'),
bbox_head
=dict(
type='FoveaHead',
num_classes
=1,
in_channels
=256,
stacked_convs
=4,
feat_channels
=256,
strides
=[8, 16, 32, 64, 128],
base_edge_list
=[16, 32, 64, 128, 256],
scale_ranges
=((1, 64), (32, 128), (64, 256), (128, 512), (256, 2048)),
sigma
=0.4,
with_deform
=False,
loss_cls
=dict(
type='FocalLoss',
use_sigmoid
=True,
gamma
=1.50,
alpha
=0.4,
loss_weight
=1.0),
loss_bbox
=dict(type='SmoothL1Loss', beta
=0.11, loss_weight
=1.0)))
train_cfg
= dict()
test_cfg
= dict(
nms_pre
=1000,
score_thr
=0.05,
nms
=dict(type='nms', iou_threshold
=0.5),
max_per_img
=100)
img_norm_cfg
= dict(
mean
=[123.675, 116.28, 103.53],
std
=[58.395, 57.12, 57.375],
to_rgb
=True)
train_pipeline
= [
dict(type='LoadImageFromFile'),
dict(type='LoadAnnotations', with_bbox
=True),
dict(type='Resize', img_scale
=(640, 480), keep_ratio
=True),
dict(type='RandomFlip', flip_ratio
=0.5),
dict(type='Normalize', **img_norm_cfg
),
dict(type='Pad', size_divisor
=32),
dict(type='DefaultFormatBundle'),
dict(type='Collect', keys
=['img', 'gt_bboxes', 'gt_labels']),
]
test_pipeline
= [
dict(type='LoadImageFromFile'),
dict(
type='MultiScaleFlipAug',
img_scale
=(640, 480),
flip
=False,
transforms
=[
dict(type='Resize', keep_ratio
=True),
dict(type='RandomFlip'),
dict(type='Normalize', **img_norm_cfg
),
dict(type='Pad', size_divisor
=32),
dict(type='ImageToTensor', keys
=['img']),
dict(type='Collect', keys
=['img']),
])
]
data
= dict(
samples_per_gpu
=2,
workers_per_gpu
=2,
train
=dict(
type=dataset_type
,
ann_file
=data_root
+ 'annotations/train.json',
img_prefix
=data_root
+ 'train/',
pipeline
=train_pipeline
),
val
=dict(
type=dataset_type
,
ann_file
=data_root
+ 'annotations/test.json',
img_prefix
=data_root
+ 'test/',
pipeline
=test_pipeline
),
test
=dict(
type=dataset_type
,
ann_file
=data_root
+ 'annotations/test.json',
img_prefix
=data_root
+ 'test/',
pipeline
=test_pipeline
))
optimizer
= dict(type='SGD',
lr
=0.002,
momentum
=0.9,
weight_decay
=0.0001)
optimizer_config
= dict(grad_clip
=None)
lr_config
= dict(
policy
='step',
warmup
='linear',
warmup_iters
=500,
warmup_ratio
=0.001,
step
=[100, 150])
total_epochs
= 200
log_config
= dict(
interval
=50,
hooks
=[
dict(type='TextLoggerHook'),
])
dist_params
= dict(backend
='nccl')
log_level
= 'INFO'
load_from
= None
resume_from
= None
workflow
= [('train', 1)]
checkpoint_config
= dict(interval
=10)
evaluation
= dict(interval
=10, metric
='bbox')