Exemple #1
0
def build_transform(cfg):
    tfs = []

    for icfg in cfg:
        if TRANSFORMS.get(icfg.get('type')) is not None:
            tf = build_from_cfg(icfg, TRANSFORMS)
        elif hasattr(alb, icfg.get('type')):
            if icfg.get('interpolation') and icfg.get(
                    'interpolation') in CV2_MODE:
                icfg['interpolation'] = CV2_MODE[icfg.get('interpolation')]
            if icfg.get('border_mode') and icfg.get(
                    'border_mode') in CV2_BORDER_MODE:
                icfg['border_mode'] = CV2_BORDER_MODE[icfg.get('border_mode')]
            tf = build_from_cfg(icfg, alb, mode='module')

        else:
            raise AttributeError(f"Invalid class {icfg.get('type')}")

        tfs.append(tf)

    aug = alb.Compose(
        transforms=tfs,
        p=1,
        keypoint_params=alb.KeypointParams(format='xy',
                                           remove_invisible=False),
    )

    return aug
Exemple #2
0
def build_datasets(cfg, default_args=None):
    datasets = []
    for icfg in cfg:
        ds = build_from_cfg(icfg, DATASETS, default_args)
        datasets.append(ds)

    return datasets
Exemple #3
0
def build_criterion(cfgs):

    criterion_list = []
    for cfg in cfgs:
        criterion = build_from_cfg(cfg, CRITERIA, mode='registry')
        criterion_list.append(criterion)

    return criterion_list
Exemple #4
0
def build_brick(cfg, default_args=None):
    brick = build_from_cfg(cfg, BRICKS, default_args)
    return brick
Exemple #5
0
def build_lr_scheduler(cfg, default_args=None):
    scheduler = build_from_cfg(cfg, LR_SCHEDULERS, default_args, 'registry')
    return scheduler
Exemple #6
0
def build_enhance(cfg, default_args=None):
    decoder = build_from_cfg(cfg, ENHANCE, default_args)
    return decoder
Exemple #7
0
def build_backbone(cfg, default_args=None):
    backbone = build_from_cfg(cfg, BACKBONES, default_args)

    return backbone
Exemple #8
0
def build_collate_fn(cfg, default_args=None):
    collate_fn = build_from_cfg(cfg, COLLATE_FN, default_args)

    return collate_fn
Exemple #9
0
def build_dataloader(cfg, default_args=None):
    dataloader = build_from_cfg(cfg, DATALOADERS, default_args)

    return dataloader
Exemple #10
0
def build_enhance_module(cfg, default_args=None):
    enhance_module = build_from_cfg(cfg, ENHANCE_MODULES, default_args)

    return enhance_module
Exemple #11
0
def build_optimizer(cfg, default_args=None):
    optim = build_from_cfg(cfg, torch_optim, default_args, 'module')

    return optim
Exemple #12
0
def build_head(cfg, default_args=None):
    heads = build_from_cfg(cfg, HEADS, default_args)

    return heads
Exemple #13
0
def build_module(cfg, default_args=None):
    util = build_from_cfg(cfg, UTILS, default_args)
    return util
Exemple #14
0
def build_torch_nn(cfg, default_args=None):
    module = build_from_cfg(cfg, nn, default_args, 'module')
    return module