Skip to content

Commit

Permalink
Merge pull request #985 from openvinotoolkit/ik/move_mmdet_templates
Browse files Browse the repository at this point in the history
move mmdet templates
  • Loading branch information
Ilya-Krylov authored Mar 19, 2022
2 parents 4d1ae2d + 13a1bbe commit 5931ec7
Show file tree
Hide file tree
Showing 171 changed files with 17,119 additions and 16 deletions.
2 changes: 1 addition & 1 deletion .gitmodules
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
[submodule "external/mmdetection"]
path = external/mmdetection
path = external/mmdetection/submodule
url = ../../openvinotoolkit/mmdetection
[submodule "external/deep-object-reid"]
path = external/deep-object-reid/submodule
Expand Down
2 changes: 1 addition & 1 deletion .pylintrc
Original file line number Diff line number Diff line change
Expand Up @@ -267,7 +267,7 @@ ignored-classes=optparse.Values,thread._local,_thread._local
# (useful for modules/projects where namespaces are manipulated during runtime
# and thus existing member attributes cannot be deduced by static analysis). It
# supports qualified module names, as well as Unix pattern matching.
ignored-modules=ote_sdk,mmseg,segmentation_tasks,mmdet,torchreid,torchreid_tasks,cv2,anomalib,pytorch_lightning,torch,addict,compression,openvino,pandas
ignored-modules=ote_sdk,mmseg,segmentation_tasks,mmdet,detection_tasks,torchreid,torchreid_tasks,cv2,anomalib,pytorch_lightning,torch,addict,compression,openvino,pandas

# Show a hint with possible names when a member name was not found. The aspect
# of finding the hint is based on edit distance.
Expand Down
14 changes: 7 additions & 7 deletions external/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -25,21 +25,21 @@ Custom_Image_Classification_EfficientNet-V2-S | EfficientNet-V2-S | 5.76 | 20.23
## Object Detection
ID | Name | Complexity (GFlops) | Model size (MB) | Path
------- | ------- | ------- | ------- | -------
Custom_Object_Detection_YOLOX | YOLOX | 6.5 | 20.4 | mmdetection/configs/ote/custom-object-detection/cspdarknet_YOLOX/template.yaml
Custom_Object_Detection_Gen3_SSD | SSD | 9.4 | 7.6 | mmdetection/configs/ote/custom-object-detection/gen3_mobilenetV2_SSD/template.yaml
Custom_Object_Detection_Gen3_ATSS | ATSS | 20.6 | 9.1 | mmdetection/configs/ote/custom-object-detection/gen3_mobilenetV2_ATSS/template.yaml
Custom_Object_Detection_YOLOX | YOLOX | 6.5 | 20.4 | mmdetection/configs/custom-object-detection/cspdarknet_YOLOX/template.yaml
Custom_Object_Detection_Gen3_SSD | SSD | 9.4 | 7.6 | mmdetection/configs/custom-object-detection/gen3_mobilenetV2_SSD/template.yaml
Custom_Object_Detection_Gen3_ATSS | ATSS | 20.6 | 9.1 | mmdetection/configs/custom-object-detection/gen3_mobilenetV2_ATSS/template.yaml

## Object Counting
ID | Name | Complexity (GFlops) | Model size (MB) | Path
------- | ------- | ------- | ------- | -------
Custom_Counting_Instance_Segmentation_MaskRCNN_EfficientNetB2B | MaskRCNN-EfficientNetB2B | 68.48 | 13.27 | mmdetection/configs/ote/custom-counting-instance-seg/efficientnetb2b_maskrcnn/template.yaml
Custom_Counting_Instance_Segmentation_MaskRCNN_ResNet50 | MaskRCNN-ResNet50 | 533.8 | 177.9 | mmdetection/configs/ote/custom-counting-instance-seg/resnet50_maskrcnn/template.yaml
Custom_Counting_Instance_Segmentation_MaskRCNN_EfficientNetB2B | MaskRCNN-EfficientNetB2B | 68.48 | 13.27 | mmdetection/configs/custom-counting-instance-seg/efficientnetb2b_maskrcnn/template.yaml
Custom_Counting_Instance_Segmentation_MaskRCNN_ResNet50 | MaskRCNN-ResNet50 | 533.8 | 177.9 | mmdetection/configs/custom-counting-instance-seg/resnet50_maskrcnn/template.yaml

## Rotated Object Detection
ID | Name | Complexity (GFlops) | Model size (MB) | Path
------- | ------- | ------- | ------- | -------
Custom_Rotated_Detection_via_Instance_Segmentation_MaskRCNN_EfficientNetB2B | MaskRCNN-EfficientNetB2B | 68.48 | 13.27 | mmdetection/configs/ote/rotated_detection/efficientnetb2b_maskrcnn/template.yaml
Custom_Rotated_Detection_via_Instance_Segmentation_MaskRCNN_ResNet50 | MaskRCNN-ResNet50 | 533.8 | 177.9 | mmdetection/configs/ote/rotated_detection/resnet50_maskrcnn/template.yaml
Custom_Rotated_Detection_via_Instance_Segmentation_MaskRCNN_EfficientNetB2B | MaskRCNN-EfficientNetB2B | 68.48 | 13.27 | mmdetection/configs/rotated_detection/efficientnetb2b_maskrcnn/template.yaml
Custom_Rotated_Detection_via_Instance_Segmentation_MaskRCNN_ResNet50 | MaskRCNN-ResNet50 | 533.8 | 177.9 | mmdetection/configs/rotated_detection/resnet50_maskrcnn/template.yaml

## Semantic Segmentaion
ID | Name | Complexity (GFlops) | Model size (MB) | Path
Expand Down
1 change: 0 additions & 1 deletion external/mmdetection
Submodule mmdetection deleted from 6024bb
Original file line number Diff line number Diff line change
@@ -0,0 +1,57 @@
dataset_type = 'CocoDataset'
img_size = (1024, 1024)

img_norm_cfg = dict(
mean=(103.53, 116.28, 123.675), std=(1.0, 1.0, 1.0), to_rgb=False)

train_pipeline = [
dict(type='LoadImageFromFile'),
dict(type='LoadAnnotations', with_bbox=True,
with_mask=True, poly2mask=False),
dict(type='Resize', img_scale=img_size, keep_ratio=False),
dict(type='RandomFlip', flip_ratio=0.5),
dict(type='Normalize', **img_norm_cfg),
dict(type='Pad', size_divisor=32),
dict(type='DefaultFormatBundle'),
dict(type='Collect', keys=['img', 'gt_bboxes', 'gt_labels', 'gt_masks'])
]

test_pipeline = [
dict(type='LoadImageFromFile'),
dict(
type='MultiScaleFlipAug',
img_scale=img_size,
flip=False,
transforms=[
dict(type='Resize', keep_ratio=False),
dict(type='RandomFlip'),
dict(type='Normalize', **img_norm_cfg),
dict(type='Pad', size_divisor=32),
dict(type='ImageToTensor', keys=['img']),
dict(type='Collect', keys=['img'])
])
]

data = dict(samples_per_gpu=4,
workers_per_gpu=2,
train=dict(
type='RepeatDataset',
adaptive_repeat_times=True,
times=1,
dataset=dict(
type=dataset_type,
ann_file='data/coco/annotations/instances_train2017.json',
img_prefix='data/coco/train2017',
pipeline=train_pipeline)),
val=dict(
type=dataset_type,
test_mode=True,
ann_file='data/coco/annotations/instances_val2017.json',
img_prefix='data/coco/val2017',
pipeline=test_pipeline),
test=dict(
type=dataset_type,
test_mode=True,
ann_file='data/coco/annotations/instances_val2017.json',
img_prefix='data/coco/val2017',
pipeline=test_pipeline))
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
{
"base": {
"find_unused_parameters": true,
"nncf_config": {
"target_metric_name": "mAP",
"input_info": {
"sample_size": [1, 3, 1024, 1024]
},
"compression": [],
"log_dir": "."
}
},
"nncf_quantization": {
"optimizer": {
"lr": 0.0005
},
"nncf_config": {
"compression": [
{
"algorithm": "quantization",
"initializer": {
"range": {
"num_init_samples": 1000
},
"batchnorm_adaptation": {
"num_bn_adaptation_samples": 1000
}
}
}
],
"accuracy_aware_training": {
"mode": "early_exit",
"params": {
"maximal_absolute_accuracy_degradation": 0.01,
"maximal_total_epochs": 20
}
}
}
},
"order_of_parts": [
"nncf_quantization"
]
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
metric: mAP
search_algorithm: smbo
early_stop: None
hp_space:
learning_parameters.learning_rate:
param_type: quniform
range:
- 0.001
- 0.1
- 0.001
learning_parameters.batch_size:
param_type: qloguniform
range:
- 2
- 4
- 2
Original file line number Diff line number Diff line change
@@ -0,0 +1,160 @@
_base_ = [
'./coco_data_pipeline.py'
]

model = dict(
type='MaskRCNN',
backbone=dict(
type='efficientnet_b2b',
out_indices=(2, 3, 4, 5),
frozen_stages=-1,
pretrained=True,
activation_cfg=dict(type='torch_swish'),
norm_cfg=dict(type='BN', requires_grad=True)),
neck=dict(
type='FPN',
in_channels=[24, 48, 120, 352],
out_channels=80,
num_outs=5),
rpn_head=dict(
type='RPNHead',
in_channels=80,
feat_channels=80,
anchor_generator=dict(
type='AnchorGenerator',
scales=[8],
ratios=[0.5, 1.0, 2.0],
strides=[4, 8, 16, 32, 64]),
bbox_coder=dict(
type='DeltaXYWHBBoxCoder',
target_means=[0.0, 0.0, 0.0, 0.0],
target_stds=[1.0, 1.0, 1.0, 1.0]),
loss_cls=dict(
type='CrossEntropyLoss', use_sigmoid=True, loss_weight=1.0),
loss_bbox=dict(type='L1Loss', loss_weight=1.0)),
roi_head=dict(
type='StandardRoIHead',
bbox_roi_extractor=dict(
type='SingleRoIExtractor',
roi_layer=dict(type='RoIAlign', output_size=7, sampling_ratio=0),
out_channels=80,
featmap_strides=[4, 8, 16, 32]),
bbox_head=dict(
type='Shared2FCBBoxHead',
in_channels=80,
fc_out_channels=1024,
roi_feat_size=7,
num_classes=80,
bbox_coder=dict(
type='DeltaXYWHBBoxCoder',
target_means=[0.0, 0.0, 0.0, 0.0],
target_stds=[0.1, 0.1, 0.2, 0.2]),
reg_class_agnostic=False,
loss_cls=dict(
type='CrossEntropyLoss', use_sigmoid=False, loss_weight=1.0),
loss_bbox=dict(type='L1Loss', loss_weight=1.0)),
mask_roi_extractor=dict(
type='SingleRoIExtractor',
roi_layer=dict(type='RoIAlign', output_size=14, sampling_ratio=0),
out_channels=80,
featmap_strides=[4, 8, 16, 32]),
mask_head=dict(
type='FCNMaskHead',
num_convs=4,
in_channels=80,
conv_out_channels=80,
num_classes=80,
loss_mask=dict(
type='CrossEntropyLoss', use_mask=True, loss_weight=1.0))),
train_cfg=dict(
rpn=dict(
assigner=dict(
type='MaxIoUAssigner',
pos_iou_thr=0.7,
neg_iou_thr=0.3,
min_pos_iou=0.3,
match_low_quality=True,
ignore_iof_thr=-1,
gpu_assign_thr=300),
sampler=dict(
type='RandomSampler',
num=256,
pos_fraction=0.5,
neg_pos_ub=-1,
add_gt_as_proposals=False),
allowed_border=-1,
pos_weight=-1,
debug=False),
rpn_proposal=dict(
nms_across_levels=False,
nms_pre=2000,
nms_post=1000,
max_num=1000,
nms_thr=0.8,
min_bbox_size=0),
rcnn=dict(
assigner=dict(
type='MaxIoUAssigner',
pos_iou_thr=0.5,
neg_iou_thr=0.5,
min_pos_iou=0.5,
match_low_quality=True,
ignore_iof_thr=-1,
gpu_assign_thr=300),
sampler=dict(
type='RandomSampler',
num=256,
pos_fraction=0.25,
neg_pos_ub=-1,
add_gt_as_proposals=True),
mask_size=28,
pos_weight=-1,
debug=False)),
test_cfg=dict(
rpn=dict(
nms_across_levels=False,
nms_pre=800,
nms_post=500,
max_num=500,
nms_thr=0.8,
min_bbox_size=0),
rcnn=dict(
score_thr=0.05,
nms=dict(type='nms', iou_threshold=0.7),
max_per_img=500,
mask_thr_binary=0.5)))

cudnn_benchmark = True
evaluation = dict(interval=1, metric='mAP', save_best='mAP', iou_thr=[0.5 , 0.55, 0.6 , 0.65, 0.7 , 0.75, 0.8 , 0.85, 0.9, 0.95])
optimizer = dict(type='SGD', lr=0.015, momentum=0.9, weight_decay=0.0001)
optimizer_config = dict(grad_clip=None)
lr_config = dict(
policy='ReduceLROnPlateau',
metric='mAP',
patience=5,
iteration_patience=300,
interval=1,
min_lr=0.000001,
warmup='linear',
warmup_iters=200,
warmup_ratio=0.3333333333333333
)
runner = dict(type='EpochRunnerWithCancel', max_epochs=300)
checkpoint_config = dict(interval=5)
log_config = dict(
interval=1,
hooks=[
dict(type='TextLoggerHook'),
# dict(type='TensorboardLoggerHook'),
])
dist_params = dict(backend='nccl')
log_level = 'INFO'
load_from = 'https://storage.openvinotoolkit.org/repositories/openvino_training_extensions/models/instance_segmentation/v2/efficientnet_b2b-mask_rcnn-576x576.pth'
resume_from = None
workflow = [('train', 1)]
work_dir = 'output'
custom_hooks = [
dict(type='EarlyStoppingHook', patience=10, metric='mAP',
interval=1, priority=75, iteration_patience=0),
]
fp16 = dict(loss_scale=512.)
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
# Description.
model_template_id: Custom_Counting_Instance_Segmentation_MaskRCNN_EfficientNetB2B
name: MaskRCNN-EfficientNetB2B
task_type: INSTANCE_SEGMENTATION
task_family: VISION
instantiation: "CLASS"
summary: Counting algorithm provides counting of objects and object instance masks. This model is based on MaskRCNN-EfficientNetB2B which is faster in training and inference but less accurate.
application: ~

# Algo backend.
framework: OTEDetection v2.9.1

# Task implementations.
entrypoints:
base: detection_tasks.apis.detection.OTEDetectionTrainingTask
openvino: detection_tasks.apis.detection.OpenVINODetectionTask
nncf: detection_tasks.apis.detection.OTEDetectionNNCFTask

# Capabilities.
capabilities:
- compute_representations

# Hyperparameters.
hyper_parameters:
base_path: ../../../../mmdetection/detection_tasks/apis/detection/configuration.yaml
parameter_overrides:
learning_parameters:
batch_size:
default_value: 4
learning_rate:
default_value: 0.015
learning_rate_warmup_iters:
default_value: 200
num_iters:
default_value: 300
nncf_optimization:
enable_quantization:
default_value: true
enable_pruning:
default_value: false
maximal_accuracy_degradation:
default_value: 1.0

# Training resources.
max_nodes: 1
training_targets:
- GPU
- CPU

# Stats.
gigaflops: 68.48
size: 13.27
Loading

0 comments on commit 5931ec7

Please sign in to comment.