Commit Graph

166 Commits (779b86cd74dc8df9024f72ab9939531c693d84e2)

Author SHA1 Message Date
谢昕辰 19f92851f5
[Fix] Add out_channels in `CascadeEncoderDecoder` and update OCRNet and MobileNet v2 results (#2656)
## Motivation

As title.

## Modification

1. update results in readme
2. fix attr error in cascade encoder decoder
2023-02-28 15:57:43 +08:00
谢昕辰 039ba5d4ca
[Feature] Support auto import modules from registry. (#2481)
## Motivation

The registry now supports auto-import modules from the given location.

register_all_modules before running is no longer needed. The modules
will be lazy-imported during building.

- [x] This PR can be merged after
https://github.com/open-mmlab/mmengine/pull/643. The MMEngine version
should be updated.

Ref: https://github.com/open-mmlab/mmdetection/pull/9143
2023-02-23 20:33:17 +08:00
谢昕辰 a947e3e754
[FIx] Set default `backend_args` values to None (#2597)
## Motivation

In MMEngine >= 0.2.0, it might directly determine what the backend is by
using the `data_root` path.

## Modification

Set all default `backend_args` values are `None`.
2023-02-16 15:33:52 +08:00
Andrew Lau 49b062e365
CodeCamp #139 [Feature] Support REFUGE dataset. (#2554)
## Motivation 
Add REFUGE datasets
Old PR: https://github.com/open-mmlab/mmsegmentation/pull/2420

---------

Co-authored-by: MengzhangLI <mcmong@pku.edu.cn>
2023-02-03 16:02:19 +08:00
Qingyun a092fea8c1
[Fix] Fix MaskFormer and Mask2Former of MMSegmentation (#2532)
## Motivation

The DETR-related modules have been refactored in
open-mmlab/mmdetection#8763, which causes breakings of MaskFormer and
Mask2Former in both MMDetection (has been fixed in
open-mmlab/mmdetection#9515) and MMSegmentation. This pr fix the bugs in
MMSegmentation.

### TO-DO List

- [x] update configs
- [x] check and modify data flow
- [x] fix unit test
- [x] aligning inference
- [x] write a ckpt converter
- [x] write ckpt update script
- [x] update model zoo
- [x] update model link in readme
- [x] update
[faq.md](https://github.com/open-mmlab/mmsegmentation/blob/dev-1.x/docs/en/notes/faq.md#installation)

## Tips of Fixing other implementations based on MaskXFormer of mmseg

1. The Transformer modules should be built directly. The original
building with register manner has been refactored.
2. The config requires to be modified. Delete `type` and modify several
keys, according to the modifications in this pr.
3. The `batch_first` is set `True` uniformly in the new implementations.
Hence the data flow requires to be transposed and config of
`batch_first` needs to be modified.
4. The checkpoint trained on the old implementation should be converted
to be used in the new one.

### Convert script

```Python
import argparse
from copy import deepcopy
from collections import OrderedDict

import torch

from mmengine.config import Config
from mmseg.models import build_segmentor
from mmseg.utils import register_all_modules
register_all_modules(init_default_scope=True)


def parse_args():
    parser = argparse.ArgumentParser(
        description='MMSeg convert MaskXFormer model, by Li-Qingyun')
    parser.add_argument('Mask_what_former', type=int,
                        help='Mask what former, can be a `1` or `2`',
                        choices=[1, 2])
    parser.add_argument('CFG_FILE', help='config file path')
    parser.add_argument('OLD_CKPT_FILEPATH', help='old ckpt file path')
    parser.add_argument('NEW_CKPT_FILEPATH', help='new ckpt file path')
    args = parser.parse_args()
    return args


args = parse_args()

def get_new_name(old_name: str):
    new_name = old_name

    if 'encoder.layers' in new_name:
        new_name = new_name.replace('attentions.0', 'self_attn')

    new_name = new_name.replace('ffns.0', 'ffn')

    if 'decoder.layers' in new_name:

        if args.Mask_what_former == 2:
            # for Mask2Former
            new_name = new_name.replace('attentions.0', 'cross_attn')
            new_name = new_name.replace('attentions.1', 'self_attn')
        else:
            # for Mask2Former
            new_name = new_name.replace('attentions.0', 'self_attn')
            new_name = new_name.replace('attentions.1', 'cross_attn')

    return new_name
    
def cvt_sd(old_sd: OrderedDict):
    new_sd = OrderedDict()
    for name, param in old_sd.items():
        new_name = get_new_name(name)
        assert new_name not in new_sd
        new_sd[new_name] = param
    assert len(new_sd) == len(old_sd)
    return new_sd
    
if __name__ == '__main__':
    cfg = Config.fromfile(args.CFG_FILE)
    model_cfg = cfg.model

    segmentor = build_segmentor(model_cfg)

    refer_sd = segmentor.state_dict()
    old_ckpt = torch.load(args.OLD_CKPT_FILEPATH)
    old_sd = old_ckpt['state_dict']

    new_sd = cvt_sd(old_sd)
    print(segmentor.load_state_dict(new_sd))

    new_ckpt = deepcopy(old_ckpt)
    new_ckpt['state_dict'] = new_sd
    torch.save(new_ckpt, args.NEW_CKPT_FILEPATH)
    print(f'{args.NEW_CKPT_FILEPATH} has been saved!')
```

Usage:
```bash
# for example
python ckpt4pr2532.py 1 configs/maskformer/maskformer_r50-d32_8xb2-160k_ade20k-512x512.py original_ckpts/maskformer_r50-d32_8xb2-160k_ade20k-512x512_20221030_182724-cbd39cc1.pth cvt_outputs/maskformer_r50-d32_8xb2-160k_ade20k-512x512_20221030_182724.pth
python ckpt4pr2532.py 2 configs/mask2former/mask2former_r50_8xb2-160k_ade20k-512x512.py original_ckpts/mask2former_r50_8xb2-160k_ade20k-512x512_20221204_000055-4c62652d.pth cvt_outputs/mask2former_r50_8xb2-160k_ade20k-512x512_20221204_000055.pth
```

---------

Co-authored-by: MeowZheng <meowzheng@outlook.com>
2023-02-01 18:58:21 +08:00
谢昕辰 124b87ce90
[Refactor] Refactor fileio (#2543)
## Motivation

Use the new fileio from mmengine
https://github.com/open-mmlab/mmengine/pull/533

## Modification

1. Use `mmengine.fileio` to repalce FileClient  in mmseg/datasets
2. Use `mmengine.fileio` to repalce FileClient in
mmseg/datasets/transforms
3. Use `mmengine.fileio` to repalce FileClient in mmseg/visualization

## BC-breaking (Optional)

we modify all the dataset configurations, so please use the latest config file.
2023-02-01 17:53:22 +08:00
MengzhangLI 67b5dfa699
[Fix] Fix ERFNet URL in dev-1.x branch (#2537) 2023-01-31 17:25:56 +08:00
王永韬 2d67e51db3
CodeCamp #140 [New] [Feature] Add synapse dataset and data augmentation in dev-1.x. (#2432)
## Motivation

Add Synapse dataset in MMSegmentation.
Old PR: https://github.com/open-mmlab/mmsegmentation/pull/2372.
2023-01-06 16:14:54 +08:00
谢昕辰 da4125587e [Refactor] Support TTA (#2184)
* tta init

* use mmcv transform

* test city

* add multiscale

* fix merge

* add softmax to post process

* add ut

* add tta pipeline to other datasets

* remove softmax

* add encoder_decoder_tta ut

* add encoder_decoder_tta ut

* rename

* rename file

* rename config

* rm aug_test

* move flip to post process

* fix channel
2022-12-30 22:52:07 +08:00
haofeng 20a6c58478 add pspnet model structure graph (#2437) 2022-12-30 22:52:07 +08:00
谢昕辰 163277bfe0
[Feature] Support Mask2former in MMSeg 1.x (#2255)
* init commits

* fix crop size

* add seg_data2instance_data method

* add ut and update requirement

* update configs and readme

* add model-indel

* update optional requirements

* fix results

* fix lint error

* update results

* update results

* remove mmdet from requirements/optional.txt

* use try import and update README

* add docstring to overwrtied method

* minor change

Co-authored-by: MengzhangLI <mcmong@pku.edu.cn>
2022-12-05 18:34:24 +08:00
MengzhangLI 933e4d3cb6
[Feature] Support MaskFormer(NeurIPS'2021) in MMSeg 1.x (#2215)
* [Feature] Support MaskFormer(NeurIPS'2021) in MMSeg 1.x

* add mmdet try except logic

* refactor config files

* add readme

* fix config

* update models & logs

* add MMDET installation and fix info

* fix comments

* fix

* fix config norm optimizer setting

* update models & logs & unittest

* add docstring of MaskFormerHead

* wait for mmdet 3.0.0rc4

* replace seg_mask with seg_logits & add docstring for batch_input_shape

* use mmdet3.0.0rc4

* fix readme and modify config comments

* add mmdet installation in pr_stage_test.yml

* update mmcv version in pr_stage_test.yml

* add mmdet in build_cpu of pr_stage_test.yml

* modify mmdet& mmcv installation in merge_stage_test.yml

* fix typo

* update test.yml

* update test.yml
2022-12-01 19:03:10 +08:00
谢昕辰 a6a5a50518
modify results (#2113) 2022-10-27 13:07:53 +08:00
MengzhangLI 25604a151b
[Feature] Support PoolFormer in MMSegmentation 2.0 (#2191)
* [Feature] 2.0 PoolFormer

* fix mmcls version

* fix ut error

* fix ut

* fix ut
2022-10-19 13:08:07 +08:00
Miao Zheng e8af7a0ed0
[Fix]Use syncbn in mobilenet_v2 (#2198) 2022-10-18 17:19:37 +08:00
MengzhangLI f3cd44bebf
[Fix] Fix ResizeToMultiple transform in MMSeg 1.x (#2185) 2022-10-14 15:37:35 +08:00
MengzhangLI 0097dfbabc
[Fix] Fix segmenter-vit-s_fcn config (#2037) 2022-09-14 22:31:39 +08:00
MengzhangLI bd1097ac02
[Fix] Fix several config file errors in 2.0 (New) (#1994)
* [Fix] Fix several config file errors in 2.0

* change _base_ config file name in configs
2022-08-30 20:20:05 +08:00
Miao Zheng adec7f2d65
[Fix] Add `by_epoch=False` for log processor (#1987) 2022-08-29 12:05:58 +08:00
Miao Zheng c5bcf9991b
[Fix] batch size for citys in cfg file name (#1977) 2022-08-26 20:49:43 +08:00
谢昕辰 a3a144a361
[Refactor] Update config names (#1964)
* rename ann configs

* update ann yml

* update

* update

* update

* update

* update

* update ann readme

* update

* update deeplabv3

* update readme

* fix yml

* fix beit
2022-08-26 18:48:56 +08:00
谢昕辰 03405dcbb6 fix logger cfg (#1894) 2022-08-19 20:50:03 +08:00
Miao Zheng c498e6f593
[Fix] Add SegVisualizationHook in default hooks (#1900) 2022-08-09 23:33:04 +08:00
Miao Zheng 78b08650b5
[Fix] Default hooks in cgnet config (#1897) 2022-08-09 20:26:05 +08:00
MengzhangLI e4b9d72a11
[Fix] 2.0 Fix mDice metric for medical datasets (#1864) 2022-08-04 18:32:52 +08:00
MengzhangLI 7369d50049
[Fix] Fix SegLocalVisualizer gt_sem_seg cuda tensor error (#1845)
* [Fix] Fix SegLocalVisualizer gt_sem_seg cuda tensor error

* fix ut error and add config visualizer dict

* fix ut error
2022-08-01 15:03:01 +08:00
xiexinchen.vendor 5b41431511 [Fix] Fix optim wrapper configs 2022-07-14 01:49:52 +00:00
zhengmiao a63f77d249 Merge branch 'xiexinchen/fix_optim_config' into 'refactor_dev'
[Fix] Fix mae/dpt optimizer config error

See merge request openmmlab-enterprise/openmmlab-ce/mmsegmentation!58
2022-07-07 11:04:10 +00:00
xiexinch 55b0c3aef5 fix cgnet configs and encnet forward error 2022-07-07 14:18:17 +08:00
xiexinch 26a0b4814b add _delete_=True to optim wrapper 2022-07-06 17:26:52 +08:00
xiexinchen.vendor b852f2605a [Fix] Fix RandomResize default setting 2022-07-06 06:04:40 +00:00
xiexinch 28a3d89b7a Update pre-commit yaml and md2yml.py 2022-07-05 15:58:48 +08:00
limengzhang.vendor f2bac79f03 [Refactor] Refactor DatasetWrapper 2022-06-27 14:36:18 +00:00
zhengmiao 9ed2e1cdd8 Merge branch 'limengzhang/fix_optim_delete' into 'refactor_dev'
[Fix] Remove _delete_=True in optimizer

See merge request openmmlab-enterprise/openmmlab-ce/mmsegmentation!51
2022-06-21 02:35:38 +00:00
MengzhangLI 2c4bcbd7c6 [Fix] Remove _delete_=True in optimizer 2022-06-20 17:53:36 +08:00
linfangjian01 bb0b33dfed [Refactor] Refactor metrics -> iou_metrics 2022-06-20 16:34:18 +08:00
zhengmiao ffa0616a68 [Refactory] KNet head 2022-06-20 04:04:48 +00:00
zhengmiao b23982d1b3 [Refactory] Refactory BaseSegmentor based BaseModel 2022-06-19 06:32:09 +00:00
limengzhang.vendor 4062e90206 [Fix] Remove OptimizerHook and Add it in OptimWrapper 2022-06-16 13:24:19 +00:00
limengzhang.vendor 11493c4851 [Fix] Fix no LoadAnnotations in testpipeline 2022-06-13 05:33:34 +00:00
limengzhang.vendor 34711422ac [Fix] Fix batch size of val_dataloader to 1. 2022-06-12 09:10:26 +00:00
linfangjian.vendor dd9c411335 [Refactor] Refactor decode_head and segmentors and add preprocess_cfg 2022-06-10 14:02:40 +00:00
limengzhang.vendor 6d80312c8f [Fix] Fix DefaultSampler to InfiniteSampler 2022-06-10 13:13:16 +00:00
limengzhang.vendor fcb9cb4571 [Refactor] Refactor lr_config 2022-06-08 09:25:00 +00:00
linfangjian.vendor 02677ac2f8 [Refactor] Refactor evaluation config, clean eval hook and metrics 2022-06-08 08:22:42 +00:00
limengzhang.vendor c84a58b7b5 [Refactor] Refacor default_hooks and train & val & test loops in configs 2022-06-08 06:28:35 +00:00
limengzhang.vendor 5b9c29f992 [Refactor] Refactor Dataset and its Transform Config files 2022-05-31 14:28:42 +00:00
MeowZheng fcb948295c [Enhancement] Revise RandomCrop 2022-05-27 21:52:49 +08:00
linfangjian.vendor f6d3291064 [Refactor] Refactor RandomCrop and PhotoMetricDistortion 2022-05-25 01:58:37 +00:00
MengzhangLI 799486e124 [Fix] Fix main line link in MAE README.md (#1556) 2022-05-05 17:49:38 +08:00