Skip to content

Commit b312e79

Browse files
xiexinchMeowZheng
authored andcommitted
[Projects] Add 'Projects/' folder, and the first example project in 0.x (#2457)
## Motivation Introducing new models and features into OpenMMLab's algorithm libraries has long been complained to be troublesome due to the rigorous requirements on code quality, which could hinder the fast iteration of SOTA models and might discourage potential contributors from sharing their latest outcome here. Ref: #2412 ## Modification This PR adds a new `projects/` folder, which will be a place for some experimental models/features. Implementations inside might be not quite perfect but already fine to produce some exciting results. We hope that this PR can help us better embrace the contribution from our community. We also add the first example project to illustrate what we expect a good project to have.
1 parent bedec40 commit b312e79

File tree

6 files changed

+165
-0
lines changed

6 files changed

+165
-0
lines changed

Diff for: .github/workflows/build.yml

+2
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@ on:
88
- 'docker/**'
99
- 'tools/**'
1010
- '**.md'
11+
- 'projects/**'
1112

1213
pull_request:
1314
paths-ignore:
@@ -17,6 +18,7 @@ on:
1718
- 'tools/**'
1819
- 'docs/**'
1920
- '**.md'
21+
- 'projects/**'
2022

2123
concurrency:
2224
group: ${{ github.workflow }}-${{ github.ref }}

Diff for: projects/README.md

+9
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
# Projects
2+
3+
Implementing new models and features into OpenMMLab's algorithm libraries could be troublesome due to the rigorous requirements on code quality, which could hinder the fast iteration of SOTA models and might discourage our members from sharing their latest outcomes here.
4+
5+
And that's why we have this `Projects/` folder now, where some experimental features, frameworks and models are placed, only needed to satisfy the minimum requirement on the code quality, and can be used as standalone libraries. Users are welcome to use them if they [use MMSegmentation from source](https://mmsegmentation.readthedocs.io/en/latest/get_started.html#best-practices).
6+
7+
Everyone is welcome to post their implementation of any great ideas in this folder! If you wish to start your own project, please go through the [example project](example_project/) for the best practice.
8+
9+
Note: The core maintainers of MMSegmentation only ensure the results are reproducible and the code quality meets its claim at the time each project was submitted, but they may not be responsible for future maintenance. The original authors take responsibility for maintaining their own projects.

Diff for: projects/example_project/README.md

+129
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,129 @@
1+
# Dummy ResNet Wrapper
2+
3+
This is an example README for community `projects/`. We have provided detailed explanations for each field in the form of html comments, which are visible when you read the source of this README file. If you wish to submit your project to our main repository, then all the fields in this README are mandatory for others to understand what you have achieved in this implementation. For more details, read our [contribution guide](https://github.com/open-mmlab/mmsegmentation/blob/master/.github/CONTRIBUTING.md) or approach us in [Discussions](https://github.com/open-mmlab/mmsegmentation/discussions).
4+
5+
## Description
6+
7+
<!-- Share any information you would like others to know. For example:
8+
9+
Author: @xxx.
10+
11+
This is an implementation of \[XXX\]. -->
12+
13+
This project implements a dummy ResNet wrapper, which literally does nothing new but prints "hello world" during initialization.
14+
15+
## Usage
16+
17+
<!-- For a typical model, this section should contain the commands for training and testing. You are also suggested to dump your environment specification to env.yml by `conda env export > env.yml`. -->
18+
19+
### Prerequisites
20+
21+
- Python 3.7
22+
- PyTorch 1.6 or higher
23+
- [MIM](https://github.com/open-mmlab/mim) v0.33 or higher
24+
- [MMSegmentation](https://github.com/open-mmlab/mmsegmentation) v0.29.1 or higher
25+
26+
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 `example_project/` root directory, run the following line to add the current directory to `PYTHONPATH`:
27+
28+
```shell
29+
export PYTHONPATH=`pwd`:$PYTHONPATH
30+
```
31+
32+
### Training commands
33+
34+
```shell
35+
mim train mmsegmentation configs/fcn_dummy-r50-d8_4xb2-40k_cityscapes-512x1024.py --work-dir work_dirs/dummy_resnet
36+
```
37+
38+
To train on multiple GPUs, e.g. 8 GPUs, run the following command:
39+
40+
```shell
41+
mim train mmsegmentation configs/fcn_dummy-r50-d8_4xb2-40k_cityscapes-512x1024.py --work-dir work_dirs/dummy_resnet --launcher pytorch --gpus 8
42+
```
43+
44+
### Testing commands
45+
46+
```shell
47+
mim test mmsegmentation configs/fcn_dummy-r50-d8_4xb2-40k_cityscapes-512x1024.py --work-dir work_dirs/dummy_resnet --checkpoint ${CHECKPOINT_PATH} --eval mIoU
48+
```
49+
50+
<!-- List the results as usually done in other model's README. [Example](https://github.com/open-mmlab/mmsegmentation/tree/master/configs/fcn#results-and-models)
51+
52+
You should claim whether this is based on the pre-trained weights, which are converted from the official release; or it's a reproduced result obtained from retraining the model in this project. -->
53+
54+
| Method | Backbone | Crop Size | Lr schd | Mem (GB) | Inf time (fps) | mIoU | mIoU(ms+flip) | config | download |
55+
| ------ | -------- | --------- | ------: | -------- | -------------- | ----: | ------------: | ------------------------------------------------------------------ | ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
56+
| FCN | R-50-D8 | 512x1024 | 40000 | 5.7 | 4.17 | 72.25 | 73.36 | [config](configs/fcn_dummy-r50-d8_4xb2-40k_cityscapes-512x1024.py) | [model](https://download.openmmlab.com/mmsegmentation/v0.5/fcn/fcn_r50-d8_512x1024_40k_cityscapes/fcn_r50-d8_512x1024_40k_cityscapes_20200604_192608-efe53f0d.pth) \| [log](https://download.openmmlab.com/mmsegmentation/v0.5/fcn/fcn_r50-d8_512x1024_40k_cityscapes/fcn_r50-d8_512x1024_40k_cityscapes_20200604_192608.log.json) |
57+
58+
## Citation
59+
60+
<!-- You may remove this section if not applicable. -->
61+
62+
```bibtex
63+
@misc{mmseg2020,
64+
title={{MMSegmentation}: OpenMMLab Semantic Segmentation Toolbox and Benchmark},
65+
author={MMSegmentation Contributors},
66+
howpublished = {\url{https://github.com/open-mmlab/mmsegmentation}},
67+
year={2020}
68+
}
69+
```
70+
71+
## Checklist
72+
73+
Here is a checklist illustrating a usual development workflow of a successful project, and also serves as an overview of this project's progress.
74+
75+
<!-- The PIC (person in charge) or contributors of this project should check all the items that they believe have been finished, which will further be verified by codebase maintainers via a PR.
76+
77+
OpenMMLab's maintainer will review the code to ensure the project's quality. Reaching the first milestone means that this project suffices the minimum requirement of being merged into 'projects/'. But this project is only eligible to become a part of the core package upon attaining the last milestone.
78+
79+
Note that keeping this section up-to-date is crucial not only for this project's developers but the entire community, since there might be some other contributors joining this project and deciding their starting point from this list. It also helps maintainers accurately estimate time and effort on further code polishing, if needed.
80+
81+
A project does not necessarily have to be finished in a single PR, but it's essential for the project to at least reach the first milestone in its very first PR. -->
82+
83+
- [ ] Milestone 1: PR-ready, and acceptable to be one of the `projects/`.
84+
85+
- [ ] Finish the code
86+
87+
<!-- The code's design shall follow existing interfaces and convention. For example, each model component should be registered into `mmseg.registry.MODELS` and configurable via a config file. -->
88+
89+
- [ ] Basic docstrings & proper citation
90+
91+
<!-- Each major object should contain a docstring, describing its functionality and arguments. If you have adapted the code from other open-source projects, don't forget to cite the source project in docstring and make sure your behavior is not against its license. Typically, we do not accept any code snippet under GPL license. [A Short Guide to Open Source Licenses](https://medium.com/nationwide-technology/a-short-guide-to-open-source-licenses-cf5b1c329edd) -->
92+
93+
- [ ] Test-time correctness
94+
95+
<!-- If you are reproducing the result from a paper, make sure your model's inference-time performance matches that in the original paper. The weights usually could be obtained by simply renaming the keys in the official pre-trained weights. This test could be skipped though, if you are able to prove the training-time correctness and check the second milestone. -->
96+
97+
- [ ] A full README
98+
99+
<!-- As this template does. -->
100+
101+
- [ ] Milestone 2: Indicates a successful model implementation.
102+
103+
- [ ] Training-time correctness
104+
105+
<!-- If you are reproducing the result from a paper, checking this item means that you should have trained your model from scratch based on the original paper's specification and verified that the final result matches the report within a minor error range. -->
106+
107+
- [ ] Milestone 3: Good to be a part of our core package!
108+
109+
- [ ] Type hints and docstrings
110+
111+
<!-- Ideally *all* the methods should have [type hints](https://www.pythontutorial.net/python-basics/python-type-hints/) and [docstrings](https://google.github.io/styleguide/pyguide.html#381-docstrings). [Example](https://github.com/open-mmlab/mmsegmentation/blob/master/mmseg/utils/misc.py#L7) -->
112+
113+
- [ ] Unit tests
114+
115+
<!-- Unit tests for each module are required. [Example](https://github.com/open-mmlab/mmsegmentation/blob/master/tests/test_utils/test_misc.py) -->
116+
117+
- [ ] Code polishing
118+
119+
<!-- Refactor your code according to reviewer's comment. -->
120+
121+
- [ ] Metafile.yml
122+
123+
<!-- It will be parsed by MIM and Inferencer. [Example](https://github.com/open-mmlab/mmsegmentation/blob/master/configs/fcn/fcn.yml) -->
124+
125+
- [ ] Move your modules into the core package following the codebase's file hierarchy structure.
126+
127+
<!-- In particular, you may have to refactor this README into a standard one. [Example](https://github.com/open-mmlab/mmsegmentation/blob/master/configs/fcn/README.md) -->
128+
129+
- [ ] Refactor your modules into the core package following the codebase's file hierarchy structure.
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
# Copyright (c) OpenMMLab. All rights reserved.
2+
_base_ = ['../../../configs/fcn/fcn_r50-d8_512x1024_40k_cityscapes.py']
3+
4+
custom_imports = dict(imports=['projects.example_project.dummy'])
5+
6+
model = dict(backbone=dict(type='DummyResNet'))

Diff for: projects/example_project/dummy/__init__.py

+4
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
# Copyright (c) OpenMMLab. All rights reserved.
2+
from .dummy_resnet import DummyResNet
3+
4+
__all__ = ['DummyResNet']

Diff for: projects/example_project/dummy/dummy_resnet.py

+15
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
# Copyright (c) OpenMMLab. All rights reserved.
2+
from mmseg.models import BACKBONES
3+
from mmseg.models.backbones import ResNetV1c
4+
5+
6+
@BACKBONES.register_module()
7+
class DummyResNet(ResNetV1c):
8+
"""Implements a dummy ResNet wrapper for demonstration purpose.
9+
Args:
10+
**kwargs: All the arguments are passed to the parent class.
11+
"""
12+
13+
def __init__(self, **kwargs) -> None:
14+
print('Hello world!')
15+
super().__init__(**kwargs)

0 commit comments

Comments
 (0)