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
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
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
def build_brick(cfg, default_args=None): brick = build_from_cfg(cfg, BRICKS, default_args) return brick
def build_lr_scheduler(cfg, default_args=None): scheduler = build_from_cfg(cfg, LR_SCHEDULERS, default_args, 'registry') return scheduler
def build_enhance(cfg, default_args=None): decoder = build_from_cfg(cfg, ENHANCE, default_args) return decoder
def build_backbone(cfg, default_args=None): backbone = build_from_cfg(cfg, BACKBONES, default_args) return backbone
def build_collate_fn(cfg, default_args=None): collate_fn = build_from_cfg(cfg, COLLATE_FN, default_args) return collate_fn
def build_dataloader(cfg, default_args=None): dataloader = build_from_cfg(cfg, DATALOADERS, default_args) return dataloader
def build_enhance_module(cfg, default_args=None): enhance_module = build_from_cfg(cfg, ENHANCE_MODULES, default_args) return enhance_module
def build_optimizer(cfg, default_args=None): optim = build_from_cfg(cfg, torch_optim, default_args, 'module') return optim
def build_head(cfg, default_args=None): heads = build_from_cfg(cfg, HEADS, default_args) return heads
def build_module(cfg, default_args=None): util = build_from_cfg(cfg, UTILS, default_args) return util
def build_torch_nn(cfg, default_args=None): module = build_from_cfg(cfg, nn, default_args, 'module') return module