运行
准备工作
此时mmdetection的版本为v1.1.0
,根据INSTALL先创建虚拟环境并且下载相关依赖,数据为coco2017
。
# 创建虚拟环境
conda create -n open-mmlab python=3.7 -y
conda activate open-mmlab
# 记得使用‘nvcc -V’查看自己cuda的版本,然后到pytorch官网下载相应版本,这里只是一个例子
conda install pytorch torchvision -c pytorch
# 克隆mmdetection
git clone https://github.com/open-mmlab/mmdetection.git
cd mmdetection
# 下载相关依赖
pip install -r requirements/build.txt
pip install "git+https://github.com/cocodataset/cocoapi.git#subdirectory=PythonAPI"
pip install -v -e . # or "python setup.py develop"
至于FCOS的论文解读,可以看我另一篇博客【ICCV2019】FCOS
修改config
对mmdetection/configs/fcos/fcos_r50_caffe_fpn_gn_1x_4gpu.py
进行修改。
# model settings
model = dict(
type='FCOS',
pretrained='/home/wh/weights/resnet50_caffe-788b5fa3.pth', #修改为自己预训练模型的路径,如果没有可以不用改。
backbone=dict(
type='ResNet',
depth=50,
num_stages=4,
out_indices=(0, 1, 2, 3), # c2,c3,c4,c5
frozen_stages=1,
norm_cfg=dict(type='BN', requires_grad=False),
style='caffe'),
neck=dict(
type='FPN',
in_channels=[256, 512, 1024, 2048],
out_channels=256,
start_level=1, # 从c3开始
add_extra_convs=True,
extra_convs_on_inputs=False, #True代表以C5为输入,False代表以P5为输出
num_outs=5,
relu_before_extra_convs=True),
bbox_head=dict(
type='FCOSHead',
num_classes=81,
in_channels=256,
stacked_convs=4,
feat_channels=256,
strides=[8, 16, 32, 64, 128],
loss_cls=dict(
type='FocalLoss',
use_sigmoid=True,
gamma=2.0,
alpha=0.25,
loss_weight=1.0),
loss_bbox=dict(type='IoULoss', loss_weight=1.0),
loss_centerness