Commit Graph

85 Commits (7ac0888d9fecb1e243b266c90dfc125b06beed64)

Author SHA1 Message Date
谢昕辰 7ac0888d9f
Bump v1.0.0rc5 (#2549)
as title
2023-02-01 20:34:20 +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
谢昕辰 18ee41eb7a
Bump v1.0.0rc4 (#2529) 2023-01-30 17:53:07 +08:00
Siddharth Ancha 6b53ec0a1f
[Doc] Fix minor typo in migration `package.md` (#2518)
Co-authored-by: xiexinch <xiexinch@outlook.com>
2023-01-30 12:02:09 +08:00
MengzhangLI a115b10323
[Doc] Add EN datasets.md in dev-1.x (#2464)
Add English version of `datasets.md`, the Chinese version is in
https://github.com/open-mmlab/mmsegmentation/pull/2387.

Co-authored-by: MeowZheng <meowzheng@outlook.com>
2023-01-22 15:55:30 +08:00
谢昕辰 d505ec1c94
[Doc] Fix API document (#2483)
## Motivation

As title.

## Modification

- docs/en/api.rst
- docs/zh_cn/api.rst
- add `scipy` to readthedocs requirement.
2023-01-13 20:06:30 +08:00
MengzhangLI 546f3b5b20
[Doc] Update ZN dataset preparation of Synapse (#2465)
## Motivation
- Add Chinese version of Synapse dataset preparation.
- Modify all `,` and `。` to `,` and `.` in
`docs/zh_cn/user_guides/2_dataset_prepare.md`.
2023-01-11 11:50:47 +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
Miao Zheng 6eb1a95a48
Bump 1.0.0rc3 (#2446)
## Motivation

To release 1.0.0rc3  

## Modification

1. Modify mmseg version 
2. Add change log
3. Modify README
4. Modify faq 
5. Revise docker file
2022-12-31 18:15:56 +08:00
谢昕辰 115552d5ea update tta docs (#2335) 2022-12-30 22:52:07 +08:00
谢昕辰 ad99ad1444 [Doc] Add dataflow document (#2403)
* draft

* update loss

* update

* add runner

* add steps

* update
2022-12-30 22:52:07 +08:00
pofengdenihong 665fa4c736 CodeCamp #144 [Doc] Chinese version of config tutorial (2371)
* [Doc]Translate the 1_config.md and modify a wrong statement in 1_config.md

* Translate the 1_config.md and modify a wrong statement in 1_config.md

* Modify some expressions

* Apply suggestions from code review
2022-12-30 22:51:19 +08:00
Miao Zheng 750bb4f180
Bump 1.0.0rc2 (#2384)
* Bump 1.0.0rc2

* typo
2022-12-06 16:32:52 +08:00
Miao Zheng 124ec8200f
Merge pull request #2088 from MengzhangLI/transforms_doc
[Doc] Update transforms Doc
2022-11-03 00:10:06 +08:00
MeowZheng 38c3145f4b refine changelog 2022-11-02 17:15:46 +08:00
MeowZheng ab26606214 typo 2022-11-02 17:12:16 +08:00
MeowZheng ddd2d6f27b fix 2022-11-02 17:00:32 +08:00
MeowZheng 84ed033246 Bump 1.0.0rc1 2022-11-02 16:49:12 +08:00
MeowZheng 85455100d5 Bump 1.0.0rc1 2022-11-02 16:48:28 +08:00
谢昕辰 b5715f3860 [Doc] Update config doc (#2048)
* Update config documentation

* add demos

* update examples

* update links
2022-11-01 21:37:29 +08:00
谢昕辰 2eaf7ee8b3 [Doc] Update inference doc (#2052)
* refactor inference doc

* introduce segdatasample

* add vis example

* fix

* Update docs/en/user_guides/3_inference.md

* update link

Co-authored-by: Miao Zheng <76149310+MeowZheng@users.noreply.github.com>
2022-11-01 21:37:29 +08:00
谢昕辰 b8d87d7fe5 [Doc] Update train test doc (#2061)
* draft

* refine structure

* fix typo

* rename single gpu title and redefine --resume

* update introduction

* add notes to load_from
2022-11-01 21:37:29 +08:00
MingJian.L 650be56fcc Update get_started.md (#2148) 2022-11-01 21:37:27 +08:00
Miao Zheng b21df463d4
[Feature] LIP dataset (#2187)
* [WIP] LIP dataset

* wip

* keep473

* lip dataset prepare

* add ut and test data
2022-10-31 20:47:52 +08:00
MengzhangLI a1f011dc0b
[Doc] Add Data Structures and Elements (#2070)
* [WIP][Doc] Add Data Structures and Elements

* fix

* add

* fix

* add chinses doc

* refactor

* fix

* fix typo

* fix

* fix

* fix typo

* Update docs/en/advanced_guides/structures.md

* Update docs/en/advanced_guides/structures.md

Co-authored-by: Miao Zheng <76149310+MeowZheng@users.noreply.github.com>
2022-10-28 22:22:44 +08:00
Miao Zheng 92ebba6c0e
[Doc] Add Migration documentation (#2066)
* wip

* [Doc] Migration

* [wip] add package changes

* remove zoo stat

* add dataset migration

* add package changes

* revise based on comments

* revise based on comments

* typo

* fix

* add engine requirements

* revise mmcv dependency
2022-10-28 21:20:15 +08:00
谢昕辰 8b392946bb
[Doc] Add evaluation doc (#2077)
* introduction

* add evaluator doc and fix typo

* fix ut

* add test dataflow

* add runner reference

* add dataloader config

* fix typo

* minor change
2022-10-13 14:55:04 +08:00
MengzhangLI e2d11d273a
[Fix] Fix typo in installation (#2175)
* [Fix] Fix installation Order of MMEngine and MMCV

* fix

* fix
2022-10-12 16:37:43 +08:00
Range King d61dd2d821
Update get_started.md (#2174)
fix the installation commands
2022-10-12 16:20:30 +08:00
谢昕辰 1413c75340
update model doc (#2160) 2022-10-08 21:01:07 +08:00
MengzhangLI 5b5968d203 fix typo 2022-10-08 17:17:05 +08:00
Miao Zheng b732fae265
Upgrade pre commit hooks (#2154)
* Upgrade pre commit hooks

* fix lint
2022-10-08 12:04:24 +08:00
MengzhangLI c8eb30329c
[Fix] Fix typo in visualization.md (#2116) 2022-09-29 19:30:53 +08:00
谢昕辰 5d1faeabf0
[Doc] Update add module doc (#2067)
* develop segmentor and remove custom optim

* update segmentor example

* add data preprocessor

* refine intro
2022-09-29 16:42:19 +08:00
MengzhangLI 89f6647d1f [Doc] Updata transforms Doc 2022-09-19 17:57:41 +08:00
谢昕辰 230246f557
[Refactor] Add pyupgrade pre-commit hook (#2078)
* add pyupgrade hook

* run pyupgrade precommit hook
2022-09-19 14:06:29 +08:00
Miao Zheng eef38883c8
[Docs] Add Overview (#2042)
* [Docs] Add Overview

* comments

* refine

* refine
2022-09-16 18:51:56 +08:00
MengzhangLI bff8a98d81
[Doc] Update Data Preparation and Visualization doc (#2054)
* [Doc] Update Data Preparation and Visualization doc

* upload visualization figure example

* fix

* fix

* delete demo image

* remove segvisualizer

* fix

* fix

* fix
2022-09-14 22:27:12 +08:00
Miao Zheng 87a1d32221
Add changelog for MMSeg 1.0.0rc0 (#2007)
* Bump 1.0.0rc0

* rephase

* rephase
2022-09-01 00:19:51 +08:00
Miao Zheng 8f5dcc8579
[Fix] README for mmseg 1.x (#2009)
* [Fix] README for mmseg 1.x

* typo

* link and refine
2022-09-01 00:03:51 +08:00
Miao Zheng 309528de8d
[Refactor] Refine documentation (#1993)
* [WIP] Refine documentation

* get started done

* config refine

* train_test

* refine user guides

* add contribution

* add contribution

* refine visualization

* advanced tutorial

* advanced guides

* tricks

* refine zh doc

* refactor changelog
2022-08-31 20:54:15 +08:00
谢昕辰 ae5c13e927
[Refactor] Inference and train tutorials for 1.x (#1952)
* inference, train_test tutorial

* fix

* add --work-dir
2022-08-29 19:47:03 +08:00
谢昕辰 99a8f59b70
visual tutorial (#1984) 2022-08-29 19:45:30 +08:00
谢昕辰 cc240ce551
[Refactor] Add transform tutorial for dev-1.x (#1985)
* transform tutorial

* fix
2022-08-29 18:21:22 +08:00
Miao Zheng c5bcf9991b
[Fix] batch size for citys in cfg file name (#1977) 2022-08-26 20:49:43 +08:00
谢昕辰 c93210262a
[Refactor] Config tutorial for 1.x (#1951)
* config tutorial

* update config name convention

* minor change

* rewrite name
2022-08-24 15:54:49 +08:00
谢昕辰 179e128e0e
transform tutorial (#1953) 2022-08-23 14:19:11 +08:00
谢昕辰 8f2c657de8 [Refactor] Dataset tutorial for 1.x (#1932)
* modify scripts dirname

* update links
2022-08-19 20:50:03 +08:00
Miao Zheng 45b63c584f [Doc] MMSeg 1.x Documentation (#1924)
* [Doc] MMSeg 1.x Documentation

* revise index
2022-08-19 20:50:03 +08:00