-
Notifications
You must be signed in to change notification settings - Fork 2.6k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Browse files
Browse the repository at this point in the history
## Motivation Support ISNet. paper link: [ISNet: Integrate Image-Level and Semantic-Level Context for Semantic Segmentation](https://openaccess.thecvf.com/content/ICCV2021/papers/Jin_ISNet_Integrate_Image-Level_and_Semantic-Level_Context_for_Semantic_Segmentation_ICCV_2021_paper.pdf) ## Modification Add ISNet decoder head. Add ISNet config.
- Loading branch information
Showing
4 changed files
with
477 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,57 @@ | ||
# ISNet | ||
|
||
[ISNet: Integrate Image-Level and Semantic-Level Context for Semantic Segmentation](https://arxiv.org/pdf/2108.12382.pdf) | ||
|
||
## Description | ||
|
||
This is an implementation of [ISNet](https://arxiv.org/pdf/2108.12382.pdf). | ||
[Official Repo](https://github.com/SegmentationBLWX/sssegmentation) | ||
|
||
## Usage | ||
|
||
### Prerequisites | ||
|
||
- Python 3.7 | ||
- PyTorch 1.6 or higher | ||
- [MIM](https://github.com/open-mmlab/mim) v0.33 or higher | ||
- [MMSegmentation](https://github.com/open-mmlab/mmsegmentation) v1.0.0rc2 or higher | ||
|
||
All the commands below rely on the correct configuration of `PYTHONPATH`, which should point to the project's directory so that Python can locate the module files. In `isnet/` root directory, run the following line to add the current directory to `PYTHONPATH`: | ||
|
||
```shell | ||
export PYTHONPATH=`pwd`:$PYTHONPATH | ||
``` | ||
|
||
### Training commands | ||
|
||
```shell | ||
mim train mmsegmentation configs/isnet_r50-d8_8xb2-160k_cityscapes-512x1024.py --work-dir work_dirs/isnet | ||
``` | ||
|
||
To train on multiple GPUs, e.g. 8 GPUs, run the following command: | ||
|
||
```shell | ||
mim train mmsegmentation configs/isnet_r50-d8_8xb2-160k_cityscapes-512x1024.py --work-dir work_dirs/isnet --launcher pytorch --gpus 8 | ||
``` | ||
|
||
### Testing commands | ||
|
||
```shell | ||
mim test mmsegmentation configs/isnet_r50-d8_8xb2-160k_cityscapes-512x1024.py --work-dir work_dirs/isnet --checkpoint ${CHECKPOINT_PATH} | ||
``` | ||
|
||
| Method | Backbone | Crop Size | Lr schd | Mem (GB) | Inf time (fps) | mIoU | mIoU(ms+flip) | config | download | | ||
| ------ | -------- | --------- | ------: | -------- | -------------- | ----: | ------------: | --------------------------------------------------------------- | ------------------------------------------------------------------------------------------------------------------------ | | ||
| ISNet | R-50-D8 | 512x1024 | - | - | - | 79.32 | 80.88 | [config](configs/isnet_r50-d8_8xb2-160k_cityscapes-512x1024.py) | [model](https://download.openmmlab.com/mmsegmentation/v0.5/isnet/isnet_r50-d8_cityscapes-512x1024_20230104-a7a8ccf2.pth) | | ||
|
||
## Citation | ||
|
||
```bibtex | ||
@article{Jin2021ISNetII, | ||
title={ISNet: Integrate Image-Level and Semantic-Level Context for Semantic Segmentation}, | ||
author={Zhenchao Jin and B. Liu and Qi Chu and Nenghai Yu}, | ||
journal={2021 IEEE/CVF International Conference on Computer Vision (ICCV)}, | ||
year={2021}, | ||
pages={7169-7178} | ||
} | ||
``` |
80 changes: 80 additions & 0 deletions
80
projects/isnet/configs/isnet_r50-d8_8xb2-160k_cityscapes-512x1024.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,80 @@ | ||
_base_ = [ | ||
'../../../configs/_base_/datasets/cityscapes.py', | ||
'../../../configs/_base_/default_runtime.py', | ||
'../../../configs/_base_/schedules/schedule_80k.py' | ||
] | ||
|
||
data_root = '../../data/cityscapes/' | ||
train_dataloader = dict(dataset=dict(data_root=data_root)) | ||
val_dataloader = dict(dataset=dict(data_root=data_root)) | ||
test_dataloader = dict(dataset=dict(data_root=data_root)) | ||
|
||
custom_imports = dict(imports=['projects.isnet.decode_heads']) | ||
|
||
norm_cfg = dict(type='SyncBN', requires_grad=True) | ||
data_preprocessor = dict( | ||
type='SegDataPreProcessor', | ||
mean=[123.675, 116.28, 103.53], | ||
std=[58.395, 57.12, 57.375], | ||
bgr_to_rgb=True, | ||
pad_val=0, | ||
seg_pad_val=255) | ||
|
||
model = dict( | ||
type='EncoderDecoder', | ||
data_preprocessor=data_preprocessor, | ||
pretrained='open-mmlab://resnet50_v1c', | ||
backbone=dict( | ||
type='ResNetV1c', | ||
depth=50, | ||
num_stages=4, | ||
out_indices=(0, 1, 2, 3), | ||
dilations=(1, 1, 2, 4), | ||
strides=(1, 2, 1, 1), | ||
norm_cfg=norm_cfg, | ||
norm_eval=False, | ||
style='pytorch', | ||
contract_dilation=True), | ||
decode_head=dict( | ||
type='ISNetHead', | ||
in_channels=(256, 512, 1024, 2048), | ||
input_transform='multiple_select', | ||
in_index=(0, 1, 2, 3), | ||
channels=512, | ||
dropout_ratio=0.1, | ||
transform_channels=256, | ||
concat_input=True, | ||
with_shortcut=False, | ||
shortcut_in_channels=256, | ||
shortcut_feat_channels=48, | ||
num_classes=19, | ||
norm_cfg=norm_cfg, | ||
align_corners=False, | ||
loss_decode=[ | ||
dict( | ||
type='CrossEntropyLoss', | ||
use_sigmoid=False, | ||
loss_weight=1.0, | ||
loss_name='loss_o'), | ||
dict( | ||
type='CrossEntropyLoss', | ||
use_sigmoid=False, | ||
loss_weight=0.4, | ||
loss_name='loss_d'), | ||
]), | ||
auxiliary_head=dict( | ||
type='FCNHead', | ||
in_channels=1024, | ||
in_index=2, | ||
channels=512, | ||
num_convs=1, | ||
concat_input=False, | ||
dropout_ratio=0.1, | ||
num_classes=19, | ||
norm_cfg=norm_cfg, | ||
align_corners=False, | ||
loss_decode=dict( | ||
type='CrossEntropyLoss', use_sigmoid=False, loss_weight=0.4)), | ||
train_cfg=dict(), | ||
# test_cfg=dict(mode='slide', crop_size=(769, 769), stride=(513, 513)) | ||
test_cfg=dict(mode='whole')) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
from .isnet_head import ISNetHead | ||
|
||
__all__ = ['ISNetHead'] |
Oops, something went wrong.