ssformer

A lightweight model for semantic segmentation

https://github.com/shiwt03/ssformer

Science Score: 44.0%

This score indicates how likely this project is to be science-related based on various indicators:

  • CITATION.cff file
    Found CITATION.cff file
  • codemeta.json file
    Found codemeta.json file
  • .zenodo.json file
    Found .zenodo.json file
  • DOI references
  • Academic publication links
  • Academic email domains
  • Institutional organization owner
  • JOSS paper metadata
  • Scientific vocabulary similarity
    Low similarity (12.1%) to scientific vocabulary
Last synced: 9 months ago · JSON representation ·

Repository

A lightweight model for semantic segmentation

Basic Info
  • Host: GitHub
  • Owner: shiwt03
  • License: apache-2.0
  • Language: Python
  • Default Branch: main
  • Size: 21.2 MB
Statistics
  • Stars: 34
  • Watchers: 1
  • Forks: 8
  • Open Issues: 2
  • Releases: 0
Created about 4 years ago · Last pushed over 3 years ago
Metadata Files
Readme License Citation

README.md

SSformer

SSformer is A Lightweight Transformer for Semantic Segmentation.

SSformer structure:

We use MMSegmentation v0.24.1 as the codebase.

Installation

For install , please refer to the guidelines in MMSegmentation v0.24.1.

An example (works for me): CUDA 11.3 and pytorch 1.10.0

A from-scratch setup script

Linux

Here is a full script for setting up SSformer with conda and link the dataset path (supposing that your dataset path is $DATA_ROOT).

shell conda create -n SSformer python=3.10 -y conda activate SSformer conda install pytorch=1.11.0 torchvision cudatoolkit=11.3 -c pytorch pip install mmcv-full -f https://download.openmmlab.com/mmcv/dist/cu113/torch1.11.0/index.html git clone https://github.com/shiwt03/SSformer.git cd SSformer pip install -e . # or "python setup.py develop" mkdir data ln -s $DATA_ROOT data

Windows(Experimental)

Here is a full script for setting up SSformer with conda and link the dataset path (supposing that your dataset path is %DATA_ROOT%. Notice: It must be an absolute path).

shell conda create -n SSformer python=3.10 -y conda activate SSformer conda install pytorch=1.11.0 torchvision cudatoolkit=11.3 -c pytorch set PATH=full\path\to\your\cpp\compiler;%PATH% pip install mmcv git clone https://github.com/shiwt03/SSformer.git cd SSformer pip install -e . # or "python setup.py develop" mklink /D data %DATA_ROOT%

Dataset Preparation

For dataset preparation, please refer to the guidelines in this link.

It is recommended to symlink the dataset root to SSformer/data. If your folder structure is different, you may need to change the corresponding paths in config files.

The fold structure is recommended to be: none SSformer ├── data │ ├── cityscapes │ │ ├── leftImg8bit │ │ │ ├── train │ │ │ ├── val │ │ ├── gtFine │ │ │ ├── train │ │ │ ├── val │ ├── ade │ │ ├── ADEChallengeData2016 │ │ │ ├── annotations │ │ │ │ ├── training │ │ │ │ ├── validation │ │ │ ├── images │ │ │ │ ├── training │ │ │ │ ├── validation

Cityscapes

The data could be found here after registration.

By convention, **labelTrainIds.png are used for cityscapes training. MMsegmentation provided a script based on cityscapesscripts to generate **labelTrainIds.png.

```shell

--nproc means 8 process for conversion, which could be omitted as well.

python tools/convert_datasets/cityscapes.py data/cityscapes --nproc 8 ``` Part of SSformer's segmentation results on Cityscapes: image

ADE20K

The training and validation set of ADE20K could be download from this link. You may also download test set from here.

Part of SSformer's segmentation results on ADE20K: image

Evaluation

Download trained weights.

ADE20K

Example: evaluate SSformer on ADE20K: ```shell

Single-gpu testing

python tools/test.py configs/SSformer/SSformerswin512x512160kade20k.py /path/to/checkpoint_file --show ```

Cityscapes

Example: evaluate SSformer on Cityscapes: ```shell

Single-gpu testing

python tools/test.py configs/SSformer/SSformerswin1024x1024160kCityscapes.py /path/to/checkpoint_file --show ```

Training

Download weights pretrained on ImageNet-22K, and put them in a folder pretrained/.

Example: train SSFormer on ADE20K: ```shell

Single-gpu training

python tools/train.py configs/SSformer/SSformerswin512x512160kade20k.py ```

Visualize

Here is a demo script to test a single image. More details refer to MMSegmentation's Doc. python demo/image_demo.py ${IMAGE_FILE} ${CONFIG_FILE} ${CHECKPOINT_FILE} [--device ${DEVICE_NAME}] [--palette-thr ${PALETTE}]

Example: visualize SSformer on CityScapes:

shell python demo/image_demo.py demo/demo.png configs/SSformer/SSformer_swin_1024x1024_80k_Cityscapes.py \ /path/to/checkpoint_file --device cuda:0 --palette cityscapes

License

Please check the LICENSE file.

Acknowledgment

Thanks to previous open-sourced repo: mmsegmentation Swin-Transformer SegFormer

Owner

  • Name: 施文韬
  • Login: shiwt03
  • Kind: user
  • Location: China
  • Company: Nanjing University of Aeronautics and Astronautics

Citation (CITATION.cff)

cff-version: 1.2.0
message: "If you use this software, please cite it as below."
authors:
  - name: "Pan Gao, Jing Xu, Wentao Shi"
title: "SSformer: A Lightweight Transformer for Semantic Segmentation."
date-released: 2022-05-11
url: "https://github.com/shiwt03/SSformer"
license: Apache-2.0

GitHub Events

Total
  • Watch event: 2
  • Fork event: 1
Last Year
  • Watch event: 2
  • Fork event: 1

Dependencies

requirements/docs.txt pypi
  • docutils ==0.16.0
  • myst-parser *
  • sphinx ==4.0.2
  • sphinx_copybutton *
  • sphinx_markdown_tables *
requirements/mminstall.txt pypi
  • mmcls >=0.20.1
  • mmcv-full >=1.4.4,<=1.6.0
requirements/optional.txt pypi
  • cityscapesscripts *
requirements/readthedocs.txt pypi
  • mmcv *
  • prettytable *
  • torch *
  • torchvision *
requirements/runtime.txt pypi
  • matplotlib *
  • mmcls >=0.20.1
  • numpy *
  • packaging *
  • prettytable *
requirements/tests.txt pypi
  • codecov * test
  • flake8 * test
  • interrogate * test
  • pytest * test
  • xdoctest >=0.10.0 test
  • yapf * test
docker/Dockerfile docker
  • pytorch/pytorch ${PYTORCH}-cuda${CUDA}-cudnn${CUDNN}-devel build
docker/serve/Dockerfile docker
  • pytorch/pytorch ${PYTORCH}-cuda${CUDA}-cudnn${CUDNN}-devel build