-
Notifications
You must be signed in to change notification settings - Fork 62
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
54 changed files
with
1,325 additions
and
252 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
#!/usr/bin/env bash | ||
|
||
set -x | ||
|
||
CFG=$1 | ||
PRETRAIN=$2 # pretrained model | ||
GPUS=$3 | ||
PY_ARGS=${@:4} | ||
|
||
# set work_dir according to config path and pretrained model to distinguish different models | ||
WORK_DIR="$(echo ${CFG%.*} | sed -e "s/configs/work_dirs/g")/$(echo $PRETRAIN | rev | cut -d/ -f 1 | rev)" | ||
|
||
PYTHONPATH="$(dirname $0)/..":$PYTHONPATH \ | ||
mim train mmdet $CFG \ | ||
--launcher pytorch -G $GPUS \ | ||
--work-dir $WORK_DIR \ | ||
--cfg-options model.backbone.init_cfg.type=Pretrained \ | ||
model.backbone.init_cfg.checkpoint=$PRETRAIN \ | ||
model.backbone.init_cfg.prefix="backbone." \ | ||
$PY_ARGS |
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
#!/usr/bin/env bash | ||
|
||
set -x | ||
|
||
CFG=$1 | ||
PRETRAIN=$2 # pretrained model | ||
GPUS=$3 | ||
PY_ARGS=${@:4} | ||
|
||
# set work_dir according to config path and pretrained model to distinguish different models | ||
WORK_DIR="$(echo ${CFG%.*} | sed -e "s/configs/work_dirs/g")/$(echo $PRETRAIN | rev | cut -d/ -f 1 | rev)" | ||
|
||
PYTHONPATH="$(dirname $0)/..":$PYTHONPATH \ | ||
mim train mmseg $CFG \ | ||
--launcher pytorch -G $GPUS \ | ||
--work-dir $WORK_DIR \ | ||
--cfg-options model.backbone.init_cfg.type=Pretrained \ | ||
model.backbone.init_cfg.checkpoint=$PRETRAIN \ | ||
model.backbone.init_cfg.prefix="backbone." \ | ||
$PY_ARGS |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
23 changes: 23 additions & 0 deletions
23
configs/benchmarks/classification/_base_/models/vit_huge_p14.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
# model settings | ||
model = dict( | ||
type='MixUpClassification', | ||
pretrained=None, | ||
alpha=[0.8, 1.0,], # deit setting | ||
mix_mode=["mixup", "cutmix",], | ||
mix_args=dict(), | ||
backbone=dict( | ||
type='MIMVisionTransformer', | ||
arch='huge', | ||
img_size=224, | ||
patch_size=14, | ||
drop_path_rate=0.3, | ||
final_norm=False, | ||
finetune=True, | ||
), | ||
head=dict( | ||
type='ClsMixupHead', # mixup CE + label smooth | ||
loss=dict(type='LabelSmoothLoss', | ||
label_smooth_val=0.1, num_classes=1000, mode='original', loss_weight=1.0), | ||
with_avg_pool=False, # no gap in ViT | ||
in_channels=1280, num_classes=1000), | ||
) |
48 changes: 48 additions & 0 deletions
48
configs/benchmarks/classification/imagenet/vit_huge_p14_swin_ft_mae_sz224_8xb128_cos_ep50.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,48 @@ | ||
_base_ = [ | ||
'../_base_/models/vit_huge_p14.py', | ||
'../_base_/datasets/imagenet_swin_ft_sz224_8xbs128.py', | ||
'../_base_/default_runtime.py', | ||
] | ||
|
||
# data | ||
data = dict(imgs_per_gpu=128, workers_per_gpu=8) | ||
|
||
# interval for accumulate gradient | ||
update_interval = 1 # total: 8 x bs128 x 1 accumulates = bs1024 | ||
|
||
# optimizer | ||
optimizer = dict( | ||
type='AdamW', | ||
lr=2e-3, | ||
weight_decay=0.05, eps=1e-8, betas=(0.9, 0.999), | ||
paramwise_options={ | ||
'(bn|ln|gn)(\d+)?.(weight|bias)': dict(weight_decay=0.), | ||
'norm': dict(weight_decay=0.), | ||
'bias': dict(weight_decay=0.), | ||
'cls_token': dict(weight_decay=0.), | ||
'pos_embed': dict(weight_decay=0.), | ||
}, | ||
constructor='TransformerFinetuneConstructor', | ||
model_type='vit', | ||
layer_decay=0.65) | ||
|
||
# learning policy | ||
lr_config = dict( | ||
policy='StepFixCosineAnnealing', | ||
min_lr=1e-6, | ||
warmup='linear', | ||
warmup_iters=5, | ||
warmup_ratio=1e-4, | ||
warmup_by_epoch=True, | ||
by_epoch=False) | ||
|
||
# apex | ||
use_fp16 = True | ||
fp16 = dict(type='mmcv', loss_scale='dynamic') | ||
# optimizer args | ||
optimizer_config = dict( | ||
update_interval=update_interval, grad_clip=dict(max_norm=5.0), | ||
) | ||
|
||
# runtime settings | ||
runner = dict(type='EpochBasedRunner', max_epochs=50) |
48 changes: 48 additions & 0 deletions
48
...gs/benchmarks/classification/imagenet/vit_large_p16_swin_ft_mae_sz224_8xb128_cos_ep100.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,48 @@ | ||
_base_ = [ | ||
'../_base_/models/vit_large_p16.py', | ||
'../_base_/datasets/imagenet_swin_ft_sz224_8xbs128.py', | ||
'../_base_/default_runtime.py', | ||
] | ||
|
||
# data | ||
data = dict(imgs_per_gpu=128, workers_per_gpu=8) | ||
|
||
# interval for accumulate gradient | ||
update_interval = 1 # total: 8 x bs128 x 1 accumulates = bs1024 | ||
|
||
# optimizer | ||
optimizer = dict( | ||
type='AdamW', | ||
lr=2e-3, | ||
weight_decay=0.05, eps=1e-8, betas=(0.9, 0.999), | ||
paramwise_options={ | ||
'(bn|ln|gn)(\d+)?.(weight|bias)': dict(weight_decay=0.), | ||
'norm': dict(weight_decay=0.), | ||
'bias': dict(weight_decay=0.), | ||
'cls_token': dict(weight_decay=0.), | ||
'pos_embed': dict(weight_decay=0.), | ||
}, | ||
constructor='TransformerFinetuneConstructor', | ||
model_type='vit', | ||
layer_decay=0.65) | ||
|
||
# learning policy | ||
lr_config = dict( | ||
policy='StepFixCosineAnnealing', | ||
min_lr=1e-6, | ||
warmup='linear', | ||
warmup_iters=5, | ||
warmup_ratio=1e-4, | ||
warmup_by_epoch=True, | ||
by_epoch=False) | ||
|
||
# apex | ||
use_fp16 = True | ||
fp16 = dict(type='mmcv', loss_scale='dynamic') | ||
# optimizer args | ||
optimizer_config = dict( | ||
update_interval=update_interval, grad_clip=dict(max_norm=5.0), | ||
) | ||
|
||
# runtime settings | ||
runner = dict(type='EpochBasedRunner', max_epochs=100) |
49 changes: 49 additions & 0 deletions
49
configs/benchmarks/mmdetection/_base_/datasets/coco_instance.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,49 @@ | ||
# dataset settings | ||
dataset_type = 'CocoDataset' | ||
data_root = 'data/coco/' | ||
img_norm_cfg = dict( | ||
mean=[123.675, 116.28, 103.53], std=[58.395, 57.12, 57.375], to_rgb=True) | ||
train_pipeline = [ | ||
dict(type='LoadImageFromFile'), | ||
dict(type='LoadAnnotations', with_bbox=True, with_mask=True), | ||
dict(type='Resize', img_scale=(1333, 800), keep_ratio=True), | ||
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=(1333, 800), | ||
flip=False, | ||
transforms=[ | ||
dict(type='Resize', keep_ratio=True), | ||
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=2, | ||
workers_per_gpu=2, | ||
train=dict( | ||
type=dataset_type, | ||
ann_file=data_root + 'annotations/instances_train2017.json', | ||
img_prefix=data_root + 'train2017/', | ||
pipeline=train_pipeline), | ||
val=dict( | ||
type=dataset_type, | ||
ann_file=data_root + 'annotations/instances_val2017.json', | ||
img_prefix=data_root + 'val2017/', | ||
pipeline=test_pipeline), | ||
test=dict( | ||
type=dataset_type, | ||
ann_file=data_root + 'annotations/instances_val2017.json', | ||
img_prefix=data_root + 'val2017/', | ||
pipeline=test_pipeline)) | ||
evaluation = dict(metric=['bbox', 'segm']) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,55 @@ | ||
# dataset settings | ||
dataset_type = 'VOCDataset' | ||
data_root = 'data/VOCdevkit/' | ||
img_norm_cfg = dict( | ||
mean=[123.675, 116.28, 103.53], std=[58.395, 57.12, 57.375], to_rgb=True) | ||
train_pipeline = [ | ||
dict(type='LoadImageFromFile'), | ||
dict(type='LoadAnnotations', with_bbox=True), | ||
dict(type='Resize', img_scale=(1000, 600), keep_ratio=True), | ||
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']), | ||
] | ||
test_pipeline = [ | ||
dict(type='LoadImageFromFile'), | ||
dict( | ||
type='MultiScaleFlipAug', | ||
img_scale=(1000, 600), | ||
flip=False, | ||
transforms=[ | ||
dict(type='Resize', keep_ratio=True), | ||
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=2, | ||
workers_per_gpu=2, | ||
train=dict( | ||
type='RepeatDataset', | ||
times=3, | ||
dataset=dict( | ||
type=dataset_type, | ||
ann_file=[ | ||
data_root + 'VOC2007/ImageSets/Main/trainval.txt', | ||
data_root + 'VOC2012/ImageSets/Main/trainval.txt' | ||
], | ||
img_prefix=[data_root + 'VOC2007/', data_root + 'VOC2012/'], | ||
pipeline=train_pipeline)), | ||
val=dict( | ||
type=dataset_type, | ||
ann_file=data_root + 'VOC2007/ImageSets/Main/test.txt', | ||
img_prefix=data_root + 'VOC2007/', | ||
pipeline=test_pipeline), | ||
test=dict( | ||
type=dataset_type, | ||
ann_file=data_root + 'VOC2007/ImageSets/Main/test.txt', | ||
img_prefix=data_root + 'VOC2007/', | ||
pipeline=test_pipeline)) | ||
evaluation = dict(interval=1, metric='mAP') |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
checkpoint_config = dict(interval=1) | ||
# yapf:disable | ||
log_config = dict( | ||
interval=50, | ||
hooks=[ | ||
dict(type='TextLoggerHook'), | ||
# dict(type='TensorboardLoggerHook') | ||
]) | ||
# yapf:enable | ||
custom_hooks = [dict(type='NumClassCheckHook')] | ||
|
||
dist_params = dict(backend='nccl') | ||
log_level = 'INFO' | ||
load_from = None | ||
resume_from = None | ||
workflow = [('train', 1)] | ||
|
||
# disable opencv multithreading to avoid system being overloaded | ||
opencv_num_threads = 0 | ||
# set multi-process start method as `fork` to speed up the training | ||
mp_start_method = 'fork' | ||
|
||
# Default setting for scaling LR automatically | ||
# - `enable` means enable scaling LR automatically | ||
# or not by default. | ||
# - `base_batch_size` = (8 GPUs) x (2 samples per GPU). | ||
auto_scale_lr = dict(enable=False, base_batch_size=16) |
Oops, something went wrong.