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

merge main #527

Merged
merged 7 commits into from
Apr 26, 2023
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
2 changes: 1 addition & 1 deletion .circleci/config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ workflows:
tools/.* lint_only false
configs/.* lint_only false
.circleci/.* lint_only false
base-revision: dev-1.x
base-revision: main
# this is the path of the configuration we should trigger once
# path filtering and pipeline parameter value updates are
# complete. In this case, we are using the parent dynamic
Expand Down
34 changes: 17 additions & 17 deletions .circleci/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -67,10 +67,10 @@ jobs:
pip install git+https://github.com/open-mmlab/mmengine.git@main
pip install -U openmim
mim install 'mmcv >= 2.0.0rc1'
pip install git+https://github.com/open-mmlab/mmclassification.git@dev-1.x
pip install git+https://github.com/open-mmlab/mmdetection.git@dev-3.x
pip install git+https://github.com/open-mmlab/mmsegmentation.git@dev-1.x
python -m pip install git+ssh://git@github.com/open-mmlab/mmpose.git@dev-1.x
pip install git+https://github.com/open-mmlab/mmpretrain.git@mmcls-1.x
pip install git+https://github.com/open-mmlab/mmdetection.git@main
pip install git+https://github.com/open-mmlab/mmsegmentation.git@main
python -m pip install git+ssh://git@github.com/open-mmlab/mmpose.git@main
pip install -r requirements.txt
- run:
name: Build and install
Expand Down Expand Up @@ -103,9 +103,9 @@ jobs:
name: Clone Repos
command: |
git clone -b main --depth 1 https://github.com/open-mmlab/mmengine.git /home/circleci/mmengine
git clone -b dev-3.x --depth 1 https://github.com/open-mmlab/mmdetection.git /home/circleci/mmdetection
git clone -b dev-1.x --depth 1 https://github.com/open-mmlab/mmclassification.git /home/circleci/mmclassification
git clone -b dev-1.x --depth 1 https://github.com/open-mmlab/mmsegmentation.git /home/circleci/mmsegmentation
git clone -b main --depth 1 https://github.com/open-mmlab/mmdetection.git /home/circleci/mmdetection
git clone -b 1.x --depth 1 https://github.com/open-mmlab/mmclassification.git /home/circleci/mmclassification
git clone -b main --depth 1 https://github.com/open-mmlab/mmsegmentation.git /home/circleci/mmsegmentation
- run:
name: Build Docker image
command: |
Expand Down Expand Up @@ -139,7 +139,7 @@ workflows:
filters:
branches:
ignore:
- dev-1.x
- main
- 1.x
pr_stage_test:
when:
Expand All @@ -150,18 +150,18 @@ workflows:
filters:
branches:
ignore:
- dev-1.x
- main
- build_cpu:
name: minimum_version_cpu
torch: 1.6.0
torchvision: 0.7.0
python: 3.7.9
torch: 1.8.1
torchvision: 0.9.1
python: 3.7.4
requires:
- lint
- build_cpu:
name: maximum_version_cpu
torch: 1.12.1
torchvision: 0.13.1
torch: 1.13.1
torchvision: 0.14.1
python: 3.9.0
requires:
- lint
Expand All @@ -183,11 +183,11 @@ workflows:
jobs:
- build_cuda:
name: minimum_version_gpu
torch: 1.6.0
torch: 1.8.1
# Use double quotation mark to explicitly specify its type
# as string instead of number
cuda: "10.1"
cuda: "10.2"
filters:
branches:
only:
- dev-1.x
- main
67 changes: 67 additions & 0 deletions .dev_scripts/benchmark_summary_analyse.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,67 @@
import argparse
import os

import mmengine


def parse_args():
parser = argparse.ArgumentParser(
description='Analyse summary.yml generated by benchmark test')
parser.add_argument('file_path', help='Summary.yml path')
args = parser.parse_args()
return args


metric_mapping = {
'Top 1 Accuracy': 'accuracy/top1',
'Top 5 Accuracy': 'accuracy/top5',
'box AP': 'coco/bbox_mAP',
'mIoU': 'mIoU'
}


def compare_metric(result, metric):
expect_val = result['expect'][metric]
actual_val = result['actual'].get(metric_mapping[metric], None)
if actual_val is None:
return None, None
if metric == 'box AP':
actual_val *= 100
decimal_bit = len(str(expect_val).split('.')[-1])
actual_val = round(actual_val, decimal_bit)
error = round(actual_val - expect_val, decimal_bit)
error_percent = round(abs(error) * 100 / expect_val, 3)
return error, error_percent


def main():
args = parse_args()
file_path = args.file_path
results = mmengine.load(file_path, 'yml')
miss_models = dict()
sort_by_error = dict()
for k, v in results.items():
valid_keys = v['expect'].keys()
compare_res = dict()
for m in valid_keys:
error, error_percent = compare_metric(v, m)
if error is None:
continue
compare_res[m] = {'error': error, 'error_percent': error_percent}
if error != 0:
miss_models[k] = compare_res
sort_by_error[k] = error
sort_by_error = sorted(
sort_by_error.items(), key=lambda x: abs(x[1]), reverse=True)
miss_models_sort = dict()
miss_models_sort['total error models'] = len(sort_by_error)
for k_v in sort_by_error:
index = k_v[0]
miss_models_sort[index] = miss_models[index]
save_path = os.path.join(os.path.dirname(file_path), 'summary_error.yml')
mmengine.fileio.dump(miss_models_sort, save_path, sort_keys=False)
print(f'Summary analysis result saved in {save_path}')


if __name__ == '__main__':
main()
5 changes: 3 additions & 2 deletions .dev_scripts/benchmark_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,9 +24,9 @@
def parse_args():
parser = argparse.ArgumentParser(
description="Test all models' accuracy in model-index.yml")
parser.add_argument(
'partition', type=str, help='Cluster partition to use.')
parser.add_argument('checkpoint_root', help='Checkpoint file root path.')
parser.add_argument(
'--partition', type=str, help='Cluster partition to use.')
parser.add_argument(
'--job-name',
type=str,
Expand Down Expand Up @@ -148,6 +148,7 @@ def create_test_job_batch(commands, model_info, args, port):
if exists:
print(f'{checkpoint} already exists.')
else:
print(f'start downloading {fname}')
wget.download(model_info.weights, str(checkpoint))
print(f'\nSaved in {checkpoint}.')

Expand Down
24 changes: 7 additions & 17 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -25,22 +25,12 @@ concurrency:

jobs:
test_linux:
runs-on: ubuntu-18.04
runs-on: ubuntu-20.04
strategy:
matrix:
python-version: [3.7]
torch: [1.6.0, 1.7.0, 1.8.0, 1.9.0, 1.10.0, 1.11.0, 1.12.0, 1.13.0]
torch: [1.8.0, 1.9.0, 1.10.0, 1.11.0, 1.12.0, 1.13.0]
include:
- torch: 1.6.0
torch_version: 1.6
torchvision: 0.7.0
- torch: 1.7.0
torch_version: 1.7
torchvision: 0.8.1
- torch: 1.7.0
torch_version: 1.7
torchvision: 0.8.1
python-version: 3.8
- torch: 1.8.0
torch_version: 1.8
torchvision: 0.9.0
Expand Down Expand Up @@ -103,11 +93,11 @@ jobs:
pip install -U openmim
mim install 'mmcv >= 2.0.0rc1'
- name: Install MMCls
run: pip install git+https://github.com/open-mmlab/mmclassification.git@dev-1.x
run: pip install 'mmcls>=1.0.0rc0'
- name: Install MMDet
run: pip install git+https://github.com/open-mmlab/mmdetection.git@dev-3.x
run: pip install git+https://github.com/open-mmlab/mmdetection.git@main
- name: Install MMSeg
run: pip install git+https://github.com/open-mmlab/mmsegmentation.git@dev-1.x
run: pip install git+https://github.com/open-mmlab/mmsegmentation.git@main
- name: Install other dependencies
run: pip install -r requirements.txt
- name: Build and install
Expand All @@ -119,8 +109,8 @@ jobs:
coverage report -m
# Upload coverage report for python3.8 && pytorch1.12.0 cpu
- name: Upload coverage to Codecov
if: ${{matrix.torch == '1.12.0' && matrix.python-version == '3.8'}}
uses: codecov/codecov-action@v2
if: ${{matrix.torch == '1.13.0' && matrix.python-version == '3.8'}}
uses: codecov/codecov-action@v3
with:
file: ./coverage.xml
flags: unittests
Expand Down
54 changes: 36 additions & 18 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@
<!--算法库 Badges-->

[![PyPI](https://img.shields.io/pypi/v/mmrazor)](https://pypi.org/project/mmrazor)
[![docs](https://img.shields.io/badge/docs-latest-blue)](https://mmrazor.readthedocs.io/en/dev-1.x/)
[![docs](https://img.shields.io/badge/docs-latest-blue)](https://mmrazor.readthedocs.io/en/main/)
[![badge](https://github.com/open-mmlab/mmrazor/workflows/build/badge.svg)](https://github.com/open-mmlab/mmrazor/actions)
[![codecov](https://codecov.io/gh/open-mmlab/mmrazor/branch/master/graph/badge.svg)](https://codecov.io/gh/open-mmlab/mmrazor)
[![license](https://img.shields.io/github/license/open-mmlab/mmrazor.svg)](https://github.com/open-mmlab/mmrazor/blob/master/LICENSE)
Expand All @@ -32,9 +32,9 @@

<!--Note:请根据各算法库自身情况设置项目和链接-->

[📘Documentation](https://mmrazor.readthedocs.io/en/dev-1.x/) |
[🛠️Installation](https://mmrazor.readthedocs.io/en/dev-1.x/get_started/installation.html) |
[👀Model Zoo](https://mmrazor.readthedocs.io/en/dev-1.x/get_started/model_zoo.html) |
[📘Documentation](https://mmrazor.readthedocs.io/en/main/) |
[🛠️Installation](https://mmrazor.readthedocs.io/en/main/get_started/installation.html) |
[👀Model Zoo](https://mmrazor.readthedocs.io/en/main/get_started/model_zoo.html) |
[🤔Reporting Issues](https://github.com/open-mmlab/mmrazor/issues/new/choose)

</div>
Expand Down Expand Up @@ -65,12 +65,12 @@ English | [简体中文](README_zh-CN.md)

## Introduction

MMRazor is a model compression toolkit for model slimming and AutoML, which includes 3 mainstream technologies:
MMRazor is a model compression toolkit for model slimming and AutoML, which includes 4 mainstream technologies:

- Neural Architecture Search (NAS)
- Pruning
- Knowledge Distillation (KD)
- Quantization (come soon)
- Quantization

It is a part of the [OpenMMLab](https://openmmlab.com/) project.

Expand All @@ -88,22 +88,23 @@ Major features:

With better modular design, developers can implement new model compression algorithms with only a few codes, or even by simply modifying config files.

Below is an overview of MMRazor's design and implementation, please refer to [tutorials](https://mmrazor.readthedocs.io/en/dev-1.x/get_started/overview.html) for more details.
About MMRazor's design and implementation, please refer to [tutorials](https://mmrazor.readthedocs.io/en/main/get_started/overview.html) for more details.

<div align="center">
<img src="resources/design_and_implement.png" style="zoom:100%"/>
</div>
<br />
## Latest Updates

## What's new
**The default branch is now `main` and the code on the branch has been upgraded to v1.0.0. The old `master` branch code now exists on the 0.x branch**

MMRazor v1.0.0rc0 was released in 1/9/2022.
MMRazor v1.0.0 was released in 2023-4-24, Major updates from 1.0.0rc2 include:

Please refer to [changelog.md](/docs/en/notes/changelog.md) for more details and other release history.
1. MMRazor quantization is released.
2. Add a new pruning algorithm named GroupFisher.
3. Support distilling rtmdet with MMRazor.

To know more about the updates in MMRazor 1.0, please refer to [Changelog](https://mmrazor.readthedocs.io/en/main/notes/changelog.html) for more details!

## Benchmark and model zoo

Results and models are available in the [model zoo](/docs/en/get_started/model_zoo.md).
Results and models are available in the [model zoo](https://mmrazor.readthedocs.io/en/main/get_started/model_zoo.html).

Supported algorithms:

Expand All @@ -123,6 +124,12 @@ Supported algorithms:

- [x] [AutoSlim(NeurIPS'2019)](/configs/pruning/mmcls/autoslim)

- [x] [L1-norm](/configs/pruning/mmcls/l1-norm)

- [x] [Group Fisher](/configs/pruning/base/group_fisher)

- [x] [DMCP](/configs/pruning/mmcls/dmcp)

</details>

<details open>
Expand Down Expand Up @@ -158,20 +165,31 @@ Supported algorithms:

</details>

<details open>
<summary>Quantization</summary>

- [x] [PTQ](/configs/quantization/ptq/base)

- [x] [QAT](/configs/quantization/qat/base)

- [x] [LSQ](/configs/quantization/qat/lsq)

</details>

## Installation

MMRazor depends on [PyTorch](https://pytorch.org/), [MMCV](https://github.com/open-mmlab/mmcv) and [MMEngine](https://github.com/open-mmlab/mmengine).

Please refer to [installation.md](/docs/en/get_started/installation.md) for more detailed instruction.
Please refer to [installation.md](https://mmrazor.readthedocs.io/en/main/get_started/installation.html) for more detailed instruction.

## Getting Started

Please refer to [user guides](https://mmrazor.readthedocs.io/en/dev-1.x/user_guides/index.html) for the basic usage of MMRazor. There are also [advanced guides](https://mmrazor.readthedocs.io/en/dev-1.x/advanced_guides/index.html):
Please refer to [user guides](https://mmrazor.readthedocs.io/en/main/user_guides/index.html) for the basic usage of MMRazor. There are also [advanced guides](https://mmrazor.readthedocs.io/en/main/advanced_guides/index.html):

## Contributing

We appreciate all contributions to improve MMRazor.
Please refer to [CONTRUBUTING.md](/docs/en/notes/contribution_guide.md) for the contributing guideline.
Please refer to [CONTRUBUTING.md](https://mmrazor.readthedocs.io/en/main/notes/contribution_guide.html) for the contributing guideline.

## Acknowledgement

Expand Down
Loading