Skip to content

Commit

Permalink
Release v3.1.0 (#10572)
Browse files Browse the repository at this point in the history
  • Loading branch information
hhaAndroid authored Jun 30, 2023
2 parents ecac3a7 + c5c8aa0 commit f78af77
Show file tree
Hide file tree
Showing 447 changed files with 41,969 additions and 1,981 deletions.
21 changes: 13 additions & 8 deletions .circleci/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,7 @@ jobs:
equal: ["3.9.0", << parameters.python >>]
steps:
- run: pip install "protobuf <= 3.20.1" && sudo apt-get update && sudo apt-get -y install libprotobuf-dev protobuf-compiler cmake
- run: pip install dsdl
- run:
name: Install mmdet dependencies
# numpy may be downgraded after building pycocotools, which causes `ImportError: numpy.core.multiarray failed to import`
Expand All @@ -73,7 +74,9 @@ jobs:
pip install -r requirements/tests.txt -r requirements/optional.txt
pip install --force-reinstall pycocotools
pip install albumentations>=0.3.2 --no-binary imgaug,albumentations
pip install -r requirements/tracking.txt
pip install git+https://github.com/cocodataset/panopticapi.git
pip install git+https://github.com/JonathonLuiten/TrackEval.git
- run:
name: Build and install
command: |
Expand All @@ -91,10 +94,10 @@ jobs:
type: string
cuda:
type: enum
enum: ["10.1", "10.2", "11.1", "11.7"]
enum: ["11.1", "11.7"]
cudnn:
type: integer
default: 7
default: 8
machine:
image: ubuntu-2004-cuda-11.4:202110-01
# docker_layer_caching: true
Expand All @@ -121,7 +124,9 @@ jobs:
docker exec mmdetection pip install -r requirements/tests.txt -r requirements/optional.txt
docker exec mmdetection pip install pycocotools
docker exec mmdetection pip install albumentations>=0.3.2 --no-binary imgaug,albumentations
docker exec mmdetection pip install -r requirements/tracking.txt
docker exec mmdetection pip install git+https://github.com/cocodataset/panopticapi.git
docker exec mmdetection pip install git+https://github.com/JonathonLuiten/TrackEval.git
docker exec mmdetection python -c 'import mmcv; print(mmcv.__version__)'
- run:
name: Build and install
Expand Down Expand Up @@ -154,9 +159,9 @@ workflows:
- dev-3.x
- build_cpu:
name: minimum_version_cpu
torch: 1.6.0
torchvision: 0.7.0
python: 3.7.4 # The lowest python 3.7.x version available on CircleCI images
torch: 1.8.0
torchvision: 0.9.0
python: 3.7.16
requires:
- lint
- build_cpu:
Expand All @@ -175,7 +180,7 @@ workflows:
torch: 1.8.1
# Use double quotation mark to explicitly specify its type
# as string instead of number
cuda: "10.2"
cuda: "11.1"
requires:
- hold
- build_cuda:
Expand All @@ -191,8 +196,8 @@ workflows:
jobs:
- build_cuda:
name: minimum_version_gpu
torch: 1.6.0
cuda: "10.1"
torch: 1.8.0
cuda: "11.1"
filters:
branches:
only:
Expand Down
15 changes: 10 additions & 5 deletions .dev_scripts/benchmark_full_models.txt
Original file line number Diff line number Diff line change
Expand Up @@ -33,12 +33,13 @@ free_anchor/freeanchor_r50_fpn_1x_coco.py
fsaf/fsaf_r50_fpn_1x_coco.py
gcnet/mask-rcnn_r50-gcb-r4-c3-c5_fpn_1x_coco.py
gfl/gfl_r50_fpn_1x_coco.py
glip/glip_atss_swin-t_a_fpn_dyhead_pretrain_obj365.py
ghm/retinanet_r50_fpn_ghm-1x_coco.py
gn/mask-rcnn_r50_fpn_gn-all_2x_coco.py
gn+ws/faster-rcnn_r50_fpn_gn-ws-all_1x_coco.py
grid_rcnn/grid-rcnn_r50_fpn_gn-head_1x_coco.py
grid_rcnn/grid-rcnn_r50_fpn_gn-head_2x_coco.py
groie/faste-rcnn_r50_fpn_groie_1x_coco.py
guided_anchoring/ga-faster-rcnn_r50_fpn_1x_coco.py
guided_anchoring/ga-faster-rcnn_r50-caffe_fpn_1x_coco.py
hrnet/htc_hrnetv2p-w18_20e_coco.py
htc/htc_r50_fpn_1x_coco.py
instaboost/mask-rcnn_r50_fpn_instaboost-4x_coco.py
Expand All @@ -50,7 +51,7 @@ mask2former/mask2former_r50_8xb2-lsj-50e_coco.py
mask2former/mask2former_r50_8xb2-lsj-50e_coco-panoptic.py
mask_rcnn/mask-rcnn_r50_fpn_1x_coco.py
maskformer/maskformer_r50_ms-16xb1-75e_coco.py
ms_rcnn/ms-rcnn_r50_fpn_1x_coco.py
ms_rcnn/ms-rcnn_r50-caffe_fpn_1x_coco.py
nas_fcos/nas-fcos_r50-caffe_fpn_nashead-gn-head_4xb4-1x_coco.py
nas_fpn/retinanet_r50_nasfpn_crop640-50e_coco.py
paa/paa_r50_fpn_1x_coco.py
Expand Down Expand Up @@ -79,13 +80,17 @@ solo/solo_r50_fpn_1x_coco.py
solov2/solov2_r50_fpn_1x_coco.py
sparse_rcnn/sparse-rcnn_r50_fpn_1x_coco.py
ssd/ssd300_coco.py
strong_baselines/mask-rcnn_r50-caffe_fpn_rpn-2conv_4conv1fc_syncbn-all_amp-lsj-100e_coco.py
swin/mask-rcnn_swin-t-p4-w7_fpn_1x_coco.py
timm_example/retinanet_timm-tv-resnet50_fpn_1x_coco.py
tood/tood_r50_fpn_1x_coco.py
tridentnet/tridentnet_r50-caffe_1x_coco.py
vfnet/vfnet_r50_fpn_1x_coco.py
yolact/yolact_r50_8xb8-55e_coco.py
yolo/yolov3_d53_8xb8-320-273e_coco.py
yolof/yolof_r50-c5_8xb8-1x_coco.py
yolox/yolox_s_8xb8-300e_coco.py
deepsort/deepsort_faster-rcnn_r50_fpn_8xb2-4e_mot17halftrain_test-mot17halfval.py
mask2former_vis/mask2former_r50_8xb2-8e_youtubevis2021.py
masktrack_rcnn/masktrack-rcnn_mask-rcnn_r50_fpn_8xb1-12e_youtubevis2021.py
ocsort/ocsort_yolox_x_8xb4-amp-80e_crowdhuman-mot17halftrain_test-mot17halfval.py
qdtrack/qdtrack_faster-rcnn_r50_fpn_8xb2-4e_mot17halftrain_test-mot17halfval.py
strongsort/strongsort_yolox_x_8xb4-80e_crowdhuman-mot17halftrain_test-mot17halfval.py
5 changes: 4 additions & 1 deletion .dev_scripts/benchmark_options.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,11 @@
'pip install instaboostfast',
'pip install git+https://github.com/cocodataset/panopticapi.git',
'pip install timm',
'pip install mmcls>=1.0.0rc0',
'pip install mmpretrain',
'pip install git+https://github.com/lvis-dataset/lvis-api.git',
'pip install -r ../requirements/multimodal.txt',
'pip install -r ../requirements/tracking.txt',
'pip install git+https://github.com/JonathonLuiten/TrackEval.git',
]

default_floating_range = 0.5
Expand Down
4 changes: 3 additions & 1 deletion .dev_scripts/benchmark_train_models.txt
Original file line number Diff line number Diff line change
Expand Up @@ -15,4 +15,6 @@ mask2former/mask2former_r50_8xb2-lsj-50e_coco-panoptic.py
swin/mask-rcnn_swin-t-p4-w7_fpn_1x_coco.py
condinst/condinst_r50_fpn_ms-poly-90k_coco_instance.py
lvis/mask-rcnn_r50_fpn_sample1e-3_ms-1x_lvis-v1.py
convnext/mask-rcnn_convnext-t-p4-w7_fpn_amp-ms-crop-3x_coco.py
mask2former_vis/mask2former_r50_8xb2-8e_youtubevis2021.py
masktrack_rcnn/masktrack-rcnn_mask-rcnn_r50_fpn_8xb1-12e_youtubevis2021.py
qdtrack/qdtrack_faster-rcnn_r50_fpn_8xb2-4e_mot17halftrain_test-mot17halfval.py
126 changes: 45 additions & 81 deletions .dev_scripts/gather_models.py
Original file line number Diff line number Diff line change
@@ -1,10 +1,11 @@
# Copyright (c) OpenMMLab. All rights reserved.
import argparse
import glob
import json
import os
import os.path as osp
import shutil
import subprocess
import time
from collections import OrderedDict

import torch
Expand Down Expand Up @@ -32,11 +33,15 @@ def process_checkpoint(in_file, out_file):
# remove optimizer for smaller file size
if 'optimizer' in checkpoint:
del checkpoint['optimizer']
if 'ema_state_dict' in checkpoint:
del checkpoint['ema_state_dict']

# remove ema state_dict
for key in list(checkpoint['state_dict']):
if key.startswith('ema_'):
checkpoint['state_dict'].pop(key)
elif key.startswith('data_preprocessor'):
checkpoint['state_dict'].pop(key)

# if it is necessary to remove some sensitive data in checkpoint['meta'],
# add the code here.
Expand All @@ -52,15 +57,15 @@ def process_checkpoint(in_file, out_file):

def is_by_epoch(config):
cfg = Config.fromfile('./configs/' + config)
return cfg.runner.type == 'EpochBasedRunner'
return cfg.train_cfg.type == 'EpochBasedTrainLoop'


def get_final_epoch_or_iter(config):
cfg = Config.fromfile('./configs/' + config)
if cfg.runner.type == 'EpochBasedRunner':
return cfg.runner.max_epochs
if cfg.train_cfg.type == 'EpochBasedTrainLoop':
return cfg.train_cfg.max_epochs
else:
return cfg.runner.max_iters
return cfg.train_cfg.max_iters


def get_best_epoch_or_iter(exp_dir):
Expand All @@ -74,60 +79,22 @@ def get_best_epoch_or_iter(exp_dir):

def get_real_epoch_or_iter(config):
cfg = Config.fromfile('./configs/' + config)
if cfg.runner.type == 'EpochBasedRunner':
epoch = cfg.runner.max_epochs
if cfg.data.train.type == 'RepeatDataset':
epoch *= cfg.data.train.times
if cfg.train_cfg.type == 'EpochBasedTrainLoop':
epoch = cfg.train_cfg.max_epochs
return epoch
else:
return cfg.runner.max_iters
return cfg.train_cfg.max_iters


def get_final_results(log_json_path,
epoch_or_iter,
results_lut,
results_lut='coco/bbox_mAP',
by_epoch=True):
result_dict = dict()
last_val_line = None
last_train_line = None
last_val_line_idx = -1
last_train_line_idx = -1
with open(log_json_path, 'r') as f:
for i, line in enumerate(f.readlines()):
log_line = json.loads(line)
if 'mode' not in log_line.keys():
continue

if by_epoch:
if (log_line['mode'] == 'train'
and log_line['epoch'] == epoch_or_iter):
result_dict['memory'] = log_line['memory']

if (log_line['mode'] == 'val'
and log_line['epoch'] == epoch_or_iter):
result_dict.update({
key: log_line[key]
for key in results_lut if key in log_line
})
return result_dict
else:
if log_line['mode'] == 'train':
last_train_line_idx = i
last_train_line = log_line

if log_line and log_line['mode'] == 'val':
last_val_line_idx = i
last_val_line = log_line

# bug: max_iters = 768, last_train_line['iter'] = 750
assert last_val_line_idx == last_train_line_idx + 1, \
'Log file is incomplete'
result_dict['memory'] = last_train_line['memory']
result_dict.update({
key: last_val_line[key]
for key in results_lut if key in last_val_line
})

with open(log_json_path) as f:
r = f.readlines()[-1]
last_metric = r.split(',')[0].split(': ')[-1].strip()
result_dict[results_lut] = last_metric
return result_dict


Expand All @@ -150,6 +117,16 @@ def get_dataset_name(config):
return name_map[cfg.dataset_type]


def find_last_dir(model_dir):
dst_times = []
for time_stamp in os.scandir(model_dir):
if osp.isdir(time_stamp):
dst_time = time.mktime(
time.strptime(time_stamp.name, '%Y%m%d_%H%M%S'))
dst_times.append([dst_time, time_stamp.name])
return max(dst_times, key=lambda x: x[0])[1]


def convert_model_info_to_pwc(model_infos):
pwc_files = {}
for model in model_infos:
Expand All @@ -160,9 +137,7 @@ def convert_model_info_to_pwc(model_infos):
pwc_model_info['Config'] = osp.join('configs', model['config'])

# get metadata
memory = round(model['results']['memory'] / 1024, 1)
meta_data = OrderedDict()
meta_data['Training Memory (GB)'] = memory
if 'epochs' in model:
meta_data['Epochs'] = get_real_epoch_or_iter(model['config'])
else:
Expand Down Expand Up @@ -198,7 +173,7 @@ def convert_model_info_to_pwc(model_infos):
Metrics={'PQ': metric}))
pwc_model_info['Results'] = results

link_string = 'https://download.openmmlab.com/mmdetection/v2.0/'
link_string = 'https://download.openmmlab.com/mmdetection/v3.0/'
link_string += '{}/{}'.format(model['config'].rstrip('.py'),
osp.split(model['model_path'])[-1])
pwc_model_info['Weights'] = link_string
Expand All @@ -214,9 +189,13 @@ def parse_args():
parser.add_argument(
'root',
type=str,
default='work_dirs',
help='root path of benchmarked models to be gathered')
parser.add_argument(
'out', type=str, help='output path of gathered models to be stored')
'--out',
type=str,
default='gather',
help='output path of gathered models to be stored')
parser.add_argument(
'--best',
action='store_true',
Expand Down Expand Up @@ -262,32 +241,22 @@ def main():
continue

# get the latest logs
log_json_path = list(
sorted(glob.glob(osp.join(exp_dir, '*.log.json'))))[-1]
log_txt_path = list(sorted(glob.glob(osp.join(exp_dir, '*.log'))))[-1]
cfg = Config.fromfile('./configs/' + used_config)
results_lut = cfg.evaluation.metric
if not isinstance(results_lut, list):
results_lut = [results_lut]
# case when using VOC, the evaluation key is only 'mAP'
# when using Panoptic Dataset, the evaluation key is 'PQ'.
for i, key in enumerate(results_lut):
if 'mAP' not in key and 'PQ' not in key:
results_lut[i] = key + '_mAP'
model_performance = get_final_results(log_json_path,
final_epoch_or_iter, results_lut,
by_epoch)
latest_exp_name = find_last_dir(exp_dir)
latest_exp_json = osp.join(exp_dir, latest_exp_name, 'vis_data',
latest_exp_name + '.json')

model_performance = get_final_results(
latest_exp_json, final_epoch_or_iter, by_epoch=by_epoch)

if model_performance is None:
continue

model_time = osp.split(log_txt_path)[-1].split('.')[0]
model_info = dict(
config=used_config,
results=model_performance,
model_time=model_time,
final_model=final_model,
log_json_path=osp.split(log_json_path)[-1])
latest_exp_json=latest_exp_json,
latest_exp_name=latest_exp_name)
model_info['epochs' if by_epoch else 'iterations'] =\
final_epoch_or_iter
model_infos.append(model_info)
Expand All @@ -300,7 +269,7 @@ def main():

model_name = osp.split(model['config'])[-1].split('.')[0]

model_name += '_' + model['model_time']
model_name += '_' + model['latest_exp_name']
publish_model_path = osp.join(model_publish_dir, model_name)
trained_model_path = osp.join(models_root, model['config'],
model['final_model'])
Expand All @@ -310,13 +279,8 @@ def main():
publish_model_path)

# copy log
shutil.copy(
osp.join(models_root, model['config'], model['log_json_path']),
osp.join(model_publish_dir, f'{model_name}.log.json'))
shutil.copy(
osp.join(models_root, model['config'],
model['log_json_path'].rstrip('.json')),
osp.join(model_publish_dir, f'{model_name}.log'))
shutil.copy(model['latest_exp_json'],
osp.join(model_publish_dir, f'{model_name}.log.json'))

# copy config to guarantee reproducibility
config_path = model['config']
Expand Down
2 changes: 1 addition & 1 deletion .github/pull_request_template.md
Original file line number Diff line number Diff line change
Expand Up @@ -21,5 +21,5 @@ If this PR introduces a new feature, it is better to list some use cases here, a

1. Pre-commit or other linting tools are used to fix the potential lint issues.
2. The modification is covered by complete unit tests. If not, please add more unit test to ensure the correctness.
3. If the modification has potential influence on downstream projects, this PR should be tested with downstream projects, like MMDet or MMCls.
3. If the modification has potential influence on downstream projects, this PR should be tested with downstream projects, like MMDet or MMPreTrain.
4. The documentation has been modified accordingly, like docstring or example tutorials.
9 changes: 7 additions & 2 deletions .readthedocs.yml
Original file line number Diff line number Diff line change
@@ -1,9 +1,14 @@
version: 2

formats: all
build:
os: ubuntu-22.04
tools:
python: "3.8"

formats:
- epub

python:
version: 3.7
install:
- requirements: requirements/docs.txt
- requirements: requirements/readthedocs.txt
Loading

0 comments on commit f78af77

Please sign in to comment.