Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Enhance] enable projects #1526

Merged
merged 6 commits into from
Dec 13, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .circleci/config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ workflows:
.dev_scripts/.* lint_only true
.github/.* lint_only true
demo/.* lint_only true
projects/.* lint_only true
base-revision: dev-1.x
# this is the path of the configuration we should trigger once
# path filtering and pipeline parameter value updates are
Expand Down
1 change: 1 addition & 0 deletions .github/workflows/merge_stage_test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ on:
- '.dev_scripts/**'
- '.circleci/**'
- 'configs/**'
- 'projects/**'

branches:
- dev-1.x
Expand Down
1 change: 1 addition & 0 deletions .github/workflows/pr_stage_test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ on:
- 'README.md'
- 'README_zh-CN.md'
- 'docs/**'
- 'projects/**'
- '.dev_scripts/**'
- '.circleci/**'
- 'configs/**'
Expand Down
24 changes: 24 additions & 0 deletions projects/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
# Welcome to Projects of MMEditing

In this folder, we welcome all contribution of image, video, 3D content generation, editing and processing.

Here, these requirements, e.g. code standards, are not that strict as in core package.
Thus, developers from the community can implement their algorithms much more easily and efficiently in MMEditing.
We appreciate all contributions from community to make MMEditing greater.

Here is an [example project](./example_project) about how to add your algorithms easily.
You can copy and create your own project from the [example project](./example_project).

We also provide some documentation listed below:

- [New Model Guide](https://mmediting.readthedocs.io/en/dev-1.x/howto/models.html)

The documentation of adding new models.

- [Contribution Guide](https://mmediting.readthedocs.io/en/dev-1.x/community/contributing.html)

The guides for new contributors about how to add your projects to MMEditing.

- [Discussions](https://github.com/open-mmlab/mmediting/discussions)

Welcome to start discussion!
140 changes: 140 additions & 0 deletions projects/example_project/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,140 @@
# Example Project

This is an example README for community `projects/`. You can write your README in your own project. Here are
some recommended parts of a README for others to understand and use your project, you can copy or modify them
according to your project.

## Description \[required\]

You can share any information you would like others to know. For example:

```
Author: @xxx.

This is an implementation of \[XXX\].
```

## Usage \[required\]

### Setup Environment \[required\]

Please refer to [Get Started](https://mmediting.readthedocs.io/en/1.x/get_started/I.html) to install
MMEditing.

At first, add the current folder to `PYTHONPATH`, so that Python can find your code. Run command in the current directory to add it.

> Please run it every time after you opened a new shell.

```shell
export PYTHONPATH=`pwd`:$PYTHONPATH
```

### Data Preparation \[optional\]

Prepare the ImageNet-2012 dataset according to the [instruction](https://mmediting.readthedocs.io/en/dev-1.x/user_guides/dataset_prepare.html#imagenet).

### Training commands \[optional\]

**To train with single GPU:**

```bash
mim train mmedit configs/examplenet_8xb32_in1k.py
```

**To train with multiple GPUs:**

```bash
mim train mmedit configs/examplenet_8xb32_in1k.py --launcher pytorch --gpus 8
```

**To train with multiple GPUs by slurm:**

```bash
mim train mmedit configs/examplenet_8xb32_in1k.py --launcher slurm \
--gpus 16 --gpus-per-node 8 --partition $PARTITION
```

### Testing commands \[required\]

**To test with single GPU:**

```bash
mim test mmedit configs/examplenet_8xb32_in1k.py $CHECKPOINT
```

**To test with multiple GPUs:**

```bash
mim test mmedit configs/examplenet_8xb32_in1k.py $CHECKPOINT --launcher pytorch --gpus 8
```

**To test with multiple GPUs by slurm:**

```bash
mim test mmedit configs/examplenet_8xb32_in1k.py $CHECKPOINT --launcher slurm \
--gpus 16 --gpus-per-node 8 --partition $PARTITION
```

## Results \[required\]

| Model | Pretrain | Top-1 (%) | Top-5 (%) | Config | Download |
| :----------------: | :----------: | :-------: | :-------: | :----------------------------------------: | :------------------------------------: |
| ExampleNet-tiny | From scratch | 82.33 | 96.15 | [config](configs/examplenet_8xb32_in1k.py) | [model](MODEL-LINK) \| [log](LOG-LINK) |
| ExampleNet-small\* | From scratch | 83.63 | 96.51 | [config](configs/examplenet_8xb32_in1k.py) | [model](MODEL-LINK) |
| ExampleNet-base\* | From scratch | 84.34 | 96.86 | [config](configs/examplenet_8xb32_in1k.py) | [model](MODEL-LINK) |

*Models with * are converted from the [official repo](REPO-LINK). The config files of these models are only for inference. We don't ensure these config files' training accuracy and welcome you to contribute your reproduction results.*

You can also paste some visual results here if the model doesn't have quantitative results.

## Citation \[required\]

<!-- Replace to the citation of the paper your project refers to. -->

```bibtex
@misc{mmediting2022,
title = {{MMEditing}: {OpenMMLab} Image and Video Editing Toolbox},
author = {{MMEditing Contributors}},
howpublished = {\url{https://github.com/open-mmlab/mmediting}},
year = {2022}
}
```

## Checklist \[required\]

Here is a checklist of this project's progress. And you can ignore this part if you don't plan to contribute
to MMediting projects.

- [ ] Milestone 1: PR-ready, and acceptable to be one of the `projects/`.

- [ ] Finish the code

<!-- The code's design shall follow existing interfaces and convention. For example, each model component should be registered into `mmedit.registry.MODELS` and configurable via a config file. -->

- [ ] Basic docstrings & proper citation

<!-- Each major class should contains a docstring, describing its functionality and arguments. If your code is copied or modified 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) -->

- [ ] Converted checkpoint and results (Only for reproduction)

<!-- If you are reproducing the result from a paper, make sure the model in the project can match that results. Also please provide checkpoint links or a checkpoint conversion script for others to get the pre-trained model. -->

- [ ] Milestone 2: Indicates a successful model implementation.

- [ ] Training results

<!-- If you are reproducing the result from a paper, train your model from scratch and verified that the final result can match the original result. -->

- [ ] Milestone 3: Good to be a part of our core package!

- [ ] Unit tests

<!-- Unit tests for the major module are required. [Example](https://github.com/open-mmlab/mmediting/blob/1.x/tests/test_models/test_backbones/test_vision_transformer.py) -->

- [ ] Code style

<!-- Refactor your code according to reviewer's comment. -->

- [ ] `metafile.yml` and `README.md`

<!-- It will used for mmediting to acquire your models. [Example](https://github.com/open-mmlab/mmediting/blob/1.x/configs/mvit/metafile.yml). In particular, you may have to refactor this README into a standard one. [Example](https://github.com/open-mmlab/mmediting/blob/1.x/configs/swin_transformer/README.md) -->
7 changes: 7 additions & 0 deletions projects/example_project/configs/examplenet_8xb32_in1k.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
# Directly inherit the entire recipe you want to use.
_base_ = 'mmediting::srcnn/srcnn_x4k915_1xb16-1000k_div2k.py'

# This line is to import your own modules.
custom_imports = dict(imports='models')

# Set your model, training, testing configurations.
3 changes: 3 additions & 0 deletions projects/example_project/models/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
from .example_net import ExampleNet

__all__ = ['ExampleNet']
31 changes: 31 additions & 0 deletions projects/example_project/models/example_net.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
from mmedit.models import ResNet
from mmedit.registry import MODELS


# Register your model to the `MODELS`.
@MODELS.register_module()
class ExampleNet(ResNet):
"""Implements an example backbone.

Implement the backbone network just like a normal pytorch network.
"""

def __init__(self, **kwargs) -> None:
print('#############################\n'
'# Hello MMEditing! #\n'
'#############################')
super().__init__(**kwargs)

def forward(self, x):
"""The forward method of the network.

Args:
x (torch.Tensor): A tensor of image batch with shape
``(batch_size, num_channels, height, width)``.

Returns:
Tuple[torch.Tensor]: Please return a tuple of tensors and every
tensor is a feature map of specified scale. If you only want the
final feature map, simply return a tuple with one item.
"""
return super().forward(x)