|
1 | | -# CoSA (Coming soon) |
2 | | -code for paper: Weakly Supervised Co-training with Swapping Assignments for Semantic Segmentation |
| 1 | +# CoSA [](https://eccv2024.ecva.net/) [](http://arxiv.org/abs/2402.17891) |
| 2 | + |
| 3 | +**Weakly Supervised Co-training with Swapping Assignments for Semantic Segmentation** |
| 4 | + |
| 5 | +Xinyu Yang, Hossein Rahmani, Sue Black, Bryan M. Williams |
| 6 | + |
| 7 | + |
| 8 | + |
| 9 | +[](https://paperswithcode.com/sota/weakly-supervised-semantic-segmentation-on?p=weakly-supervised-co-training-with-swapping) |
| 10 | +[](https://paperswithcode.com/sota/weakly-supervised-semantic-segmentation-on-4?p=weakly-supervised-co-training-with-swapping) |
| 11 | + |
| 12 | +## Overview |
| 13 | +We propose an end-to-end framework for WSSS: Co-training with Swapping Assignments (**CoSA**), |
| 14 | +<p align="middle"> |
| 15 | +<img src="./assets/overview.png" alt="CoSA pipeline" width="1200px"> |
| 16 | +</p> |
| 17 | + |
| 18 | +--- |
| 19 | +## Usage |
| 20 | + |
| 21 | +### 1. Data Preparation |
| 22 | + |
| 23 | +<details> |
| 24 | +<summary> |
| 25 | +COCO dataset |
| 26 | +</summary> |
| 27 | + |
| 28 | +#### 1. Download and Extract COCO 2014 |
| 29 | +``` bash |
| 30 | +mkdir coco |
| 31 | +cd coco |
| 32 | +wget http://images.cocodataset.org/zips/train2014.zip |
| 33 | +wget http://images.cocodataset.org/zips/val2014.zip |
| 34 | +wget http://images.cocodataset.org/zips/test2014.zip |
| 35 | +unzip ./train2014.zip |
| 36 | +unzip ./val2014.zip |
| 37 | +unzip ./test2014.zip |
| 38 | +``` |
| 39 | + |
| 40 | +#### 2. Download Segmentation Labels |
| 41 | + |
| 42 | +[Here](https://drive.google.com/file/d/147kbmwiXUnd2dW9_j8L5L0qwFYHUcP9I/view?usp=share_link) to download the COCO segmentation labels `coco_anno.tar` and move it to `coco` dir. |
| 43 | +After that you should extract it by running: |
| 44 | +```bash |
| 45 | +tar -xvf coco_anno.tar |
| 46 | +``` |
| 47 | +then you should have a directory structure like this (the number in the brackets is the number of images): |
| 48 | +``` bash |
| 49 | +coco/ |
| 50 | +├── SegmentationClass |
| 51 | +│ ├── train2014 (82081) |
| 52 | +│ └── val2014 (40137) |
| 53 | +├── test2014 (40775) |
| 54 | +├── train2014 (82783) |
| 55 | +└── val2014 (40504) |
| 56 | +``` |
| 57 | +</details> |
| 58 | + |
| 59 | +<details> |
| 60 | +<summary> |
| 61 | +VOC dataset |
| 62 | +</summary> |
| 63 | + |
| 64 | +#### 1. Download PASCAL VOC 2012 and Extract |
| 65 | + |
| 66 | +``` bash |
| 67 | +wget http://host.robots.ox.ac.uk/pascal/VOC/voc2012/VOCtrainval_11-May-2012.tar |
| 68 | +tar –xvf VOCtrainval_11-May-2012.tar |
| 69 | +``` |
| 70 | +#### 2. Download the augmented annotations |
| 71 | +[Here](https://www.dropbox.com/s/oeu149j8qtbs1x0/SegmentationClassAug.zip?dl=0) is a download link of the augmented annotations. After downloading ` SegmentationClassAug.zip `, you should unzip it and move it to `VOCdevkit/VOC2012`. The directory structure should be like this (the number in the brackets is the number of images): |
| 72 | + |
| 73 | +``` bash |
| 74 | +VOCdevkit/ |
| 75 | +└── VOC2012 |
| 76 | + ├── Annotations |
| 77 | + ├── ImageSets |
| 78 | + ├── JPEGImages (17125) |
| 79 | + ├── SegmentationClass |
| 80 | + ├── SegmentationClassAug (12031) |
| 81 | + └── SegmentationObject (2913) |
| 82 | +``` |
| 83 | +</details> |
| 84 | + |
| 85 | + |
| 86 | +### 2. Setup Python Environment |
| 87 | +We recommend using Anaconda to create a virtual environment. |
| 88 | +``` bash |
| 89 | + conda create -yn cosa python=3.10 pip wheel |
| 90 | + conda activate cosa |
| 91 | + pip install -r requirements.txt |
| 92 | +``` |
| 93 | +after that, you can install some extension packages: `mmcv`, `bilateralfilter` and `pydensecrf` by running: |
| 94 | +``` bash |
| 95 | +mim install mmcv-lite |
| 96 | +pip install git+https://github.com/lucasb-eyer/pydensecrf.git |
| 97 | +cd utils/bilateralfilter |
| 98 | +#sudo apt install swig |
| 99 | +swig -python -c++ bilateralfilter.i |
| 100 | +python setup.py install |
| 101 | +``` |
| 102 | +## 3. Train and Evaluate |
| 103 | +``` bash |
| 104 | + |
| 105 | +### train and eval coco, you may need to modify the `coco_root` in `run_coco.sh` to the path of your COCO dataset. |
| 106 | +sh run_coco.sh |
| 107 | + |
| 108 | +### train and eval voc, you may need to modify the `voc12_root` in `run_voc.sh` to the path of your VOC dataset. |
| 109 | +sh run_voc.sh |
| 110 | + |
| 111 | +``` |
| 112 | + |
| 113 | +## Tested Environment |
| 114 | +- Ubuntu 20.04 LTS x86_64 |
| 115 | +- CUDA 12.1 |
| 116 | +- NVIDIA GeForce RTX 3090 x2 |
| 117 | +- Python 3.10 |
| 118 | + |
| 119 | +## Our Results |
| 120 | +Semantic performance on VOC and COCO. Logs and weights are available now. |
| 121 | +| Dataset | Backbone | Val | Test | Log | Weight | |
| 122 | +| :-------: | :--------: | :-----: | :----: | :---: | :------: | |
| 123 | +| COCO | ViT-B | 51.0 | - | [log](assets/logs/coco_log.txt) | [weight]() | |
| 124 | +| VOC | ViT-B | 76.2 | [75.1](http://host.robots.ox.ac.uk:8080/anonymous/GOZOHI.html) | [log](assets/logs/voc_log.txt) | [weight]() | |
| 125 | + |
| 126 | +Visualization results for CoSA comparing with [MCT](https://github.com/xulianuwa/MCTformer), [ToCo](https://github.com/rulixiang/ToCo) and [BECO](https://github.com/ShenghaiRong/BECO) on COCO: |
| 127 | + |
| 128 | +<p align="middle"> |
| 129 | +<img src="./assets/coco1.png" alt="COCO Visual1" width="1200px"> |
| 130 | +</p> |
| 131 | + |
| 132 | +<p align="middle"> |
| 133 | +<img src="./assets/coco2.png" alt="COCO Visual2" width="1200px"> |
| 134 | +</p> |
| 135 | + |
| 136 | +Visualization results for CoSA comparing with [MCT](https://github.com/xulianuwa/MCTformer), [ToCo](https://github.com/rulixiang/ToCo) and [BECO](https://github.com/ShenghaiRong/BECO) on VOC: |
| 137 | + |
| 138 | +<p align="middle"> |
| 139 | +<img src="./assets/voc1.png" alt="VOC Visual1" width="1200px"> |
| 140 | +</p> |
| 141 | + |
| 142 | + |
| 143 | +The code and weights for CoSA-MS are coming soon. |
| 144 | + |
| 145 | +## Citation |
| 146 | +Please cite our work if you find it helpful: |
| 147 | +```bash |
| 148 | +@article{yang2024weakly, |
| 149 | + title={Weakly supervised co-training with swapping assignments for semantic segmentation}, |
| 150 | + author={Yang, Xinyu and Rahmani, Hossein and Black, Sue and Williams, Bryan M}, |
| 151 | + journal={arXiv preprint arXiv:2402.17891}, |
| 152 | + year={2024} |
| 153 | +} |
| 154 | + |
| 155 | +``` |
| 156 | + |
| 157 | + |
| 158 | +## Acknowledgement |
| 159 | +This repo is heavily built upon [ToCo](https://github.com/rulixiang/ToCo) and [MCT](https://github.com/xulianuwa/MCTformer). Please consider citing their works if you find this repo helpful. |
0 commit comments