Spaces:
Sleeping
Sleeping
A newer version of the Gradio SDK is available:
5.35.0
ADE20k Semantic segmentation with BEiT
Getting started
- Install the mmsegmentation library and some required packages.
pip install mmcv-full==1.3.0 mmsegmentation==0.11.0
pip install scipy timm==0.3.2
- Install apex for mixed-precision training
git clone https://github.com/NVIDIA/apex
cd apex
pip install -v --disable-pip-version-check --no-cache-dir --global-option="--cpp_ext" --global-option="--cuda_ext" ./
- Follow the guide in mmseg to prepare the ADE20k dataset.
Fine-tuning
Command format:
tools/dist_train.sh <CONFIG_PATH> <NUM_GPUS> --work-dir <SAVE_PATH> --seed 0 --deterministic --options model.pretrained=<IMAGENET_CHECKPOINT_PATH/URL>
For example, using a BEiT-base backbone with UperNet:
bash tools/dist_train.sh \
configs/beit/upernet/upernet_beit_base_12_640_slide_160k_ade20k_pt2ft.py 8 \
--work-dir /path/to/save --seed 0 --deterministic \
--options model.pretrained=https://conversationhub.blob.core.windows.net/beit-share-public/beit/beit_base_patch16_224_pt22k_ft22k.pth?sv=2021-10-04&st=2023-06-08T11%3A16%3A02Z&se=2033-06-09T11%3A16%3A00Z&sr=c&sp=r&sig=N4pfCVmSeq4L4tS8QbrFVsX6f6q844eft8xSuXdxU48%3D
More config files can be found at configs/beit/upernet
.
Evaluation
Command format:
tools/dist_test.sh <CONFIG_PATH> <CHECKPOINT_PATH> <NUM_GPUS> --eval mIoU
For example, evaluate a BEiT-base backbone with UperNet:
bash tools/dist_test.sh configs/beit/upernet/upernet_beit_base_12_640_slide_160k_ade20k_pt2ft.py \
https://conversationhub.blob.core.windows.net/beit-share-public/beit/beit_base_patch16_640_pt22k_ft22ktoade20k.pth?sv=2021-10-04&st=2023-06-08T11%3A16%3A02Z&se=2033-06-09T11%3A16%3A00Z&sr=c&sp=r&sig=N4pfCVmSeq4L4tS8QbrFVsX6f6q844eft8xSuXdxU48%3D 4 --eval mIoU
Expected results:
+--------+-------+-------+-------+
| Scope | mIoU | mAcc | aAcc |
+--------+-------+-------+-------+
| global | 53.61 | 64.82 | 84.62 |
+--------+-------+-------+-------+
Multi-scale + flip (\*_ms.py
)
bash tools/dist_test.sh configs/beit/upernet/upernet_beit_base_12_640_slide_160k_ade20k_ms.py \
https://conversationhub.blob.core.windows.net/beit-share-public/beit/beit_base_patch16_640_pt22k_ft22ktoade20k.pth?sv=2021-10-04&st=2023-06-08T11%3A16%3A02Z&se=2033-06-09T11%3A16%3A00Z&sr=c&sp=r&sig=N4pfCVmSeq4L4tS8QbrFVsX6f6q844eft8xSuXdxU48%3D 4 --eval mIoU
Expected results:
+--------+-------+-------+------+
| Scope | mIoU | mAcc | aAcc |
+--------+-------+-------+------+
| global | 54.26 | 65.28 | 84.9 |
+--------+-------+-------+------+
Acknowledgment
This code is built using the mmsegmentation library, Timm library, the Swin repository, XCiT and the SETR repository.