Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Feature/lint #16

Merged
merged 2 commits into from
May 13, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
141 changes: 0 additions & 141 deletions configs/mmtune/_base_/space/mmseg_model.py
Original file line number Diff line number Diff line change
Expand Up @@ -230,143 +230,6 @@
test_cfg=dict(mode='slide', crop_size=(512, 512), stride=(256, 256)),
)

ocrnet_hr18 = dict(
_delete_=True,
type='CascadeEncoderDecoder',
num_stages=2,
pretrained='open-mmlab://msra/hrnetv2_w18',
backbone=dict(
type='HRNet',
norm_cfg=norm_cfg,
norm_eval=False,
extra=dict(
stage1=dict(
num_modules=1,
num_branches=1,
block='BOTTLENECK',
num_blocks=(4, ),
num_channels=(64, ),
),
stage2=dict(
num_modules=1,
num_branches=2,
block='BASIC',
num_blocks=(4, 4),
num_channels=(18, 36),
),
stage3=dict(
num_modules=4,
num_branches=3,
block='BASIC',
num_blocks=(4, 4, 4),
num_channels=(18, 36, 72),
),
stage4=dict(
num_modules=3,
num_branches=4,
block='BASIC',
num_blocks=(4, 4, 4, 4),
num_channels=(18, 36, 72, 144),
),
),
),
decode_head=[
dict(
type='FCNHead',
in_channels=[18, 36, 72, 144],
channels=sum([18, 36, 72, 144]),
in_index=(0, 1, 2, 3),
input_transform='resize_concat',
kernel_size=1,
num_convs=1,
concat_input=False,
dropout_ratio=-1,
num_classes=3,
norm_cfg=norm_cfg,
align_corners=False,
loss_decode=dict(
type='CrossEntropyLoss', use_sigmoid=False, loss_weight=0.4),
),
dict(
type='OCRHead',
in_channels=[18, 36, 72, 144],
in_index=(0, 1, 2, 3),
input_transform='resize_concat',
channels=512,
ocr_channels=256,
dropout_ratio=-1,
num_classes=3,
norm_cfg=norm_cfg,
align_corners=False,
loss_decode=dict(
type='CrossEntropyLoss', use_sigmoid=False, loss_weight=1.0),
),
],
# model training and testing settings
train_cfg=dict(),
test_cfg=dict(mode='slide', crop_size=(512, 512), stride=(256, 256)),
)

fcn_hr18 = dict(
_delete_=True,
type='EncoderDecoder',
pretrained='open-mmlab://msra/hrnetv2_w18',
backbone=dict(
type='HRNet',
norm_cfg=norm_cfg,
norm_eval=False,
extra=dict(
stage1=dict(
num_modules=1,
num_branches=1,
block='BOTTLENECK',
num_blocks=(4, ),
num_channels=(64, ),
),
stage2=dict(
num_modules=1,
num_branches=2,
block='BASIC',
num_blocks=(4, 4),
num_channels=(18, 36),
),
stage3=dict(
num_modules=4,
num_branches=3,
block='BASIC',
num_blocks=(4, 4, 4),
num_channels=(18, 36, 72),
),
stage4=dict(
num_modules=3,
num_branches=4,
block='BASIC',
num_blocks=(4, 4, 4, 4),
num_channels=(18, 36, 72, 144),
),
),
),
decode_head=dict(
type='FCNHead',
in_channels=[18, 36, 72, 144],
in_index=(0, 1, 2, 3),
channels=sum([18, 36, 72, 144]),
input_transform='resize_concat',
kernel_size=1,
num_convs=1,
concat_input=False,
dropout_ratio=-1,
num_classes=3,
norm_cfg=norm_cfg,
align_corners=False,
loss_decode=dict(
type='CrossEntropyLoss', use_sigmoid=False, loss_weight=1.0),
),
# model training and testing settings
train_cfg=dict(),
test_cfg=dict(mode='slide', crop_size=(512, 512), stride=(256, 256)),
)

model = dict(
type='Choice',
categories=[
Expand All @@ -375,16 +238,12 @@
deeplabv3plus_r50_d8,
segformer_mit_b0,
fpn_r50,
ocrnet_hr18,
fcn_hr18,
],
alias=[
'pspnet_r50_d8',
'upernet_swin',
'deeplabv3plus_r50_d8',
'segformer_mit_b0',
'fpn_r50',
'ocrnet_hr18',
'fcn_hr18',
],
)
4 changes: 3 additions & 1 deletion configs/mmtune/mmseg_asynchb_nevergrad_pso.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,9 @@
space = {
'model': {{_base_.model}},
'optimizer': {{_base_.optimizer}},
'data.samples_per_gpu': {{_base_.batch_size}}
'data.samples_per_gpu': {{_base_.batch_size}},
'model.decode_head.num_classes': dict(type='Constant', value=21),
'model.auxiliary_head.num_classes': dict(type='Constant', value=21),
}

metric = 'val/mIoU'
Expand Down
2 changes: 0 additions & 2 deletions mmtune/mm/tasks/mmtrainbase.py
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,6 @@ def train_model(self, model: torch.nn.Module,
**kwargs) -> None:
pass


def contextaware_run(self, status, backend, *args, **kwargs) -> None:
from mmtune.mm import hooks # noqa F401
if backend == 'nccl' and os.getenv('NCCL_BLOCKING_WAIT') is None:
Expand All @@ -52,4 +51,3 @@ def create_trainable(self, backend: str = 'nccl') -> ray.tune.trainable:
num_workers=self.args.num_workers,
num_gpus_per_worker=self.args.num_cpus_per_worker,
num_cpus_per_worker=self.args.num_cpus_per_worker)

3 changes: 2 additions & 1 deletion mmtune/ray/spaces/__init__.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
from .builder import SPACES, build_space
from .choice import Choice
from .const import Constant

__all__ = ['SPACES', 'build_space', 'Choice']
__all__ = ['SPACES', 'build_space', 'Choice', 'Constant']
17 changes: 17 additions & 0 deletions mmtune/ray/spaces/const.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
from typing import Any, Optional

from mmtune.utils import ImmutableContainer
from .base import BaseSpace
from .builder import SPACES


@SPACES.register_module()
class Constant(BaseSpace):

def __init__(self,
value: Any,
alias: Optional[str] = None,
use_container: bool = True):
if use_container:
value = ImmutableContainer(value, alias)
self._space = value