CenterMask論文記錄和模型訓練
創新點
- a novel spatial attention-guided mask (SAG-Mask) branch to anchor-free one stage object detector
SAG-Mask
在分割任務中在預測mask的卷積層中加入注意力機制 SAM
- Backbone : VoVNetV2, with two effective strategies: (1) add residual connection into each OSA module to ease optimization for alleviating the optimization problem of larger VoVNet [19] and (2)effective Squeeze-Excitation (eSE) dealing with the channelinformation loss problem of original SE.
OSA
One-Shot Aggregation
DenseNet在目標檢測任務上表現很好。因為它通過聚合不同receptive field特徵層的方式,保留了中間特徵層的資訊。它通過feature reuse 使得模型的大小和flops大大降低,但是,實驗證明,DenseNet backbone更加耗時也增加了能耗:dense connection架構使得輸入channel線性遞增,導致了更多的記憶體訪問消耗,進而導致更多的計算消耗和能耗。
在OSA module中,每一層產生兩種連線,一種是通過conv和下一層連線,產生receptive field 更大的feature map,另一種是和最後的輸出層相連,以聚合足夠好的特徵。
eSE
Squeeze-Excitation (SE) [13] channel attention module 減少了通道數,這樣雖然減少了計算成本,但是造成了通道資訊損失
提出eSE模組,用channel-wise global average pooling保留通道維度,然後接1個C維度的全連線層
計算公式:
關鍵點
one stage / anchor free / attention module
組成部分
(1) backbone for feature extraction
VoVNetV2
在VoVNet基礎上增加了 residual connection 和 eSE注意力模組
(2) FCOS [33] :detection head
an anchor-free and proposal-free object detection in a per-pixel prediction manner as like FCN
(3) mask head :The procedure of masking objects is composed of detecting objects from the FCOS [33] box head and then predicting segmentation masks inside the cropped regionsin a per-pixel manner
Adaptive RoI Assignment Function
根據RoI scales對RoIs對映到不同層次的feature map上,大尺度的roi對映到高層的feature level
對應對映關係可計算:
安裝
pip install cython
pip install -U 'git+https://github.com/cocodataset/cocoapi.git#subdirectory=PythonAPI'
pip install -i https://pypi.douban.com/simple/ pyyaml==5.1.1
python -m pip install 'git+https://github.com/facebookresearch/detectron2.git'
python -m pip install detectron2 -f https://dl.fbaipublicfiles.com/detectron2/wheels/cu101/torch1.5/index.html
git clone https://github.com/youngwanLEE/centermask2.git
修改資料集地址: /usr/local/lib/python3.6/dist-packages/detectron2/data/datasets/builtin.py
# Register them all under "./datasets"
_root = os.getenv("DETECTRON2_DATASETS", "datasets")
改為
# Register them all under "./datasets"
_root = os.getenv("DETECTRON2_DATASETS", "/xxx/xxx/")
Config:
/home/centermask2/configs/centermask/centermask_V_39_eSE_FPN_ms_3x.yaml
Train:
CUDA_VISIBLE_DEVICES=2,3 python train_net.py --config-file "configs/centermask/centermask_V_39_eSE_FPN_ms_3x.yaml" --num-gpus 2
CUDA_VISIBLE_DEVICES=0,1,2,3 python train_net.py --config-file "configs/centermask/centermask_V_39_eSE_FPN_ms_3x.yaml" --num-gpus 4
Test:
python train_net.py --config-file "configs/centermask/centermask_V_39_eSE_FPN_ms_3x.yaml" --num-gpus 1 --eval-only MODEL.WEIGHTS output/centermask/CenterMask-V-39-ms-3x/model_0019999.pth