Commit Graph

801 Commits (779b86cd74dc8df9024f72ab9939531c693d84e2)
 

Author SHA1 Message Date
谢昕辰 779b86cd74
bump v1.0.0rc6 (#2647)
as title
2023-03-03 16:54:12 +08:00
Miao Zheng aaa08dc4b2
[Doc] Refine MMSegmentation documentation (#2668) 2023-03-03 14:51:38 +08:00
Miao Zheng 310ec4afc7
[Enhancement] Modify interface of MMSeginferencer and add docs (#2658)
## Motivation

Make MMSeginferencer easier to be used

## Modification

1. Add `_load_weights_to_model` to MMSeginferencer, it is for get
`dataset_meta` from ckpt
2. Modify and remove some parameters of `__call__`, `visualization` and
`postprocess`
3. Add function of save seg mask, remove dump pkl.
4. Refine docstring of MMSeginferencer and SegLocalVisualizer
5. Add the user documentation of MMSeginferencer

## BC-breaking (Optional)

yes, remove some parameters, we need to discuss whether keep them with
deprecated waring or just remove them as the MMSeginferencer just merged
in mmseg a few days.

Co-authored-by: xiexinch <xiexinch@outlook.com>
2023-03-03 14:37:54 +08:00
Tianlong Ai 8c1d299cb6
[Docs] Add Chinese dataflow markdown (#2652)
## Modification
Add Chinese dataflow markdown

---------

Signed-off-by: csatsurnh <cshan1995@126.com>
Co-authored-by: csatsurnh <cshan1995@126.com>
Co-authored-by: Miao Zheng <76149310+MeowZheng@users.noreply.github.com>
2023-03-02 09:56:00 +08:00
Miao Zheng e955d6868a
[Docs] Fix migration link in README (#2659)
as title
2023-03-02 09:16:48 +08:00
谢昕辰 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
jinxianwei eca61d3cda
tools/analysis_tools browse_dataset.py (#2649)
## Motivation

browse_dataset before training

## Modification

create tools/analysis_tools/browse_dataset.py
2023-02-27 12:02:48 +08:00
Miao Zheng 619a3c2508
[Enhancement] Remove mmdet and mmcls from mminstall (#2642)
## Motivation

As the mmdet and mmcls are not very stabel, and mim can install repo
from source code, we remove them from mminstall and they won't be
installed automatically when run `mim install mmsegmentation`

## Modification

1. remove mmdet and mcls from mminstall
2. add explanation in faq

---------

Co-authored-by: MengzhangLI <mcmong@pku.edu.cn>
2023-02-24 14:57:54 +08:00
谢昕辰 53fe1ccf39
[Feature] Support MMSegInferencer (#2413)
## Motivation

Support `MMSegInferencer` for providing an easy and clean interface for
single or multiple images inferencing.

Ref: https://github.com/open-mmlab/mmengine/pull/773
https://github.com/open-mmlab/mmocr/pull/1608

## Modification

- mmseg/apis/mmseg_inferencer.py
- mmseg/visualization/local_visualizer.py
- demo/image_demo_with_inferencer.py

## Use cases (Optional)

Based on https://github.com/open-mmlab/mmengine/tree/inference

Add a new image inference demo with `MMSegInferencer`

- demo/image_demo_with_inferencer.py

```shell
python demo/image_demo_with_inferencer.py demo/demo.png fcn_r50-d8_4xb2-40k_cityscapes-512x1024
```

---------

Co-authored-by: MeowZheng <meowzheng@outlook.com>
2023-02-23 21:16:19 +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
Miao Zheng 2d38bc8554
[Enhancement] Refine projects (#2586)
## Motivation

Make projects contribution more clear

## Modification

1. Add description on project/README
2. Modify comments to reference in example_project/README 
3. Add faq for projects

## BC-breaking (Optional)

No
2023-02-22 19:18:12 +08:00
wangjiangben-hw e9d5b03607
[DOC] update link in NPU DOC (#2610)
## Motivation

update link in dock

## Modification

docs/en/device/npu.md
docs/zh_cn/device/npu.md
2023-02-16 17:43:18 +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
CSH 2e27f8b678
[Enhancement]Replace numpy ascontiguousarray with torch contiguous to speed-up (#2604)
## Motivation

Original motivation was after [MMDetection PR
#9533](https://github.com/open-mmlab/mmdetection/pull/9533)

With several experiments I found out that if a ndarray is contiguous,
numpy.transpose + torch.contiguous perform better, while if not, then
use numpy.ascontiguousarray + numpy.transpose

## Modification

Replace numpy.ascontiguousarray with torch.contiguous in
[PackSegInputs](https://github.com/open-mmlab/mmsegmentation/blob/1.x/mmseg/datasets/transforms/formatting.py)

Co-authored-by: MeowZheng <meowzheng@outlook.com>
2023-02-15 19:02:00 +08:00
wangjiangben-hw 9b8e8b730c
[NPU] add npu result (#2596)
Motivation
add NPU results -- apcnet, bisenetv1, bisenetv2 

Modification
add docs/en/device/npu.md and docs/zh_cn/device/npu.md that accompanies
the submission results.

---------

Co-authored-by: Miao Zheng <76149310+MeowZheng@users.noreply.github.com>
2023-02-15 12:03:01 +08:00
vansin fdf7585bba
docs: Add twitter discord medium youtube link (#2602)
as title
2023-02-15 11:29:53 +08:00
Yijie Zheng 712612b1a1
[Doc] fix api name error in the migration doc (#2601)
as title
2023-02-15 11:14:22 +08:00
Miao Zheng e289eb273e
[Fix] Fix the benchmark model list (#2582)
as title
2023-02-10 14:31:31 +08:00
Miao Zheng 2cbc3cf183
[Fix] Fix the benchmark model list (#2582)
as title
2023-02-10 14:29:06 +08:00
jinxianwei 08eb9a4e1d
[Doc] for Visualization feature map using wandb backend in dev-1.x (#2557)
## Motivation

Docs for Visualization featusre map using wandb backend.

## Modification

Add a new markdown file and result demo of wandb.

---------

Co-authored-by: MeowZheng <meowzheng@outlook.com>
2023-02-08 19:53:50 +08:00
wangjiangben-hw 916ed2b2e2
[NPU] add npu result (#2569)
Motivation
add NPU results.

Modification
add docs/en/device/npu.md and docs/zh_cn/device/npu.md that accompanies
the submission results.

---------

Co-authored-by: Miao Zheng <76149310+MeowZheng@users.noreply.github.com>
2023-02-07 16:36:36 +08:00
MengzhangLI b2577e0ba0
[Doc] Add EN custmized runtime doc in dev-1.x (#2533)
## Motivation
Translate Chinese version customized runtime doc into English
https://github.com/open-mmlab/mmsegmentation/pull/2502.
2023-02-07 14:47:22 +08:00
Tianlong Ai 432628b735
[Fix] Rename and Fix bug of projects HieraSeg (old PR #2444) (#2565)
## Motivation
Supplementary PR #2444 
Fix tiny bug and add loss_by_feat() to compute loss to train.
The inference process have verified to be accurate.
## Modification
- modify `sep_aspp_contrast_head.py` , add `loss_by_feat()` function to
train(training still has bug, will fix in future😫)
- fix testing commands path error `bash tools/dist_test.sh
projects/HieraSeg_project/` to `bash tools/dist_test.sh
projects/HieraSeg/` at README.md
2023-02-06 18:55:22 +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
谢昕辰 7ac0888d9f
Bump v1.0.0rc5 (#2549)
as title
2023-02-01 20:34:20 +08:00
zccjjj ce63ccf7ab
Rename typing.py to typing_utils.py (#2548)
## Motivation

Fix the bug in running ```collect_evn.py```. #2547 

## Modification

Rename typing.py to typing_utils.py
2023-02-01 19:11:38 +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
Siddharth Ancha 698dee9525
Backward merge #2535 from `1.x` into `dev-1.x` (#2546)
## Motivation

This is essentially #2535 that I had intended to submit to the `dev-1.x`
branch but accidentally submitted it directly to the `1.x` branch
(apologies!). This also got approved possibly because the core devs also
didn't realize this.

The problem is that now `1.x` and `dev-1.x` are out of sync -- the
changes introduced by #2535 will never be reflected in `dev-1.x`.

## Modification

I'm proposing this "backward-merge" so that `1.x` and `dev-1.x` can be
in sync again. If you look at "files changed", they are exactly the
changes introduced by #2535.

Co-authored-by: MeowZheng <meowzheng@outlook.com>
2023-02-01 10:26:44 +08:00
MengzhangLI 67b5dfa699
[Fix] Fix ERFNet URL in dev-1.x branch (#2537) 2023-01-31 17:25:56 +08:00
谢昕辰 18ee41eb7a
Bump v1.0.0rc4 (#2529) 2023-01-30 17:53:07 +08:00
Miao Zheng 981f3a488e
[Fix]Fix mmcv version 2.0.0rc3 for win test (#2531)
as title
2023-01-30 13:49:54 +08:00
Siddharth Ancha d1c0a3efd4
[Fix] Unfinished label conversion from `-1` to `255` in 1.x (#2516)
## Motivation

This is motivated by a previously unfinished PR (#2332). In that PR, the
label -1 was changed to 255 in `BaseSegDataset`, which is correct.
However, it was changed at only one location. There is another location
in `mmseg/datasets/basesegdataset.py` where -1 was still being used that
was not converted to 255. I have now converted it to 255.

This is exactly same as a similar fix to the `master` branch via #2515 .

## Modification

I've simply converted the snipped

```python
if new_id != -1:
    new_palette.append(palette[old_id])
```
to 
```python
if new_id != 255:
    new_palette.append(palette[old_id])
```

## Checklist

- [x] Pre-commit or other linting tools are used to fix the potential
lint issues.
  - _I've fixed all linting/pre-commit errors._
- [x] The modification is covered by complete unit tests. If not, please
add more unit test to ensure the correctness.
  - _No unit tests need to be added or were affected.
- [x] If the modification has potential influence on downstream
projects, this PR should be tested with downstream projects, like MMDet
or MMDet3D.
  - _I don't think this change affects MMDet or MMDet3D._
- [x] The documentation has been modified accordingly, like docstring or
example tutorials.
- _This change fixes an existing bug and doesn't require modifying any
documentation/docstring._
2023-01-30 12:35:55 +08:00
Siddharth Ancha 74e8b89b17
[Fix] Switch order of `reduce_zero_label` and applying `label_map` in 1.x (#2517)
This is an almost exact duplicate of #2500 (that was made to the
`master` branch) now applied to the `1.x` branch.

---

## Motivation

I want to fix a bug through this PR. The bug occurs when two options --
`reduce_zero_label=True`, and custom classes are used.
`reduce_zero_label` remaps the GT seg labels by remapping the zero-class
to 255 which is ignored. Conceptually, this should occur *before* the
`label_map` is applied, which maps *already reduced labels*. However,
currently, the `label_map` is applied before the zero label is reduced.

## Modification

The modification is simple:
- I've just interchanged the order of the two operations by moving a few
lines from bottom to top.
- I've added a test that passes when the fix is introduced, and fails on
the original `master` branch.

## BC-breaking (Optional)

I do not anticipate this change braking any backward-compatibility.

## Checklist

- [x] Pre-commit or other linting tools are used to fix the potential
lint issues.
  - _I've fixed all linting/pre-commit errors._
- [x] The modification is covered by complete unit tests. If not, please
add more unit test to ensure the correctness.
  - _I've added a unit test._ 
- [x] If the modification has potential influence on downstream
projects, this PR should be tested with downstream projects, like MMDet
or MMDet3D.
  - _I don't think this change affects MMDet or MMDet3D._
- [x] The documentation has been modified accordingly, like docstring or
example tutorials.
- _This change fixes an existing bug and doesn't require modifying any
documentation/docstring._
2023-01-30 12:17:15 +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
谢昕辰 b9b5d8bf52
[CI] Upgrade the version of isort to fix lint error (#2519)
## Motivation

https://github.com/open-mmlab/mmeval/pull/85

---------

Co-authored-by: Miao Zheng <76149310+MeowZheng@users.noreply.github.com>
2023-01-30 10:31:12 +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
谢昕辰 37af545f6b
[Fix] Fix inference api and support setting palette to SegLocalVisualizer (#2475)
as title

Co-authored-by: MengzhangLI <mcmong@pku.edu.cn>
2023-01-20 21:40:13 +08:00
Leeinsn 7fc8ca0312
CodeCamp #141 [Feature] Add BioMedical3DRandomFlip. (#2404)
## Motivation

Support for biomedical 3d images augmentation.

## Modification

Add BioMedical3DRandomFlip in mmseg/datasets/transforms/transforms.py.

Co-authored-by: MeowZheng <meowzheng@outlook.com>
2023-01-20 15:34:11 +08:00
Tianlong Ai e394e2aa28
CodeCamp #1555[Feature] Support Mapillary Vistas Dataset (#2484)
## Support `Mapillary Vistas Dataset`

## Motivation

Support  **`Mapillary Vistas Dataset`**
Dataset Paper link : https://ieeexplore.ieee.org/document/9878466/
Download and more information view
https://www.mapillary.com/dataset/vistas
```
@InProceedings{Neuhold_2017_ICCV,
author = {Neuhold, Gerhard and Ollmann, Tobias and Rota Bulo, Samuel and Kontschieder, Peter},
title = {The Mapillary Vistas Dataset for Semantic Understanding of Street Scenes},
booktitle = {Proceedings of the IEEE International Conference on Computer Vision (ICCV)},
month = {Oct},
year = {2017}
}
```

## Modification

Add `Mapillary_dataset` in `mmsegmentation/projects`
Add `configs/_base_/mapillary_v1_2.py` and
`configs/_base_/mapillary_v2_0.py`
Add `configs/deeplabv3plus_r18-d8_4xb2-80k_mapillay-512x1024.py` to test
training and testing on Mapillary datasets
Add `docs/en/user_guides/2_dataset_prepare.md` , add Mapillary Vistas
Dataset Preparing and Structure.
Add `tools/dataset_converters/mapillary.py` to convert RGB labels to
Mask labels.

Co-authored-by: 谢昕辰 <xiexinch@outlook.com>
2023-01-20 14:25:51 +08:00
MengzhangLI f678a5c974
[Doc] Add ZN Customized_runtime Doc in dev-1.x (#2502)
Old PR: https://github.com/open-mmlab/mmsegmentation/pull/2169
2023-01-19 16:29:56 +08:00
MengzhangLI c2ba8ebac1
[Fix][Doc] Fix link of preprocessing and order of operations in ZN dataset.md doc. (#2494)
## Motivation

Ref:
https://github.com/open-mmlab/mmsegmentation/pull/2464#discussion_r1072211706

Co-authored-by: Miao Zheng <76149310+MeowZheng@users.noreply.github.com>
2023-01-19 14:26:26 +08:00
Vladimir Loginov 6d8ba3b5a0
Update basesegdataset.py (#2492)
## Motivation

Makes docstring to be consistent with actual argument name.

## Modification

Minor fix

## BC-breaking (Optional)

No
2023-01-17 20:18:46 +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
Tianlong Ai ce09639a21
CodeCamp #151[Feature] Support HieraSeg on cityscapes (#2444)
## Support `HieraSeg` interface on `cityscapes`

## Motivation

Support `HieraSeg` interface on cityscapes dataset  
Paper link : https://ieeexplore.ieee.org/document/9878466/

```
@article{li2022deep,
  title={Deep Hierarchical Semantic Segmentation},
  author={Li, Liulei and Zhou, Tianfei and Wang, Wenguan and Li, Jianwu and Yang, Yi},
  journal={CVPR},
  year={2022}
}
```

## Modification

Add `HieraSeg_Projects` on `projects/`
Add `sep_aspp_contrast_head` decoder head.
Add `HieraSeg` config.
Add `hiera_loss`, `hiera_triplet_loss_cityscape`, `tree_triplet_loss`
2023-01-12 17:12:40 +08:00
Wencheng Wu 8dae9465a6
[Feature] Add `gt_edge_map` field. (#2466)
## Motivation

The motivation of this PR is to add `gt_edge_map` field to support
boundary loss.

## Modification

- GenerateEdge
Modify `gt_edge` field to `gt_edge_map`.

- PackSegInputs
Add `gt_edge_map` to data_sample.

- stack_batch
Pad `gt_edge_map` to max_shape.

## BC-breaking (Optional)

No

## Use cases (Optional)

Reference `GenerateEdge`.
2023-01-11 11:51:29 +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
谢昕辰 f90f7a56d4
[Fix] Fix incorrect `img_shape` value assignment in RandomCrop (#2469)
## Motivation

Fix incorrect `img_shape` value assignment.

## Modification

- mmseg/datasets/transforms/transforms.py
2023-01-10 18:03:43 +08:00
Miao Zheng 4e759bb1d2
[CI] Remove test py3.6 (#2468)
## Motivation

as title

## Modification

1. .circleci/test.yml
2. .github/workflows/merge_stage_test.yml
2023-01-10 17:11:59 +08:00
谢昕辰 0238d02c48
[Doc] Add checklist of ISNet (#2460)
## Motivation

As title. 

## Modification

- projects/isnet/README.md
2023-01-09 13:09:23 +08:00