目标检测Anchor-free FCOS网络训练自己数据集(VOC格式)

FCOS测试:

论文参考博主另一篇博客:论文阅读【FCOS】
在这里插入图片描述

YOLO V3测试:

在这里插入图片描述

一、环境配置:

2种方案,源码更清晰一点,mm框架的训练方便。

  1. 直接项目源码:https://github.com/tianzhi0549/FCOS ,截止目前 pytorch每天都在更新nightly(测试)版本,建议安装最新稳定(stable)版pytorch=1.3.1, torchvision=0.4.2, cudatoolkit=10.0匹配cuda10.0,使用命令nvcc -V 查下你当前的cuda版本,最后执行命令:
# first, make sure that your conda is setup properly with the right environment
# for that, check that `which conda`, `which pip` and `which python` points to the
# right path. From a clean conda env, this is what you need to do

conda create --name FCOS
conda activate FCOS

# this installs the right pip and dependencies for the fresh python
conda install ipython

# FCOS and coco api dependencies
pip install ninja yacs cython matplotlib tqdm

# follow PyTorch installation in https://pytorch.org/get-started/locally/
# we give the instructions for CUDA 9.0
conda install -c pytorch==1.3.1 torchvision=0.4.2 cudatoolkit=10.0



# install pycocotools. Please make sure you have installed cython.
cd到home/xxx下
git clone https://github.com/cocodataset/cocoapi.git
cd cocoapi/PythonAPI
python setup.py build_ext install

# install PyTorch Detection
cd到home/xxx下
git clone https://github.com/tianzhi0549/FCOS.git
cd FCOS

# the following will install the lib with
# symbolic links, so that you can modify
# the files if you want and won't need to
# re-build it
激活fcos环境再编译 source activate FCOS
python setup.py build develop --no-deps

2.搭建mmdetection:

参考:https://github.com/open-mmlab/mmdetection
mmdetection安装文档详见:https://github.com/open-mmlab/mmdetection/blob/master/docs/INSTALL.md

mmcv安装文档详见: https://github.com/open-mmlab/mmcv

要求

  • Linux (Windows is not officially supported)
  • Python 3.5+ (Python 2 is not supported)
  • PyTorch 1.1 or higher
  • CUDA 9.0 or higher
  • NCCL 2
  • GCC(G++) 4.9 or higher
  • mmcv

注:这里安装前一般把 NCCL 和 MMCV提前安装好

安装虚拟环境

conda还是好一点,装局部的话,安装过成中 将 set conda python那个选 no,就不会改变系统python 装局部启动环境时
执行:

cd anacond3/bin
source activate 
source activate open-mmlab

不要忙着启动了,还没搭环境呢,anaconda安装好之后执行:

a. Create a conda virtual environment and activate it.

conda create -n open-mmlab python=3.7 -y
conda activate open-mmlab

b. Install PyTorch stable or nightly and torchvision following the official instructions, e.g.,

conda install pytorch torchvision -c pytorch

c. Clone the mmdetection repository.

git clone https://github.com/open-mmlab/mmdetection.git
cd mmdetection

d. Install mmdetection (other dependencies will be installed automatically).

python setup.py develop
# or "pip install -v -e ."

二、制作VOC格式数据集:

这里没有用coco格式,原作者代码解析coco官方数据集没问题,博主自己转换的就有问题,这里我看了coco API借口也没发现自己制作的问题,算了赶时间我就换VOC格式,VOC相比COCO能简单,COCO数据集无用的信息太多了。

参考:https://blog.csdn.net/u011574296/article/details/78953681
这个网上很多,如果不想制作看博主一篇文章:我们直接提取VOC,或者COCO的某几类作为自己的数据集,博主提取COCO的person一类哈 :
提取VOC或COCO某几类数据集:https://blog.csdn.net/weixin_38632246/article/details/97141364:

三、实验细节:

修改配置文件~ /mmdetection/config/fcos/fcos_r50_caffe_fpn_gn_1x_4gpu.py

# model settings
model = dict(
    type='FCOS',
    pretrained='/home/rock/mmdetection/configs/fcos/resnet50_caffe-788b5fa3.pth',  #这个可以不改,默认直接下载
    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=False
评论 48
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值