KieDani/SegformerPlusPlus
1
1---2license: gpl-3.03language:4- en5pipeline_tag: image-segmentation6---7# SegFormer++8 9Paper: [Segformer++: Efficient Token-Merging Strategies for High-Resolution Semantic Segmentation](https://arxiv.org/abs/2405.14467)10 1112 1314 15## Abstract16 17Utilizing transformer architectures for semantic segmentation of high-resolution images is hindered by the attention's quadratic computational complexity in the number of tokens. A solution to this challenge involves decreasing the number of tokens through token merging, which has exhibited remarkable enhancements in inference speed, training efficiency, and memory utilization for image classification tasks. In this paper, we explore various token merging strategies within the framework of the SegFormer architecture and perform experiments on multiple semantic segmentation and human pose estimation datasets. Notably, without model re-training, we, for example, achieve an inference acceleration of 61% on the Cityscapes dataset while maintaining the mIoU performance. Consequently, this paper facilitates the deployment of transformer-based architectures on resource-constrained devices and in real-time applications.18 19**Update:** It is now possible to load the model via torch.hub. See [here](docs/setup/torchhub_setup.md).20 21**Update:** It is now possible to run the model **without OpenMMLab dependencies**, enabling users to utilize the SegFormerPlusPlus architecture without installing the full OpenMMLab framework.22 23## Results and Models24 25Memory refers to the VRAM requirements during the training process.26 27### Inference on Cityscapes (MiT-B5)28 29The weights of the Segformer (Original) model were used to get the inference results.30 31| Method | mIoU | Speed-Up | download |32|-----------------------------------|------:|---------:|----------------------------------------------------------------|33| Segformer (Original) | 82.39 | - | [model](https://mediastore.rz.uni-augsburg.de/get/yzE65lzm6N/) |34| Segformer++<sub>HQ</sub> (ours) | 82.31 | 1.61 | [model](https://mediastore.rz.uni-augsburg.de/get/yzE65lzm6N/) |35| Segformer++<sub>fast</sub> (ours) | 82.04 | 1.94 | [model](https://mediastore.rz.uni-augsburg.de/get/yzE65lzm6N/) |36| Segformer++<sub>2x2</sub> (ours) | 81.96 | 1.90 | [model](https://mediastore.rz.uni-augsburg.de/get/yzE65lzm6N/) |37| Segformer (Downsampling) | 77.31 | 6.51 | [model](https://mediastore.rz.uni-augsburg.de/get/yzE65lzm6N/) |38 39### Training on Cityscapes (MiT-B5)40 41| Method | mIoU | Speed-Up | Memory (GB) | download |42|-----------------------------------|------:|---------:|-------------|-----------------------------------------------------------------|43| Segformer (Original) | 82.39 | - | 48.3 | [model](https://mediastore.rz.uni-augsburg.de/get/yzE65lzm6N/) |44| Segformer++<sub>HQ</sub> (ours) | 82.19 | 1.40 | 34.0 | [model](https://mediastore.rz.uni-augsburg.de/get/i8fY8uXJrV/ ) |45| Segformer++<sub>fast</sub> (ours) | 81.77 | 1.55 | 30.5 | [model](https://mediastore.rz.uni-augsburg.de/get/cmG974iAxt/ ) |46| Segformer++<sub>2x2</sub> (ours) | 82.38 | 1.63 | 31.1 | [model](https://mediastore.rz.uni-augsburg.de/get/p0uMKbw531/) |47| Segformer (Downsampling) | 79.24 | 2.95 | 10.0 | [model](https://mediastore.rz.uni-augsburg.de/get/73zkKSO21t/) |48 49### Training on ADE20K (640x640) (MiT-B5)50 51| Method | mIoU | Speed-Up | Memory (GB) | download |52|-----------------------------------|------:|---------:|------------:|----------------------------------------------------------------|53| Segformer (Original) | 49.72 | - | 33.7 | [model](https://mediastore.rz.uni-augsburg.de/get/nKEjUHNAfK/) |54| Segformer++<sub>HQ</sub> (ours) | 49.77 | 1.15 | 29.2 | [model](https://mediastore.rz.uni-augsburg.de/get/Odyie8usgj/) |55| Segformer++<sub>fast</sub> (ours) | 49.10 | 1.20 | 28.0 | [model](https://mediastore.rz.uni-augsburg.de/get/K0IGkx4O2s/) |56| Segformer++<sub>2x2</sub> (ours) | 49.35 | 1.26 | 27.2 | [model](https://mediastore.rz.uni-augsburg.de/get/w5_Pxx4Q5C/) |57| Segformer (Downsampling) | 46.71 | 1.89 | 12.4 | [model](https://mediastore.rz.uni-augsburg.de/get/dFVvZQL6iL/) |58 59### Training on JBD60 61| Method | PCK@0.1 | PCK@0.05 | Speed-Up | Memory (GB) | download |62|-----------------------------------|--------:|---------:|---------:|------------:|----------------------------------------------------------------|63| Segformer (Original) | 95.20 | 90.65 | - | 40.0 | [model](https://mediastore.rz.uni-augsburg.de/get/psolrWXLLp/) |64| Segformer++<sub>HQ</sub> (ours) | 95.18 | 90.51 | 1.19 | 36.0 | [model](https://mediastore.rz.uni-augsburg.de/get/jx1eyecMLF/) |65| Segformer++<sub>fast</sub> (ours) | 94.58 | 89.87 | 1.25 | 34.6 | [model](https://mediastore.rz.uni-augsburg.de/get/K0IGkx4O2s/) |66| Segformer++<sub>2x2</sub> (ours) | 95.17 | 90.16 | 1.27 | 33.4 | [model](https://mediastore.rz.uni-augsburg.de/get/HumKbSB1vI/) |67 68### Training on MS COCO69 70| Method | PCK@0.1 | PCK@0.05 | Speed-Up | Memory (GB) | download |71|-----------------------------------|--------:|---------:|---------:|------------:|----------------------------------------------------------------|72| Segformer (Original) | 95.16 | 87.61 | - | 13.5 | [model](https://mediastore.rz.uni-augsburg.de/get/ZOgj2NmQLy/) |73| Segformer++<sub>HQ</sub> (ours) | 94.97 | 87.35 | 0.97 | 13.1 | [model](https://mediastore.rz.uni-augsburg.de/get/oAH5IlPxG8/) |74| Segformer++<sub>fast</sub> (ours) | 95.02 | 87.37 | 0.99 | 12.9 | [model](https://mediastore.rz.uni-augsburg.de/get/3E2mMNLAAn/) |75| Segformer++<sub>2x2</sub> (ours) | 94.98 | 87.36 | 1.24 | 12.3 | [model](https://mediastore.rz.uni-augsburg.de/get/rzlgKC5XLc/) |76 77## Usage78 79Easy usage:80- [Use the SegFormer++ easily via TorchHub](docs/setup/torchhub_setup.md)81- [Use the SegFormer++ directly](docs/setup/noopenmmlab_setup.md)82 83Explanation of the different token merging strategies:84- [Token Merging Settings](docs/run/token_merging.md)85 86Legacy Variants (e.g. as part of mmseg or mmpose) can be found on GitHub: https://github.com/KieDani/SegformerPlusPlus87 88## Citation89```bibtex90@article{kienzle2024segformer++,91 title={Segformer++: Efficient Token-Merging Strategies for High-Resolution Semantic Segmentation},92 author={Kienzle, Daniel and Kantonis, Marco and Sch{\"o}n, Robin and Lienhart, Rainer},93 journal={IEEE International Conference on Multimedia Information Processing and Retrieval (MIPR)},94 year={2024}95}96```