Skip to content

Commit 3a512dc

Browse files
authored
Add ResNeXt101-ATSS as a Experimental model (#2309)
* Add ResNeXt101-ATSS * Change atss name to mobilenetv2-atss * Change to experimental yaml * Revert mobilnet atss template changes * Update CHANGELOG.md * Add pretrained weights url * Update resnext101_atss stats * Fix model_api issue * Fix wrong import in unit tests
1 parent de75276 commit 3a512dc

File tree

19 files changed

+760
-12
lines changed

19 files changed

+760
-12
lines changed

CHANGELOG.md

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,8 +11,9 @@ All notable changes to this project will be documented in this file.
1111
- Auto train type detection for Semi-SL, Self-SL and Incremental: "--train-type" now is optional (https://github.com/openvinotoolkit/training_extensions/pull/2195)
1212
- Add per-class XAI saliency maps for Mask R-CNN model (https://github.com/openvinotoolkit/training_extensions/pull/2227)
1313
- Add new object detector Deformable DETR (<https://github.com/openvinotoolkit/training_extensions/pull/2249>)
14-
- Add new object detecotr DINO(<https://github.com/openvinotoolkit/training_extensions/pull/2266>)
14+
- Add new object detector DINO(<https://github.com/openvinotoolkit/training_extensions/pull/2266>)
1515
- Add new visual prompting task (https://github.com/openvinotoolkit/training_extensions/pull/2203), (https://github.com/openvinotoolkit/training_extensions/pull/2274)
16+
- Add new object detector ResNeXt101-ATSS (<https://github.com/openvinotoolkit/training_extensions/pull/2309>)
1617

1718
### Enhancements
1819

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
"""Initialization of ResNeXt101-ATSS model for Detection Task."""
2+
3+
# Copyright (C) 2023 Intel Corporation
4+
# SPDX-License-Identifier: Apache-2.0
Lines changed: 74 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,74 @@
1+
{
2+
"base": {
3+
"find_unused_parameters": true,
4+
"nncf_config": {
5+
"target_metric_name": "mAP",
6+
"input_info": {
7+
"sample_size": [1, 3, 992, 736]
8+
},
9+
"compression": [],
10+
"log_dir": "/tmp"
11+
}
12+
},
13+
"nncf_quantization": {
14+
"optimizer": {
15+
"lr": 0.0005
16+
},
17+
"nncf_config": {
18+
"compression": [
19+
{
20+
"algorithm": "quantization",
21+
"initializer": {
22+
"range": {
23+
"num_init_samples": 300
24+
},
25+
"batchnorm_adaptation": {
26+
"num_bn_adaptation_samples": 300
27+
}
28+
}
29+
}
30+
],
31+
"accuracy_aware_training": {
32+
"mode": "early_exit",
33+
"params": {
34+
"maximal_absolute_accuracy_degradation": 0.01,
35+
"maximal_total_epochs": 20
36+
}
37+
}
38+
}
39+
},
40+
"nncf_quantization_pruning": {
41+
"nncf_config": {
42+
"accuracy_aware_training": {
43+
"mode": "adaptive_compression_level",
44+
"params": {
45+
"initial_training_phase_epochs": 5,
46+
"maximal_total_epochs": 100,
47+
"patience_epochs": 5
48+
}
49+
},
50+
"compression": [
51+
{
52+
"algorithm": "filter_pruning",
53+
"params": {
54+
"schedule": "baseline",
55+
"pruning_flops_target": 0.1,
56+
"filter_importance": "geometric_median"
57+
}
58+
},
59+
{
60+
"algorithm": "quantization",
61+
"initializer": {
62+
"range": {
63+
"num_init_samples": 300
64+
},
65+
"batchnorm_adaptation": {
66+
"num_bn_adaptation_samples": 300
67+
}
68+
}
69+
}
70+
]
71+
}
72+
},
73+
"order_of_parts": ["nncf_quantization", "nncf_quantization_pruning"]
74+
}
Lines changed: 72 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,72 @@
1+
"""Data Pipeline of ResNeXt101-ATSS model for Detection Task."""
2+
3+
# Copyright (C) 2023 Intel Corporation
4+
# SPDX-License-Identifier: Apache-2.0
5+
6+
# pylint: disable=invalid-name
7+
8+
__img_size = (992, 736)
9+
__img_norm_cfg = dict(mean=[0, 0, 0], std=[255, 255, 255], to_rgb=True)
10+
11+
train_pipeline = [
12+
dict(type="LoadImageFromFile"),
13+
dict(type="LoadAnnotations", with_bbox=True),
14+
dict(type="MinIoURandomCrop", min_ious=(0.1, 0.3, 0.5, 0.7, 0.9), min_crop_size=0.3),
15+
dict(
16+
type="Resize",
17+
img_scale=[(992, 736), (896, 736), (1088, 736), (992, 672), (992, 800)],
18+
multiscale_mode="value",
19+
keep_ratio=False,
20+
),
21+
dict(type="RandomFlip", flip_ratio=0.5),
22+
dict(type="Normalize", **__img_norm_cfg),
23+
dict(type="DefaultFormatBundle"),
24+
dict(type="Collect", keys=["img", "gt_bboxes", "gt_labels"]),
25+
]
26+
test_pipeline = [
27+
dict(type="LoadImageFromFile"),
28+
dict(
29+
type="MultiScaleFlipAug",
30+
img_scale=__img_size,
31+
flip=False,
32+
transforms=[
33+
dict(type="Resize", keep_ratio=False),
34+
dict(type="RandomFlip"),
35+
dict(type="Normalize", **__img_norm_cfg),
36+
dict(type="ImageToTensor", keys=["img"]),
37+
dict(type="Collect", keys=["img"]),
38+
],
39+
),
40+
]
41+
42+
43+
__dataset_type = "CocoDataset"
44+
__data_root = "data/coco/"
45+
46+
47+
__samples_per_gpu = 2
48+
49+
data = dict(
50+
samples_per_gpu=__samples_per_gpu,
51+
workers_per_gpu=2,
52+
train=dict(
53+
type=__dataset_type,
54+
ann_file=__data_root + "annotations/instances_train2017.json",
55+
img_prefix=__data_root + "train2017/",
56+
pipeline=train_pipeline,
57+
),
58+
val=dict(
59+
type=__dataset_type,
60+
ann_file=__data_root + "annotations/instances_val2017.json",
61+
img_prefix=__data_root + "val2017/",
62+
test_mode=True,
63+
pipeline=test_pipeline,
64+
),
65+
test=dict(
66+
type=__dataset_type,
67+
ann_file=__data_root + "annotations/instances_val2017.json",
68+
img_prefix=__data_root + "val2017/",
69+
test_mode=True,
70+
pipeline=test_pipeline,
71+
),
72+
)
Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
"""MMDeploy config of ResNeXt101-ATSS model for Detection Task."""
2+
3+
# Copyright (C) 2023 Intel Corporation
4+
# SPDX-License-Identifier: Apache-2.0
5+
6+
_base_ = ["../../base/deployments/base_detection_dynamic.py"]
7+
8+
ir_config = dict(
9+
output_names=["boxes", "labels"],
10+
)
11+
12+
backend_config = dict(
13+
model_inputs=[dict(opt_shapes=dict(input=[-1, 3, 736, 992]))],
14+
)
Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
metric: mAP
2+
search_algorithm: asha
3+
early_stop: None
4+
hp_space:
5+
learning_parameters.learning_rate:
6+
param_type: qloguniform
7+
range:
8+
- 0.0004
9+
- 0.04
10+
- 0.0001
11+
learning_parameters.batch_size:
12+
param_type: qloguniform
13+
range:
14+
- 4
15+
- 16
16+
- 2
Lines changed: 83 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,83 @@
1+
"""Model configuration of ResNeXt101-ATSS model for Detection Task."""
2+
3+
# Copyright (C) 2023 Intel Corporation
4+
# SPDX-License-Identifier: Apache-2.0
5+
6+
# pylint: disable=invalid-name
7+
8+
_base_ = [
9+
"../../../../../recipes/stages/detection/incremental.py",
10+
"../../base/models/detector.py",
11+
]
12+
13+
model = dict(
14+
type="CustomATSS",
15+
backbone=dict(
16+
type="ResNeXt",
17+
depth=101,
18+
groups=64,
19+
base_width=4,
20+
num_stages=4,
21+
out_indices=(0, 1, 2, 3),
22+
frozen_stages=1,
23+
norm_cfg=dict(type="BN", requires_grad=True),
24+
style="pytorch",
25+
init_cfg=dict(type="Pretrained", checkpoint="open-mmlab://resnext101_64x4d"),
26+
),
27+
neck=dict(
28+
type="FPN",
29+
in_channels=[256, 512, 1024, 2048],
30+
out_channels=256,
31+
start_level=1,
32+
add_extra_convs="on_output",
33+
num_outs=5,
34+
relu_before_extra_convs=True,
35+
),
36+
bbox_head=dict(
37+
type="CustomATSSHead",
38+
num_classes=2,
39+
in_channels=256,
40+
stacked_convs=4,
41+
feat_channels=256,
42+
anchor_generator=dict(
43+
type="AnchorGenerator",
44+
ratios=[1.0],
45+
octave_base_scale=8,
46+
scales_per_octave=1,
47+
strides=[8, 16, 32, 64, 128],
48+
),
49+
bbox_coder=dict(
50+
type="DeltaXYWHBBoxCoder",
51+
target_means=[0.0, 0.0, 0.0, 0.0],
52+
target_stds=[0.1, 0.1, 0.2, 0.2],
53+
),
54+
loss_cls=dict(type="FocalLoss", use_sigmoid=True, gamma=2.0, alpha=0.25, loss_weight=1.0),
55+
loss_bbox=dict(type="GIoULoss", loss_weight=2.0),
56+
loss_centerness=dict(type="CrossEntropyLoss", use_sigmoid=True, loss_weight=1.0),
57+
use_qfl=False,
58+
qfl_cfg=dict(
59+
type="QualityFocalLoss",
60+
use_sigmoid=True,
61+
beta=2.0,
62+
loss_weight=1.0,
63+
),
64+
),
65+
train_cfg=dict(
66+
assigner=dict(type="ATSSAssigner", topk=9),
67+
allowed_border=-1,
68+
pos_weight=-1,
69+
debug=False,
70+
),
71+
test_cfg=dict(
72+
nms_pre=1000,
73+
min_bbox_size=0,
74+
score_thr=0.05,
75+
nms=dict(type="nms", iou_threshold=0.6),
76+
max_per_img=100,
77+
),
78+
)
79+
80+
load_from = "https://storage.openvinotoolkit.org/repositories/openvino_training_extensions/\
81+
models/object_detection/v2/resnext101_atss_070623.pth"
82+
83+
fp16 = dict(loss_scale=512.0)
Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
"""Initialization of ResNeXt101-ATSS model for Semi-SL Detection Task."""
2+
3+
# Copyright (C) 2023 Intel Corporation
4+
# SPDX-License-Identifier: Apache-2.0
Lines changed: 74 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,74 @@
1+
{
2+
"base": {
3+
"find_unused_parameters": true,
4+
"nncf_config": {
5+
"target_metric_name": "mAP",
6+
"input_info": {
7+
"sample_size": [1, 3, 992, 736]
8+
},
9+
"compression": [],
10+
"log_dir": "/tmp"
11+
}
12+
},
13+
"nncf_quantization": {
14+
"optimizer": {
15+
"lr": 0.0005
16+
},
17+
"nncf_config": {
18+
"compression": [
19+
{
20+
"algorithm": "quantization",
21+
"initializer": {
22+
"range": {
23+
"num_init_samples": 300
24+
},
25+
"batchnorm_adaptation": {
26+
"num_bn_adaptation_samples": 300
27+
}
28+
}
29+
}
30+
],
31+
"accuracy_aware_training": {
32+
"mode": "early_exit",
33+
"params": {
34+
"maximal_absolute_accuracy_degradation": 0.01,
35+
"maximal_total_epochs": 20
36+
}
37+
}
38+
}
39+
},
40+
"nncf_quantization_pruning": {
41+
"nncf_config": {
42+
"accuracy_aware_training": {
43+
"mode": "adaptive_compression_level",
44+
"params": {
45+
"initial_training_phase_epochs": 5,
46+
"maximal_total_epochs": 100,
47+
"patience_epochs": 5
48+
}
49+
},
50+
"compression": [
51+
{
52+
"algorithm": "filter_pruning",
53+
"params": {
54+
"schedule": "baseline",
55+
"pruning_flops_target": 0.1,
56+
"filter_importance": "geometric_median"
57+
}
58+
},
59+
{
60+
"algorithm": "quantization",
61+
"initializer": {
62+
"range": {
63+
"num_init_samples": 300
64+
},
65+
"batchnorm_adaptation": {
66+
"num_bn_adaptation_samples": 300
67+
}
68+
}
69+
}
70+
]
71+
}
72+
},
73+
"order_of_parts": ["nncf_quantization", "nncf_quantization_pruning"]
74+
}

0 commit comments

Comments
 (0)