Skip to content

Commit

Permalink
Merge branch 'master' of https://github.com/open-mmlab/mmdetection in…
Browse files Browse the repository at this point in the history
…to fix_docs
  • Loading branch information
jshilong committed Dec 2, 2021
2 parents 67e49ca + f08548b commit 7bd36f0
Show file tree
Hide file tree
Showing 85 changed files with 2,165 additions and 557 deletions.
168 changes: 168 additions & 0 deletions .circleci/config.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,168 @@
version: 2.1

jobs:
lint:
docker:
- image: cimg/python:3.7.4
steps:
- checkout
- run:
name: Install dependencies
command: |
sudo apt-add-repository ppa:brightbox/ruby-ng -y
sudo apt-get update
sudo apt-get install -y ruby2.7
- run:
name: Install pre-commit hook
command: |
pip install pre-commit
pre-commit install
- run:
name: Linting
command: pre-commit run --all-files
- run:
name: Check docstring coverage
command: |
pip install interrogate
interrogate -v --ignore-init-method --ignore-module --ignore-nested-functions --ignore-regex "__repr__" --fail-under 50 mmdet
build_cpu:
parameters:
# The python version must match available image tags in
# https://circleci.com/developer/images/image/cimg/python
python:
type: string
default: "3.7.4"
torch:
type: string
torchvision:
type: string
docker:
- image: cimg/python:<< parameters.python >>
resource_class: large
steps:
- checkout
- run:
name: Install Libraries
command: |
sudo apt-get update
sudo apt-get install -y ninja-build libglib2.0-0 libsm6 libxrender-dev libxext6 libgl1-mesa-glx libjpeg-dev zlib1g-dev libtinfo-dev libncurses5
- run:
name: Configure Python & pip
command: |
pip install --upgrade pip
pip install wheel
- run:
name: Install PyTorch
command: |
python -V
pip install torch==<< parameters.torch >>+cpu torchvision==<< parameters.torchvision >>+cpu -f https://download.pytorch.org/whl/torch_stable.html
- when:
condition:
equal: [ "3.9.0", << parameters.python >> ]
steps:
- run: pip install protobuf && sudo apt-get update && sudo apt-get -y install libprotobuf-dev protobuf-compiler cmake
- run:
name: Install mmdet dependencies
command: |
pip install mmcv-full -f https://download.openmmlab.com/mmcv/dist/cpu/torch<< parameters.torch >>/index.html
pip install -r requirements/tests.txt -r requirements/optional.txt
pip install albumentations>=0.3.2 --no-binary imgaug,albumentations
pip install git+https://github.com/cocodataset/panopticapi.git
- run:
name: Build and install
command: |
pip install -e .
- run:
name: Run unittests
command: |
coverage run --branch --source mmdet -m pytest tests/
coverage xml
coverage report -m
build_cu101:
machine:
image: ubuntu-1604-cuda-10.1:201909-23
resource_class: gpu.nvidia.small
steps:
- checkout
- run:
name: Install Libraries
command: |
sudo apt-get update
sudo apt-get install -y git ninja-build libglib2.0-0 libsm6 libxrender-dev libxext6 libgl1-mesa-glx
- run:
name: Configure Python & pip
command: |
pyenv global 3.7.0
pip install --upgrade pip
pip install wheel
- run:
name: Install PyTorch
command: |
python -V
pip install torch==1.6.0+cu101 torchvision==0.7.0+cu101 -f https://download.pytorch.org/whl/torch_stable.html
- run:
name: Install mmdet dependencies
# pip install mmcv-full -f https://download.openmmlab.com/mmcv/dist/cu101/torch${{matrix.torch_version}}/index.html
command: |
pip install mmcv-full -f https://download.openmmlab.com/mmcv/dist/cu101/torch1.6.0/index.html
pip install -r requirements/tests.txt -r requirements/optional.txt
pip install pycocotools
pip install albumentations>=0.3.2 --no-binary imgaug,albumentations
pip install git+https://github.com/cocodataset/panopticapi.git
python -c 'import mmcv; print(mmcv.__version__)'
- run:
name: Build and install
command: |
python setup.py check -m -s
TORCH_CUDA_ARCH_LIST=7.0 pip install -e .
- run:
name: Run unittests
command: |
pytest tests/
workflows:
unit_tests:
jobs:
- lint
- build_cpu:
name: build_cpu_th1.6
torch: 1.6.0
torchvision: 0.7.0
requires:
- lint
- build_cpu:
name: build_cpu_th1.7
torch: 1.7.0
torchvision: 0.8.1
requires:
- lint
- build_cpu:
name: build_cpu_th1.8_py3.9
torch: 1.8.0
torchvision: 0.9.0
python: "3.9.0"
requires:
- lint
- build_cpu:
name: build_cpu_th1.9_py3.8
torch: 1.9.0
torchvision: 0.10.0
python: "3.8.12"
requires:
- lint
- build_cpu:
name: build_cpu_th1.9_py3.9
torch: 1.9.0
torchvision: 0.10.0
python: "3.9.0"
requires:
- lint
- build_cu101:
requires:
- build_cpu_th1.6
- build_cpu_th1.7
- build_cpu_th1.8_py3.9
- build_cpu_th1.9_py3.8
- build_cpu_th1.9_py3.9
30 changes: 23 additions & 7 deletions .dev_scripts/gather_models.py
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,14 @@ def get_final_epoch(config):
return cfg.runner.max_epochs


def get_best_epoch(exp_dir):
best_epoch_full_path = list(
sorted(glob.glob(osp.join(exp_dir, 'best_*.pth'))))[-1]
best_epoch_model_path = best_epoch_full_path.split('/')[-1]
best_epoch = best_epoch_model_path.split('_')[-1].split('.')[0]
return best_epoch_model_path, int(best_epoch)


def get_real_epoch(config):
cfg = mmcv.Config.fromfile('./configs/' + config)
epoch = cfg.runner.max_epochs
Expand Down Expand Up @@ -160,6 +168,10 @@ def parse_args():
help='root path of benchmarked models to be gathered')
parser.add_argument(
'out', type=str, help='output path of gathered models to be stored')
parser.add_argument(
'--best',
action='store_true',
help='whether to gather the best model.')

args = parser.parse_args()
return args
Expand Down Expand Up @@ -187,10 +199,13 @@ def main():
for used_config in used_configs:
exp_dir = osp.join(models_root, used_config)
# check whether the exps is finished
final_epoch = get_final_epoch(used_config)
final_model = 'epoch_{}.pth'.format(final_epoch)
model_path = osp.join(exp_dir, final_model)
if args.best is True:
final_model, final_epoch = get_best_epoch(exp_dir)
else:
final_epoch = get_final_epoch(used_config)
final_model = 'epoch_{}.pth'.format(final_epoch)

model_path = osp.join(exp_dir, final_model)
# skip if the model is still training
if not osp.exists(model_path):
continue
Expand Down Expand Up @@ -221,6 +236,7 @@ def main():
results=model_performance,
epochs=final_epoch,
model_time=model_time,
final_model=final_model,
log_json_path=osp.split(log_json_path)[-1]))

# publish model for each checkpoint
Expand All @@ -234,7 +250,7 @@ def main():
model_name += '_' + model['model_time']
publish_model_path = osp.join(model_publish_dir, model_name)
trained_model_path = osp.join(models_root, model['config'],
'epoch_{}.pth'.format(model['epochs']))
model['final_model'])

# convert model
final_model_path = process_checkpoint(trained_model_path,
Expand All @@ -254,9 +270,9 @@ def main():
config_path = osp.join(
'configs',
config_path) if 'configs' not in config_path else config_path
target_cconfig_path = osp.split(config_path)[-1]
shutil.copy(config_path,
osp.join(model_publish_dir, target_cconfig_path))
target_config_path = osp.split(config_path)[-1]
shutil.copy(config_path, osp.join(model_publish_dir,
target_config_path))

model['model_path'] = final_model_path
publish_model_infos.append(model)
Expand Down
74 changes: 32 additions & 42 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
@@ -1,52 +1,47 @@
name: build

on: [push, pull_request]
on:
push:
paths-ignore:
- '.dev_scripts/**'
- '.github/**.md'
- 'demo/**'
- 'docker/**'
- 'tools/**'

jobs:
lint:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- name: Set up Python 3.7
uses: actions/setup-python@v2
with:
python-version: 3.7
- name: Install pre-commit hook
run: |
pip install pre-commit
pre-commit install
- name: Linting
run: pre-commit run --all-files
- name: Check docstring coverage
run: |
pip install interrogate
interrogate -v --ignore-init-method --ignore-module --ignore-nested-functions --ignore-regex "__repr__" --fail-under 80 mmdet
pull_request:
paths-ignore:
- '.dev_scripts/**'
- '.github/**.md'
- 'demo/**'
- 'docker/**'
- 'tools/**'
- 'docs/**'
- 'docs_zh-CN/**'

jobs:
build_cpu:
runs-on: ubuntu-18.04
strategy:
matrix:
python-version: [3.7]
torch: [1.3.1, 1.5.1, 1.6.0, 1.7.0, 1.8.0, 1.9.0]
torch: [1.5.1, 1.6.0, 1.7.0, 1.8.0, 1.9.0]
include:
- torch: 1.3.1
torchvision: 0.4.2
mmcv: "latest+torch1.3.0+cpu"
- torch: 1.5.1
torchvision: 0.6.1
mmcv: "latest+torch1.5.0+cpu"
mmcv: 1.5.0
- torch: 1.6.0
torchvision: 0.7.0
mmcv: "latest+torch1.6.0+cpu"
mmcv: 1.6.0
- torch: 1.7.0
torchvision: 0.8.1
mmcv: "latest+torch1.7.0+cpu"
mmcv: 1.7.0
- torch: 1.8.0
torchvision: 0.9.0
mmcv: "latest+torch1.8.0+cpu"
mmcv: 1.8.0
- torch: 1.9.0
torchvision: 0.10.0
mmcv: "latest+torch1.9.0+cpu"
mmcv: 1.9.0
steps:
- uses: actions/checkout@v2
- name: Set up Python ${{ matrix.python-version }}
Expand All @@ -60,7 +55,7 @@ jobs:
run: pip install torch==${{matrix.torch}}+cpu torchvision==${{matrix.torchvision}}+cpu -f https://download.pytorch.org/whl/torch_stable.html
- name: Install MMCV
run: |
pip install mmcv-full -f https://download.openmmlab.com/mmcv/dist/cpu/torch${{matrix.torch}}/index.html
pip install mmcv-full -f https://download.openmmlab.com/mmcv/dist/cpu/torch${{matrix.mmcv}}/index.html
python -c 'import mmcv; print(mmcv.__version__)'
- name: Install unittest dependencies
run: |
Expand All @@ -85,33 +80,28 @@ jobs:
python-version: [3.7]
torch:
[
1.3.1,
1.5.1+cu101,
1.6.0+cu101,
1.7.0+cu101,
1.8.0+cu101,
]
include:
- torch: 1.3.1
torch_version: torch1.3.1
torchvision: 0.4.2
mmcv_link: "torch1.3.0"
- torch: 1.5.1+cu101
torch_version: torch1.5.1
torchvision: 0.6.1+cu101
mmcv_link: "torch1.5.0"
mmcv: 1.5.0
- torch: 1.6.0+cu101
torch_version: torch1.6.0
torchvision: 0.7.0+cu101
mmcv_link: "torch1.6.0"
mmcv: 1.6.0
- torch: 1.7.0+cu101
torch_version: torch1.7.0
torchvision: 0.8.1+cu101
mmcv_link: "torch1.7.0"
mmcv: 1.7.0
- torch: 1.8.0+cu101
torch_version: torch1.8.0
torchvision: 0.9.0+cu101
mmcv_link: "torch1.8.0"
mmcv: 1.8.0

steps:
- uses: actions/checkout@v2
Expand All @@ -135,7 +125,7 @@ jobs:
- name: Install mmdet dependencies
run: |
python -V
python -m pip install mmcv-full -f https://download.openmmlab.com/mmcv/dist/cu101/${{matrix.mmcv_link}}/index.html
python -m pip install mmcv-full -f https://download.openmmlab.com/mmcv/dist/cu101/torch${{matrix.mmcv}}/index.html
python -m pip install pycocotools
python -m pip install -r requirements/tests.txt -r requirements/optional.txt
python -m pip install albumentations>=0.3.2 --no-binary imgaug,albumentations
Expand Down Expand Up @@ -173,7 +163,7 @@ jobs:
- torch: 1.9.0+cu102
torch_version: torch1.9.0
torchvision: 0.10.0+cu102
mmcv_link: "torch1.9.0"
mmcv: 1.9.0

steps:
- uses: actions/checkout@v2
Expand Down Expand Up @@ -208,7 +198,7 @@ jobs:
- name: Install mmdet dependencies
run: |
python -V
python -m pip install mmcv-full -f https://download.openmmlab.com/mmcv/dist/cu102/${{matrix.mmcv_link}}/index.html
python -m pip install mmcv-full -f https://download.openmmlab.com/mmcv/dist/cu102/torch${{matrix.mmcv}}/index.html
python -m pip install pycocotools
python -m pip install -r requirements/tests.txt -r requirements/optional.txt
python -m pip install albumentations>=0.3.2 --no-binary imgaug,albumentations
Expand Down
Loading

0 comments on commit 7bd36f0

Please sign in to comment.