Shortcuts

Note

You are reading the documentation for MMEditing 0.x, which will soon be deprecated by the end of 2022. We recommend you upgrade to MMEditing 1.0 to enjoy fruitful new features and better performance brought by OpenMMLab 2.0. Check out the changelog, code and documentation of MMEditing 1.0 for more details.

Source code for mmedit.models.builder

# Copyright (c) OpenMMLab. All rights reserved.
import torch.nn as nn
from mmcv import build_from_cfg

from .registry import BACKBONES, COMPONENTS, LOSSES, MODELS


[docs]def build(cfg, registry, default_args=None): """Build module function. Args: cfg (dict): Configuration for building modules. registry (obj): ``registry`` object. default_args (dict, optional): Default arguments. Defaults to None. """ if isinstance(cfg, list): modules = [ build_from_cfg(cfg_, registry, default_args) for cfg_ in cfg ] return nn.Sequential(*modules) return build_from_cfg(cfg, registry, default_args)
[docs]def build_backbone(cfg): """Build backbone. Args: cfg (dict): Configuration for building backbone. """ return build(cfg, BACKBONES)
[docs]def build_component(cfg): """Build component. Args: cfg (dict): Configuration for building component. """ return build(cfg, COMPONENTS)
[docs]def build_loss(cfg): """Build loss. Args: cfg (dict): Configuration for building loss. """ return build(cfg, LOSSES)
[docs]def build_model(cfg, train_cfg=None, test_cfg=None): """Build model. Args: cfg (dict): Configuration for building model. train_cfg (dict): Training configuration. Default: None. test_cfg (dict): Testing configuration. Default: None. """ return build(cfg, MODELS, dict(train_cfg=train_cfg, test_cfg=test_cfg))
Read the Docs v: latest
Versions
latest
stable
1.x
v0.16.0
v0.15.2
v0.15.1
v0.15.0
v0.14.0
v0.13.0
v0.12.0
dev-1.x
Downloads
pdf
html
epub
On Read the Docs
Project Home
Builds

Free document hosting provided by Read the Docs.