Skip to content

Commit

Permalink
Merge branch 'dev'
Browse files Browse the repository at this point in the history
  • Loading branch information
mzr1996 committed Jan 31, 2022
2 parents 25f5cc7 + fb6d6f1 commit e0edffb
Show file tree
Hide file tree
Showing 167 changed files with 7,472 additions and 514 deletions.
28 changes: 16 additions & 12 deletions .dev_scripts/benchmark_regression/1-benchmark_valid.py
Original file line number Diff line number Diff line change
Expand Up @@ -128,18 +128,19 @@ def inference(config_file, checkpoint, classes, args):

if args.flops:
from mmcv.cnn.utils import get_model_complexity_info
if hasattr(model, 'extract_feat'):
model.forward = model.extract_feat
flops, params = get_model_complexity_info(
model,
input_shape=(3, ) + resolution,
print_per_layer_stat=False,
as_strings=args.flops_str)
result['flops'] = flops if args.flops_str else int(flops)
result['params'] = params if args.flops_str else int(params)
else:
result['flops'] = ''
result['params'] = ''
with torch.no_grad():
if hasattr(model, 'extract_feat'):
model.forward = model.extract_feat
flops, params = get_model_complexity_info(
model,
input_shape=(3, ) + resolution,
print_per_layer_stat=False,
as_strings=args.flops_str)
result['flops'] = flops if args.flops_str else int(flops)
result['params'] = params if args.flops_str else int(params)
else:
result['flops'] = ''
result['params'] = ''

return result

Expand Down Expand Up @@ -199,6 +200,9 @@ def main(args):
summary_data = {}
for model_name, model_info in models.items():

if model_info.config is None:
continue

config = Path(model_info.config)
assert config.exists(), f'{model_name}: {config} not found.'

Expand Down
7 changes: 7 additions & 0 deletions .dev_scripts/benchmark_regression/2-benchmark_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -163,6 +163,10 @@ def test(args):

preview_script = ''
for model_info in models.values():

if model_info.results is None:
continue

script_path = create_test_job_batch(commands, model_info, args, port,
script_name)
preview_script = script_path or preview_script
Expand Down Expand Up @@ -288,6 +292,9 @@ def summary(args):
summary_data = {}
for model_name, model_info in models.items():

if model_info.results is None:
continue

# Skip if not found result file.
result_file = work_dir / model_name / 'result.pkl'
if not result_file.exists():
Expand Down
6 changes: 2 additions & 4 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,9 +9,8 @@ on:
- 'README.md'
- 'README_zh-CN.md'
- 'model-index.yml'
- 'configs/**.md'
- 'configs/**'
- 'docs/**'
- 'docs_zh-CN/**'
- 'demo/**'
- '.dev_scripts/**'

Expand All @@ -20,9 +19,8 @@ on:
- 'README.md'
- 'README_zh-CN.md'
- 'model-index.yml'
- 'configs/**.md'
- 'configs/**'
- 'docs/**'
- 'docs_zh-CN/**'
- 'demo/**'
- '.dev_scripts/**'

Expand Down
20 changes: 11 additions & 9 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,13 @@ The master branch works with **PyTorch 1.5+**.

## What's new

v0.20.0 was released in 30/1/2022.

Highlights of the new version:
- Support **K-fold cross-validation**. The tutorial will be released later.
- Support **HRNet**, **ConvNeXt**, **Twins** and **EfficientNet**.
- Support model conversion from PyTorch to **Core ML** by a tool.

v0.19.0 was released in 31/12/2021.

Highlights of the new version:
Expand All @@ -68,12 +75,6 @@ Highlights of the new version:
- Support **DeiT** & **Conformer** backbone and checkpoints.
- Provide a **CAM visualization** tool based on [pytorch-grad-cam](https://github.com/jacobgil/pytorch-grad-cam), and detailed [user guide](https://mmclassification.readthedocs.io/en/latest/tools/visualization.html#class-activation-map-visualization)!

v0.18.0 was released in 30/11/2021.

Highlights of the new version:
- Support **MLP-Mixer** backbone and provide pre-trained checkpoints.
- Add a tool to **visualize the learning rate curve** of the training phase. Welcome to use with the [tutorial](https://mmclassification.readthedocs.io/en/latest/tools/visualization.html#learning-rate-schedule-visualization)!

Please refer to [changelog.md](docs/en/changelog.md) for more details and other release history.

## Installation
Expand Down Expand Up @@ -123,9 +124,10 @@ Results and models are available in the [model zoo](https://mmclassification.rea
- [x] [DeiT](https://github.com/open-mmlab/mmclassification/tree/master/configs/deit)
- [x] [Conformer](https://github.com/open-mmlab/mmclassification/tree/master/configs/conformer)
- [x] [T2T-ViT](https://github.com/open-mmlab/mmclassification/tree/master/configs/t2t_vit)
- [ ] EfficientNet
- [ ] Twins
- [ ] HRNet
- [x] [Twins](https://github.com/open-mmlab/mmclassification/tree/master/configs/twins)
- [x] [EfficientNet](https://github.com/open-mmlab/mmclassification/tree/master/configs/efficientnet)
- [x] [ConvNeXt](https://github.com/open-mmlab/mmclassification/tree/master/configs/convnext)
- [x] [HRNet](https://github.com/open-mmlab/mmclassification/tree/master/configs/hrnet)

</details>

Expand Down
20 changes: 11 additions & 9 deletions README_zh-CN.md
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,13 @@ MMClassification 是一款基于 PyTorch 的开源图像分类工具箱,是 [O

## 更新日志

2022/1/30 发布了 v0.20.0 版本

新版本亮点:
- 支持 **K 折交叉验证** 工具。相应文档会在后续添加。
- 支持了 **HRNet****ConvNeXt****Twins** 以及 **EfficientNet** 四个主干网络,欢迎使用!
- 支持了从 PyTorch 模型到 Core-ML 模型的转换工具。

2021/12/31 发布了 v0.19.0 版本

新版本亮点:
Expand All @@ -66,12 +73,6 @@ MMClassification 是一款基于 PyTorch 的开源图像分类工具箱,是 [O
- 支持了 **DeiT****Conformer** 主干网络,并提供了预训练模型。
- 提供了一个 **CAM 可视化** 工具。该工具基于 [pytorch-grad-cam](https://github.com/jacobgil/pytorch-grad-cam),我们提供了详细的 [使用教程](https://mmclassification.readthedocs.io/en/latest/tools/visualization.html#class-activation-map-visualization)

2021/11/30 发布了 v0.18.0 版本

新版本亮点:
- 支持了 **MLP-Mixer** 主干网络,欢迎使用!
- 添加了一个**可视化学习率曲线**的工具,可以参考[教程](https://mmclassification.readthedocs.io/zh_CN/latest/tools/visualization.html#id3)使用

发布历史和更新细节请参考 [更新日志](docs/en/changelog.md)

## 安装
Expand Down Expand Up @@ -121,9 +122,10 @@ MMClassification 是一款基于 PyTorch 的开源图像分类工具箱,是 [O
- [x] [DeiT](https://github.com/open-mmlab/mmclassification/tree/master/configs/deit)
- [x] [Conformer](https://github.com/open-mmlab/mmclassification/tree/master/configs/conformer)
- [x] [T2T-ViT](https://github.com/open-mmlab/mmclassification/tree/master/configs/t2t_vit)
- [ ] EfficientNet
- [ ] Twins
- [ ] HRNet
- [x] [Twins](https://github.com/open-mmlab/mmclassification/tree/master/configs/twins)
- [x] [EfficientNet](https://github.com/open-mmlab/mmclassification/tree/master/configs/efficientnet)
- [x] [ConvNeXt](https://github.com/open-mmlab/mmclassification/tree/master/configs/convnext)
- [x] [HRNet](https://github.com/open-mmlab/mmclassification/tree/master/configs/hrnet)

</details>

Expand Down
23 changes: 23 additions & 0 deletions configs/_base_/models/convnext/convnext-base.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
# Model settings
model = dict(
type='ImageClassifier',
backbone=dict(
type='ConvNeXt',
arch='base',
out_indices=(3, ),
drop_path_rate=0.5,
gap_before_final_norm=True,
init_cfg=[
dict(
type='TruncNormal',
layer=['Conv2d', 'Linear'],
std=.02,
bias=0.),
dict(type='Constant', layer=['LayerNorm'], val=1., bias=0.),
]),
head=dict(
type='LinearClsHead',
num_classes=1000,
in_channels=1024,
loss=dict(type='CrossEntropyLoss', loss_weight=1.0),
))
23 changes: 23 additions & 0 deletions configs/_base_/models/convnext/convnext-large.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
# Model settings
model = dict(
type='ImageClassifier',
backbone=dict(
type='ConvNeXt',
arch='large',
out_indices=(3, ),
drop_path_rate=0.5,
gap_before_final_norm=True,
init_cfg=[
dict(
type='TruncNormal',
layer=['Conv2d', 'Linear'],
std=.02,
bias=0.),
dict(type='Constant', layer=['LayerNorm'], val=1., bias=0.),
]),
head=dict(
type='LinearClsHead',
num_classes=1000,
in_channels=1536,
loss=dict(type='CrossEntropyLoss', loss_weight=1.0),
))
23 changes: 23 additions & 0 deletions configs/_base_/models/convnext/convnext-small.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
# Model settings
model = dict(
type='ImageClassifier',
backbone=dict(
type='ConvNeXt',
arch='small',
out_indices=(3, ),
drop_path_rate=0.4,
gap_before_final_norm=True,
init_cfg=[
dict(
type='TruncNormal',
layer=['Conv2d', 'Linear'],
std=.02,
bias=0.),
dict(type='Constant', layer=['LayerNorm'], val=1., bias=0.),
]),
head=dict(
type='LinearClsHead',
num_classes=1000,
in_channels=768,
loss=dict(type='CrossEntropyLoss', loss_weight=1.0),
))
23 changes: 23 additions & 0 deletions configs/_base_/models/convnext/convnext-tiny.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
# Model settings
model = dict(
type='ImageClassifier',
backbone=dict(
type='ConvNeXt',
arch='tiny',
out_indices=(3, ),
drop_path_rate=0.1,
gap_before_final_norm=True,
init_cfg=[
dict(
type='TruncNormal',
layer=['Conv2d', 'Linear'],
std=.02,
bias=0.),
dict(type='Constant', layer=['LayerNorm'], val=1., bias=0.),
]),
head=dict(
type='LinearClsHead',
num_classes=1000,
in_channels=768,
loss=dict(type='CrossEntropyLoss', loss_weight=1.0),
))
23 changes: 23 additions & 0 deletions configs/_base_/models/convnext/convnext-xlarge.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
# Model settings
model = dict(
type='ImageClassifier',
backbone=dict(
type='ConvNeXt',
arch='xlarge',
out_indices=(3, ),
drop_path_rate=0.5,
gap_before_final_norm=True,
init_cfg=[
dict(
type='TruncNormal',
layer=['Conv2d', 'Linear'],
std=.02,
bias=0.),
dict(type='Constant', layer=['LayerNorm'], val=1., bias=0.),
]),
head=dict(
type='LinearClsHead',
num_classes=1000,
in_channels=2048,
loss=dict(type='CrossEntropyLoss', loss_weight=1.0),
))
12 changes: 12 additions & 0 deletions configs/_base_/models/efficientnet_b0.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
# model settings
model = dict(
type='ImageClassifier',
backbone=dict(type='EfficientNet', arch='b0'),
neck=dict(type='GlobalAveragePooling'),
head=dict(
type='LinearClsHead',
num_classes=1000,
in_channels=1280,
loss=dict(type='CrossEntropyLoss', loss_weight=1.0),
topk=(1, 5),
))
12 changes: 12 additions & 0 deletions configs/_base_/models/efficientnet_b1.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
# model settings
model = dict(
type='ImageClassifier',
backbone=dict(type='EfficientNet', arch='b1'),
neck=dict(type='GlobalAveragePooling'),
head=dict(
type='LinearClsHead',
num_classes=1000,
in_channels=1280,
loss=dict(type='CrossEntropyLoss', loss_weight=1.0),
topk=(1, 5),
))
12 changes: 12 additions & 0 deletions configs/_base_/models/efficientnet_b2.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
# model settings
model = dict(
type='ImageClassifier',
backbone=dict(type='EfficientNet', arch='b2'),
neck=dict(type='GlobalAveragePooling'),
head=dict(
type='LinearClsHead',
num_classes=1000,
in_channels=1408,
loss=dict(type='CrossEntropyLoss', loss_weight=1.0),
topk=(1, 5),
))
12 changes: 12 additions & 0 deletions configs/_base_/models/efficientnet_b3.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
# model settings
model = dict(
type='ImageClassifier',
backbone=dict(type='EfficientNet', arch='b3'),
neck=dict(type='GlobalAveragePooling'),
head=dict(
type='LinearClsHead',
num_classes=1000,
in_channels=1536,
loss=dict(type='CrossEntropyLoss', loss_weight=1.0),
topk=(1, 5),
))
12 changes: 12 additions & 0 deletions configs/_base_/models/efficientnet_b4.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
# model settings
model = dict(
type='ImageClassifier',
backbone=dict(type='EfficientNet', arch='b4'),
neck=dict(type='GlobalAveragePooling'),
head=dict(
type='LinearClsHead',
num_classes=1000,
in_channels=1792,
loss=dict(type='CrossEntropyLoss', loss_weight=1.0),
topk=(1, 5),
))
12 changes: 12 additions & 0 deletions configs/_base_/models/efficientnet_b5.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
# model settings
model = dict(
type='ImageClassifier',
backbone=dict(type='EfficientNet', arch='b5'),
neck=dict(type='GlobalAveragePooling'),
head=dict(
type='LinearClsHead',
num_classes=1000,
in_channels=2048,
loss=dict(type='CrossEntropyLoss', loss_weight=1.0),
topk=(1, 5),
))
12 changes: 12 additions & 0 deletions configs/_base_/models/efficientnet_b6.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
# model settings
model = dict(
type='ImageClassifier',
backbone=dict(type='EfficientNet', arch='b6'),
neck=dict(type='GlobalAveragePooling'),
head=dict(
type='LinearClsHead',
num_classes=1000,
in_channels=2304,
loss=dict(type='CrossEntropyLoss', loss_weight=1.0),
topk=(1, 5),
))
12 changes: 12 additions & 0 deletions configs/_base_/models/efficientnet_b7.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
# model settings
model = dict(
type='ImageClassifier',
backbone=dict(type='EfficientNet', arch='b7'),
neck=dict(type='GlobalAveragePooling'),
head=dict(
type='LinearClsHead',
num_classes=1000,
in_channels=2560,
loss=dict(type='CrossEntropyLoss', loss_weight=1.0),
topk=(1, 5),
))
Loading

0 comments on commit e0edffb

Please sign in to comment.