Example #1
0
def build(task: str, cfg: CfgNode) -> List[MonitorBase]:
    r"""
    Builder function.

    Arguments
    ---------
    task: str
        builder task name (track|vos)
    cfg: CfgNode
        node name: monitors
    
    Returns
    -------
    List[MonitorBase]
        list of monitors
    """
    assert task in TASK_MONITORS, "no tester for task {}".format(task)
    modules = TASK_MONITORS[task]

    names = cfg.names
    monitors = []
    for name in names:
        monitor = modules[name]()
        hps = monitor.get_hps()
        hps = merge_cfg_into_hps(cfg[name], hps)
        monitor.set_hps(hps)
        monitor.update_params()
        monitors.append(monitor)

    return monitors
Example #2
0
def build(task: str, cfg: CfgNode, optimizer, dataloader) -> TrainerBase:
    r"""
    Builder function.

    Arguments
    ---------
    task: str
        builder task name (track|vos)
    cfg: CfgNode
        node name: trainer

    Returns
    -------
    TrainerBase
        tester built by builder
    """
    assert task in TASK_TRAINERS, "no trainer for task {}".format(task)
    MODULES = TASK_TRAINERS[task]

    # build monitors
    if "monitors" in cfg:
        monitor_cfg = cfg.monitors
        monitors = monitor_builder.build(task, monitor_cfg)
    else:
        monitors = []

    name = cfg.name
    trainer = MODULES[name](optimizer, dataloader, monitors)
    hps = trainer.get_hps()
    hps = merge_cfg_into_hps(cfg[name], hps)
    trainer.set_hps(hps)
    trainer.update_params()

    return trainer
Example #3
0
def build(task: str, cfg: CfgNode):
    if task in TASK_LOSSES:
        MODULES = TASK_LOSSES[task]
    else:
        logger.error("no loss for task {}".format(task))
        exit(-1)

    names = cfg.names
    loss_dict = OrderedDict()
    for name in names:
        assert name in MODULES, "loss {} not registered for {}!".format(
            name, task)
        module = MODULES[name]()
        hps = module.get_hps()
        hps = merge_cfg_into_hps(cfg[name], hps)
        module.set_hps(hps)
        module.update_params()
        loss_dict[cfg[name].name] = module

    return loss_dict