Exemple #1
0
def train(cfg, args, model, device, distributed):
    optimizer = make_optimizer(cfg, model)
    scheduler = make_lr_scheduler(cfg, optimizer)

    arguments = {}
    arguments["iteration"] = 0

    output_dir = cfg.OUTPUT_DIR
    save_to_disk = comm.get_rank() == 0
    checkpointer = DetectronCheckpointer(cfg, model, optimizer, scheduler,
                                         output_dir, save_to_disk)

    if cfg.MODEL.BACKBONE.CONV_BODY is "DLA-34-DCN":
        ckpt = cfg.MODEL.WEIGHT if args.ckpt is None else args.ckpt
        extra_checkpoint_data = checkpointer.load(ckpt)
        arguments.update(extra_checkpoint_data)
    elif args.ckpt is not None:
        extra_checkpoint_data = checkpointer.load(args.ckpt)
        arguments.update(extra_checkpoint_data)

    data_loader = make_data_loader(
        cfg,
        is_train=True,
    )

    checkpoint_period = cfg.SOLVER.CHECKPOINT_PERIOD

    do_train(cfg, distributed, model, data_loader, optimizer, scheduler,
             checkpointer, device, checkpoint_period, arguments)
Exemple #2
0
def train(cfg, model, device, distributed):
    optimizer = make_optimizer(cfg, model)
    scheduler = make_lr_scheduler(cfg, optimizer)

    arguments = {}
    arguments["iteration"] = 0

    output_dir = cfg.OUTPUT_DIR
    save_to_disk = comm.get_rank() == 0
    checkpointer = DetectronCheckpointer(
        cfg, model, optimizer, scheduler, output_dir, save_to_disk
    )
    extra_checkpoint_data = checkpointer.load(cfg.MODEL.WEIGHT)
    arguments.update(extra_checkpoint_data)

    data_loader = make_data_loader(
        cfg,
        is_train=True,
    )

    checkpoint_period = cfg.SOLVER.CHECKPOINT_PERIOD

    do_train(
        cfg,
        distributed,
        model,
        data_loader,
        optimizer,
        scheduler,
        checkpointer,
        device,
        checkpoint_period,
        arguments
    )