# SEAM
The implementation of [**Self-supervised Equivariant Attention Mechanism for Weakly Supervised Semantic Segmentaion**](https://arxiv.org/abs/2004.04581).
You can also download the repository from [https://gitee.com/hibercraft/SEAM](https://gitee.com/hibercraft/SEAM)
## Abstract
Image-level weakly supervised semantic segmentation is a challenging problem that has been deeply studied in recentyears. Most of advanced solutions exploit class activation map (CAM). However, CAMs can hardly serve as the object mask due to the gap between full and weak supervisions. In this paper, we propose a self-supervised equivariant attention mechanism (SEAM) to discover additional supervision and narrow the gap. Our method is based on the observation that equivariance is an implicit constraint in fully supervised semantic segmentation, whose pixel-level labels take the same spatial transformation as the input images during data augmentation. However, this constraint is lost on the CAMs trained by image-level supervision. Therefore, we propose consistency regularization on predicted CAMs from various transformed images to provide self-supervision for network learning. Moreover, we propose a pixel correlation module (PCM), which exploits context appearance information and refines the prediction of current pixel by its similar neighbors, leading to further improvement on CAMs consistency. Extensive experiments on PASCAL VOC 2012 dataset demonstrate our method outperforms state-of-the-art methods using the same level of supervision.
Thanks to the work of [jiwoon-ahn](https://github.com/jiwoon-ahn), the code of this repository borrow heavly from his [AffinityNet](https://github.com/jiwoon-ahn/psa) repository, and we follw the same pipeline to verify the effectiveness of our SEAM.
## Requirements
- Python 3.6
- pytorch 0.4.1, torchvision 0.2.1
- CUDA 9.0
- 4 x GPUs (12GB)
## Usage
### Installation
- Download the repository.
```
git clone https://github.com/YudeWang/SEAM.git
```
- Install python dependencies.
```
pip install -r requirements.txt
```
- **Download model weights from [google drive](https://drive.google.com/open?id=1jWsV5Yev-PwKgvvtUM3GnY0ogb50-qKa) or [baidu cloud](https://pan.baidu.com/s/1ymaMeF0ASjQ9oCGI9cmqHQ) (with code 6nmo)**, including ImageNet pretrained models and our training results.
- Download PASCAL VOC 2012 devkit (follow instructions in http://host.robots.ox.ac.uk/pascal/VOC/voc2012/#devkit). It is suggested to make a soft link toward downloaded dataset.
```
ln -s $your_dataset_path/VOCdevkit/VOC2012 VOC2012
```
- (Optional) The image-level labels have already been given in `voc12/cls_label.npy`. If you want to regenerate it (which is unnecessary), please download the annotation of VOC 2012 SegmentationClassAug training set (containing 10582 images), which can be download [here](https://www.dropbox.com/s/oeu149j8qtbs1x0/SegmentationClassAug.zip?dl=0) and place them all as `VOC2012/SegmentationClassAug/xxxxxx.png`. Then run the code
```
cd voc12
python make_cls_labels.py --voc12_root VOC2012
```
### SEAM step
1. SEAM training
```
python train_SEAM.py --voc12_root VOC2012 --weights $pretrained_model --session_name $your_session_name
```
2. SEAM inference.
```
python infer_SEAM.py --weights $SEAM_weights --infer_list [voc12/val.txt | voc12/train.txt | voc12/train_aug.txt] --out_cam $your_cam_dir --out_crf $your_crf_dir
```
3. SEAM step evaluation. We provide python mIoU evaluation script `evaluation.py`, or you can use official development kit. Here we suggest to show the curve of mIoU with different background score.
```
python evaluation.py --list VOC2012/ImageSets/Segmentation/[val.txt | train.txt] --predict_dir $your_cam_dir --gt_dir VOC2012/SegmentationClass --comment $your_comments --type npy --curve True
```
### Random walk step
The random walk step keep the same with AffinityNet repository.
1. Train AffinityNet.
```
python train_aff.py --weights $pretrained_model --voc12_root VOC2012 --la_crf_dir $your_crf_dir_4.0 --ha_crf_dir $your_crf_dir_24.0 --session_name $your_session_name
```
2. Random walk propagation
```
python infer_aff.py --weights $aff_weights --infer_list [voc12/val.txt | voc12/train.txt] --cam_dir $your_cam_dir --voc12_root VOC2012 --out_rw $your_rw_dir
```
3. Random walk step evaluation
```
python evaluation.py --list VOC2012/ImageSets/Segmentation/[val.txt | train.txt] --predict_dir $your_rw_dir --gt_dir VOC2012/SegmentationClass --comment $your_comments --type png
```
### Pseudo labels retrain
Pseudo label retrain on DeepLabv1. Code is available [here](https://github.com/YudeWang/semantic-segmentation-codebase/tree/main/experiment/seamv1-pseudovoc).
## Citation
Please cite our paper if the code is helpful to your research.
```
@InProceedings{Wang_2020_CVPR_SEAM,
author = {Yude Wang and Jie Zhang and Meina Kan and Shiguang Shan and Xilin Chen},
title = {Self-supervised Equivariant Attention Mechanism for Weakly Supervised Semantic Segmentation},
booktitle = {Proc. IEEE Conference on Computer Vision and Pattern Recognition (CVPR)},
year = {2020}
}
```
## Reference
[1] J. Ahn and S. Kwak. Learning pixel-level semantic affinity with image-level supervision for weakly supervised semantic segmentation. In Proc. IEEE Conference on Computer Vision and Pattern Recognition (CVPR), 2018.
没有合适的资源?快使用搜索试试~ 我知道了~
SEAM:弱监督语义分割的自监督等变注意机制,CVPR 2020(口头)
共24个文件
py:14个
txt:6个
png:1个
需积分: 26 8 下载量 167 浏览量
2021-05-29
13:00:56
上传
评论 1
收藏 987KB ZIP 举报
温馨提示
接缝 的。 您还可以从下载存储库 抽象的 图像级弱监督语义分割是近年来深入研究的一个具有挑战性的问题。 大多数高级解决方案利用类激活图 (CAM)。 然而,由于全监督和弱监督之间的差距,CAM 很难作为对象掩码。 在本文中,我们提出了一种自监督的等变注意机制(SEAM)来发现额外的监督并缩小差距。 我们的方法基于观察到等方差是完全监督语义分割中的隐式约束,其像素级标签在数据增强期间采用与输入图像相同的空间变换。 然而,这种约束在通过图像级监督训练的 CAM 上丢失了。 因此,我们建议对来自各种转换图像的预测 CAM 进行一致性正则化,以提供网络学习的自我监督。 此外,我们提出了一个像素相关模块(PCM),它利用上下文外观信息并通过其相似的邻居细化当前像素的预测,从而进一步提高 CAM 的一致性。 在 PASCAL VOC 2012 数据集上进行的大量实验表明,我们的方法优于使用相同监督级
资源详情
资源评论
资源推荐
收起资源包目录
SEAM-master.zip (24个子文件)
SEAM-master
network.png 425KB
train_aff.py 6KB
requirements.txt 228B
infer_aff.py 6KB
LICENSE 1KB
network
resnet38d.py 8KB
resnet38_SEAM.py 3KB
resnet38_aff.py 4KB
README.md 5KB
train_SEAM.py 10KB
evaluation.py 5KB
tool
visualization.py 4KB
imutils.py 7KB
pyutils.py 5KB
torchutils.py 6KB
infer_SEAM.py 5KB
voc12
train_aug.txt 682KB
test.txt 40KB
make_cls_labels.py 786B
trainaug_val.txt 775KB
train.txt 94KB
val.txt 93KB
cls_labels.npy 2.01MB
data.py 11KB
共 24 条
- 1
歪头羊
- 粉丝: 35
- 资源: 4651
上传资源 快速赚钱
- 我的内容管理 展开
- 我的资源 快来上传第一个资源
- 我的收益 登录查看自己的收益
- 我的积分 登录查看自己的积分
- 我的C币 登录后查看C币余额
- 我的收藏
- 我的下载
- 下载帮助
安全验证
文档复制为VIP权益,开通VIP直接复制
信息提交成功
评论0