當前位置: 首頁>>代碼示例>>Python>>正文


Python data.make_data_loader方法代碼示例

本文整理匯總了Python中maskrcnn_benchmark.data.make_data_loader方法的典型用法代碼示例。如果您正苦於以下問題:Python data.make_data_loader方法的具體用法?Python data.make_data_loader怎麽用?Python data.make_data_loader使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在maskrcnn_benchmark.data的用法示例。


在下文中一共展示了data.make_data_loader方法的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。

示例1: run_test

# 需要導入模塊: from maskrcnn_benchmark import data [as 別名]
# 或者: from maskrcnn_benchmark.data import make_data_loader [as 別名]
def run_test(cfg, model, distributed):
    if distributed:
        model = model.module
    torch.cuda.empty_cache()  # TODO check if it helps
    iou_types = ("bbox",)
    if cfg.MODEL.MASK_ON:
        iou_types = iou_types + ("segm",)
    if cfg.MODEL.KEYPOINT_ON:
        iou_types = iou_types + ("keypoints",)
    output_folders = [None] * len(cfg.DATASETS.TEST)
    dataset_names = cfg.DATASETS.TEST
    if cfg.OUTPUT_DIR:
        for idx, dataset_name in enumerate(dataset_names):
            output_folder = os.path.join(cfg.OUTPUT_DIR, "inference", dataset_name)
            mkdir(output_folder)
            output_folders[idx] = output_folder
    data_loaders_val = make_data_loader(cfg, is_train=False, is_distributed=distributed)
    for output_folder, dataset_name, data_loader_val in zip(output_folders, dataset_names, data_loaders_val):
        inference(
            model,
            data_loader_val,
            dataset_name=dataset_name,
            iou_types=iou_types,
            box_only=False if cfg.MODEL.RETINANET_ON else cfg.MODEL.RPN_ONLY,
            device=cfg.MODEL.DEVICE,
            expected_results=cfg.TEST.EXPECTED_RESULTS,
            expected_results_sigma_tol=cfg.TEST.EXPECTED_RESULTS_SIGMA_TOL,
            output_folder=output_folder,
        )
        synchronize() 
開發者ID:Res2Net,項目名稱:Res2Net-maskrcnn,代碼行數:32,代碼來源:train_net.py

示例2: bn_statistic

# 需要導入模塊: from maskrcnn_benchmark import data [as 別名]
# 或者: from maskrcnn_benchmark.data import make_data_loader [as 別名]
def bn_statistic(model, rngs):
    from maskrcnn_benchmark.data import make_data_loader
    device = cfg.MODEL.DEVICE
    import torch.nn as nn

    for name, param in model.named_buffers():
        if 'running_mean' in name:
            nn.init.constant_(param, 0)
        if 'running_var' in name:
            nn.init.constant_(param, 1)

    data_loader = make_data_loader(
        cfg,
        is_train=True,
        is_distributed=True
    )
    model.train()
    pbar = tqdm(total=500)
    for iteration, (images, targets, _) in enumerate(data_loader, 1):
        images = images.to(device)
        targets = [target.to(device) for target in targets]
        with torch.no_grad():
            loss_dict = model(images, targets, rngs)
        pbar.update(1)
        if iteration >= 500:
            break
    pbar.close()
    return model 
開發者ID:megvii-model,項目名稱:DetNAS,代碼行數:30,代碼來源:inference.py

示例3: test

# 需要導入模塊: from maskrcnn_benchmark import data [as 別名]
# 或者: from maskrcnn_benchmark.data import make_data_loader [as 別名]
def test(cfg, model, distributed):
    if distributed:
        model = model.module
    torch.cuda.empty_cache()  # TODO check if it helps
    iou_types = ("bbox",)
    if cfg.MODEL.MASK_ON:
        iou_types = iou_types + ("segm",)
    output_folders = [None] * len(cfg.DATASETS.TEST)
    dataset_names = cfg.DATASETS.TEST
    if cfg.OUTPUT_DIR:
        for idx, dataset_name in enumerate(dataset_names):
            output_folder = os.path.join(cfg.OUTPUT_DIR, "inference", dataset_name)
            mkdir(output_folder)
            output_folders[idx] = output_folder
    data_loaders_val = make_data_loader(cfg, is_train=False, is_distributed=distributed)
    for output_folder, dataset_name, data_loader_val in zip(output_folders, dataset_names, data_loaders_val):
        inference(
            model,
            data_loader_val,
            dataset_name=dataset_name,
            iou_types=iou_types,
            box_only=cfg.MODEL.RPN_ONLY,
            device=cfg.MODEL.DEVICE,
            expected_results=cfg.TEST.EXPECTED_RESULTS,
            expected_results_sigma_tol=cfg.TEST.EXPECTED_RESULTS_SIGMA_TOL,
            output_folder=output_folder,
        )
        synchronize() 
開發者ID:clw5180,項目名稱:remote_sensing_object_detection_2019,代碼行數:30,代碼來源:train_net.py

示例4: run_test

# 需要導入模塊: from maskrcnn_benchmark import data [as 別名]
# 或者: from maskrcnn_benchmark.data import make_data_loader [as 別名]
def run_test(cfg, model, distributed):
    if distributed:
        model = model.module
    torch.cuda.empty_cache()  # TODO check if it helps
    iou_types = ("bbox",)
    if cfg.MODEL.MASK_ON:
        iou_types = iou_types + ("segm",)
    if cfg.MODEL.KEYPOINT_ON:
        iou_types = iou_types + ("keypoints",)
    output_folders = [None] * len(cfg.DATASETS.TEST)
    dataset_names = cfg.DATASETS.TEST
    if cfg.OUTPUT_DIR:
        for idx, dataset_name in enumerate(dataset_names):
            output_folder = os.path.join(cfg.OUTPUT_DIR, "inference", dataset_name)
            mkdir(output_folder)
            output_folders[idx] = output_folder
    data_loaders_val = make_data_loader(cfg, is_train=False, is_distributed=distributed)
    for output_folder, dataset_name, data_loader_val in zip(output_folders, dataset_names, data_loaders_val):
        inference(
            model,
            data_loader_val,
            dataset_name=dataset_name,
            iou_types=iou_types,
            box_only=False if cfg.MODEL.RETINANET_ON else cfg.MODEL.RPN_ONLY,
            bbox_aug=cfg.TEST.BBOX_AUG.ENABLED,
            device=cfg.MODEL.DEVICE,
            expected_results=cfg.TEST.EXPECTED_RESULTS,
            expected_results_sigma_tol=cfg.TEST.EXPECTED_RESULTS_SIGMA_TOL,
            output_folder=output_folder,
        )
        synchronize() 
開發者ID:facebookresearch,項目名稱:maskrcnn-benchmark,代碼行數:33,代碼來源:train_net.py

示例5: test

# 需要導入模塊: from maskrcnn_benchmark import data [as 別名]
# 或者: from maskrcnn_benchmark.data import make_data_loader [as 別名]
def test(cfg, model, distributed):
    if distributed:
        model = model.module
    torch.cuda.empty_cache()  # TODO check if it helps
    iou_types = ("bbox",)
    if cfg.MODEL.MASK_ON:
        iou_types = iou_types + ("segm",)
    output_folders = [None] * len(cfg.DATASETS.TEST)
    if cfg.OUTPUT_DIR:
        dataset_names = cfg.DATASETS.TEST
        for idx, dataset_name in enumerate(dataset_names):
            output_folder = os.path.join(cfg.OUTPUT_DIR, "inference", dataset_name)
            mkdir(output_folder)
            output_folders[idx] = output_folder
    data_loaders_val = make_data_loader(cfg, is_train=False, is_distributed=distributed)
    for output_folder, data_loader_val in zip(output_folders, data_loaders_val):
        inference(
            model,
            data_loader_val,
            iou_types=iou_types,
            #box_only=cfg.MODEL.RPN_ONLY,
            box_only=False if cfg.RETINANET.RETINANET_ON else cfg.MODEL.RPN_ONLY,
            device=cfg.MODEL.DEVICE,
            expected_results=cfg.TEST.EXPECTED_RESULTS,
            expected_results_sigma_tol=cfg.TEST.EXPECTED_RESULTS_SIGMA_TOL,
            output_folder=output_folder,
        )
        synchronize() 
開發者ID:zhangxiaosong18,項目名稱:FreeAnchor,代碼行數:30,代碼來源:train_net.py

示例6: test

# 需要導入模塊: from maskrcnn_benchmark import data [as 別名]
# 或者: from maskrcnn_benchmark.data import make_data_loader [as 別名]
def test(cfg, model, distributed):
    if distributed:
        model = model.module
    torch.cuda.empty_cache()  # TODO check if it helps
    iou_types = ("bbox",)
    if cfg.MODEL.MASK_ON:
        iou_types = iou_types + ("segm",)
    if cfg.MODEL.KEYPOINT_ON:
        iou_types = iou_types + ("keypoints",)
    output_folders = [None] * len(cfg.DATASETS.TEST)
    dataset_names = cfg.DATASETS.TEST
    if cfg.OUTPUT_DIR:
        for idx, dataset_name in enumerate(dataset_names):
            output_folder = os.path.join(cfg.OUTPUT_DIR, "inference", dataset_name)
            mkdir(output_folder)
            output_folders[idx] = output_folder
    data_loaders_val = make_data_loader(cfg, is_train=False, is_distributed=distributed)
    for output_folder, dataset_name, data_loader_val in zip(output_folders, dataset_names, data_loaders_val):
        inference(
            model,
            data_loader_val,
            dataset_name=dataset_name,
            iou_types=iou_types,
            box_only=False if cfg.MODEL.RETINANET_ON else cfg.MODEL.RPN_ONLY,
            device=cfg.MODEL.DEVICE,
            expected_results=cfg.TEST.EXPECTED_RESULTS,
            expected_results_sigma_tol=cfg.TEST.EXPECTED_RESULTS_SIGMA_TOL,
            output_folder=output_folder,
        )
        synchronize() 
開發者ID:mlperf,項目名稱:training,代碼行數:32,代碼來源:train_net.py

示例7: run_test

# 需要導入模塊: from maskrcnn_benchmark import data [as 別名]
# 或者: from maskrcnn_benchmark.data import make_data_loader [as 別名]
def run_test(cfg, model, distributed):  
    if distributed:  
        model = model.module  
    torch.cuda.empty_cache()  # TODO check if it helps  
    iou_types = ("bbox",)  
    if cfg.MODEL.MASK_ON:  
        iou_types = iou_types + ("segm",)
    if cfg.MODEL.KEYPOINT_ON:
        iou_types = iou_types + ("keypoints",)  
    output_folders = [None] * len(cfg.DATASETS.TEST)  
    dataset_names = cfg.DATASETS.TEST  
    if cfg.OUTPUT_DIR:  
        for idx, dataset_name in enumerate(dataset_names):  
            output_folder = os.path.join(cfg.OUTPUT_DIR, "inference", dataset_name)  
            mkdir(output_folder)  
            output_folders[idx] = output_folder  
    data_loaders_val = make_data_loader(cfg, mode=0, resolution=None, is_train=False, is_distributed=distributed)
    for loader in data_loaders_val:
        loader.collate_fn.special_deal = False
    for output_folder, dataset_name, data_loader_val in zip(output_folders, dataset_names, data_loaders_val):  
        inference(  
            model,  
            data_loader_val,  
            dataset_name=dataset_name,  
            iou_types=iou_types,  
            box_only=False if (cfg.MODEL.RETINANET_ON or cfg.MODEL.DENSEBOX_ON) else cfg.MODEL.RPN_ONLY,  
            device=cfg.MODEL.DEVICE,  
            expected_results=cfg.TEST.EXPECTED_RESULTS,  
            expected_results_sigma_tol=cfg.TEST.EXPECTED_RESULTS_SIGMA_TOL,  
            output_folder=output_folder,  
        )  
        synchronize() 
開發者ID:Lausannen,項目名稱:NAS-FCOS,代碼行數:34,代碼來源:train_net.py

示例8: test

# 需要導入模塊: from maskrcnn_benchmark import data [as 別名]
# 或者: from maskrcnn_benchmark.data import make_data_loader [as 別名]
def test(cfg, model, distributed):
    if distributed:
        model = model.module
    torch.cuda.empty_cache()  # TODO check if it helps
    iou_types = ("bbox",)
    if cfg.MODEL.MASK_ON:
        iou_types = iou_types + ("segm",)
    output_folders = [None] * len(cfg.DATASETS.TEST)
    if cfg.OUTPUT_DIR:
        dataset_names = cfg.DATASETS.TEST
        for idx, dataset_name in enumerate(dataset_names):
            output_folder = os.path.join(cfg.OUTPUT_DIR, "inference", dataset_name)
            mkdir(output_folder)
            output_folders[idx] = output_folder
    data_loaders_val = make_data_loader(cfg, is_train=False, is_distributed=distributed)
    for output_folder, data_loader_val in zip(output_folders, data_loaders_val):
        inference(
            model,
            data_loader_val,
            iou_types=iou_types,
            box_only=cfg.MODEL.RPN_ONLY,
            device=cfg.MODEL.DEVICE,
            expected_results=cfg.TEST.EXPECTED_RESULTS,
            expected_results_sigma_tol=cfg.TEST.EXPECTED_RESULTS_SIGMA_TOL,
            output_folder=output_folder,
            maskiou_on=cfg.MODEL.MASKIOU_ON
        )
        synchronize() 
開發者ID:zjhuang22,項目名稱:maskscoring_rcnn,代碼行數:30,代碼來源:train_net.py

示例9: run_test

# 需要導入模塊: from maskrcnn_benchmark import data [as 別名]
# 或者: from maskrcnn_benchmark.data import make_data_loader [as 別名]
def run_test(cfg, model, distributed):
    if distributed:
        model = model.module
    torch.cuda.empty_cache()  # TODO check if it helps
    iou_types = ("bbox",)
    if cfg.MODEL.MASK_ON:
        iou_types = iou_types + ("segm",)
    if cfg.MODEL.KEYPOINT_ON:
        iou_types = iou_types + ("keypoints",)
    output_folders = [None] * len(cfg.DATASETS.TEST)
    dataset_names = cfg.DATASETS.TEST
    if cfg.OUTPUT_DIR:
        for idx, dataset_name in enumerate(dataset_names):
            output_folder = os.path.join(cfg.OUTPUT_DIR, "inference", dataset_name)
            mkdir(output_folder)
            output_folders[idx] = output_folder
    data_loaders_val = make_data_loader(cfg, is_train=False, is_distributed=distributed)
    for output_folder, dataset_name, data_loader_val in zip(output_folders, dataset_names, data_loaders_val):
        inference(
            model,
            data_loader_val,
            dataset_name=dataset_name,
            iou_types=iou_types,
            box_only=False if cfg.MODEL.FCOS_ON or cfg.MODEL.RETINANET_ON or cfg.MODEL.GAU_ON else cfg.MODEL.RPN_ONLY,  # changed for fcos
            device=cfg.MODEL.DEVICE,
            expected_results=cfg.TEST.EXPECTED_RESULTS,
            expected_results_sigma_tol=cfg.TEST.EXPECTED_RESULTS_SIGMA_TOL,
            output_folder=output_folder,
            ignore_uncertain=cfg.TEST.IGNORE_UNCERTAIN,
            use_iod_for_ignore=cfg.TEST.USE_IOD_FOR_IGNORE,
            eval_standard=cfg.TEST.COCO_EVALUATE_STANDARD,
            use_last_prediction=cfg.TEST.DEBUG.USE_LAST_PREDICTION,
            evaluate_method=cfg.TEST.EVALUATE_METHOD,
            voc_iou_ths=cfg.TEST.VOC_IOU_THS,
            gt_file={'merge': cfg.TEST.MERGE_GT_FILE,
                     'sub': DatasetCatalog.DATA_DIR + '/' + DatasetCatalog.DATASETS[dataset_name]["ann_file"]},
            use_ignore_attr=cfg.TEST.USE_IGNORE_ATTR
        )
        synchronize()

# ################################################ add by hui ################################################# 
開發者ID:ucas-vg,項目名稱:TinyBenchmark,代碼行數:43,代碼來源:train_test_net.py

示例10: run_test

# 需要導入模塊: from maskrcnn_benchmark import data [as 別名]
# 或者: from maskrcnn_benchmark.data import make_data_loader [as 別名]
def run_test(cfg, model, distributed):
    if distributed:
        model = model.module
    torch.cuda.empty_cache()  # TODO check if it helps
    iou_types = ("bbox",)
    if cfg.MODEL.MASK_ON:
        iou_types = iou_types + ("segm",)
    if cfg.MODEL.KEYPOINT_ON:
        iou_types = iou_types + ("keypoints",)
    output_folders = [None] * len(cfg.DATASETS.TEST)
    dataset_names = cfg.DATASETS.TEST
    if cfg.OUTPUT_DIR:
        for idx, dataset_name in enumerate(dataset_names):
            output_folder = os.path.join(cfg.OUTPUT_DIR, "inference", dataset_name)
            mkdir(output_folder)
            output_folders[idx] = output_folder
    data_loaders_val = make_data_loader(cfg, is_train=False, is_distributed=distributed)
    for output_folder, dataset_name, data_loader_val in zip(output_folders, dataset_names, data_loaders_val):
        inference(
            model,
            data_loader_val,
            dataset_name=dataset_name,
            iou_types=iou_types,
            box_only=False if cfg.MODEL.FCOS_ON or cfg.MODEL.RETINANET_ON else cfg.MODEL.RPN_ONLY,  # changed for fcos
            device=cfg.MODEL.DEVICE,
            expected_results=cfg.TEST.EXPECTED_RESULTS,
            expected_results_sigma_tol=cfg.TEST.EXPECTED_RESULTS_SIGMA_TOL,
            output_folder=output_folder,
        )
        synchronize() 
開發者ID:ucas-vg,項目名稱:TinyBenchmark,代碼行數:32,代碼來源:train_net.py

示例11: train

# 需要導入模塊: from maskrcnn_benchmark import data [as 別名]
# 或者: from maskrcnn_benchmark.data import make_data_loader [as 別名]
def train(cfg, local_rank, distributed):
    model = build_detection_model(cfg)
    device = torch.device(cfg.MODEL.DEVICE)
    model.to(device)

    optimizer = make_optimizer(cfg, model)
    scheduler = make_lr_scheduler(cfg, optimizer)

    if distributed:
        model = torch.nn.parallel.DistributedDataParallel(
            model, device_ids=[local_rank], output_device=local_rank,
            # this should be removed if we update BatchNorm stats
            broadcast_buffers=False,
        )

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

    output_dir = cfg.OUTPUT_DIR

    save_to_disk = 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,
        is_distributed=distributed,
        start_iter=arguments["iteration"],
    )

    checkpoint_period = cfg.SOLVER.CHECKPOINT_PERIOD

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

    return model 
開發者ID:Res2Net,項目名稱:Res2Net-maskrcnn,代碼行數:50,代碼來源:train_net.py

示例12: train

# 需要導入模塊: from maskrcnn_benchmark import data [as 別名]
# 或者: from maskrcnn_benchmark.data import make_data_loader [as 別名]
def train(cfg, local_rank, distributed):
    model = build_detection_model(cfg)
    device = torch.device(cfg.MODEL.DEVICE)
    model.to(device)

    optimizer = make_optimizer(cfg, model)
    scheduler = make_lr_scheduler(cfg, optimizer)

    if distributed:
        model = torch.nn.parallel.DistributedDataParallel(
            model, device_ids=[local_rank], output_device=local_rank,
            # this should be removed if we update BatchNorm stats
            broadcast_buffers=False,
        )

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

    output_dir = cfg.OUTPUT_DIR

    save_to_disk = 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)
    arguments["iteration"] = 0

    data_loader = make_data_loader(
        cfg,
        is_train=True,
        is_distributed=distributed,
        start_iter=arguments["iteration"],
    )

    checkpoint_period = cfg.SOLVER.CHECKPOINT_PERIOD

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

    return model 
開發者ID:Xiangyu-CAS,項目名稱:R2CNN.pytorch,代碼行數:51,代碼來源:train_net.py

示例13: fitness

# 需要導入模塊: from maskrcnn_benchmark import data [as 別名]
# 或者: from maskrcnn_benchmark.data import make_data_loader [as 別名]
def fitness(gpu, ngpus_per_node, cfg, args, rngs, salt, conn):
    num_gpus = int(os.environ["WORLD_SIZE"]) \
        if "WORLD_SIZE" in os.environ else 1
    args["distributed"] = num_gpus > 1

    args["local_rank"] = gpu

    if args["distributed"]:
        torch.cuda.set_device(args["local_rank"])
        torch.distributed.init_process_group(
            backend="nccl", init_method="env://",
            world_size=num_gpus, rank=args["local_rank"]
        )

    model = GeneralizedRCNN(cfg)
    model.to(cfg.MODEL.DEVICE)

    save_to_disk = get_rank() == 0
    checkpointer = DetectronCheckpointer2(
        cfg, model, save_dir=cfg.OUTPUT_DIR, save_to_disk=save_to_disk)
    extra_checkpoint_data = checkpointer.load(os.path.join(cfg.OUTPUT_DIR, salt+".pth"))

    iou_types = ("bbox",)
    if cfg.MODEL.MASK_ON:
        iou_types = iou_types + ("segm",)
    output_folders = [None] * len(cfg.DATASETS.TEST)
    if cfg.OUTPUT_DIR:
        dataset_names = cfg.DATASETS.TEST
        for idx, dataset_name in enumerate(dataset_names):
            output_folder = os.path.join(
                cfg.OUTPUT_DIR, "inference", dataset_name)
            mkdir(output_folder)
            output_folders[idx] = output_folder

    data_loaders_val = make_data_loader(
        cfg, is_train=False, is_distributed=args["distributed"])
    for output_folder, data_loader_val in zip(output_folders, data_loaders_val):
        results = inference(
            model,
            rngs,
            data_loader_val,
            iou_types=iou_types,
            box_only=False,
            device=cfg.MODEL.DEVICE,
            expected_results=cfg.TEST.EXPECTED_RESULTS,
            expected_results_sigma_tol=cfg.TEST.EXPECTED_RESULTS_SIGMA_TOL,
            output_folder=output_folder,
        )
        synchronize()

    if get_rank() == 0:
        conn.send(results.results['bbox']['AP'])
        conn.close() 
開發者ID:megvii-model,項目名稱:DetNAS,代碼行數:55,代碼來源:test_server.py

示例14: train

# 需要導入模塊: from maskrcnn_benchmark import data [as 別名]
# 或者: from maskrcnn_benchmark.data import make_data_loader [as 別名]
def train(cfg, local_rank, distributed):
    model = build_detection_model(cfg)
    device = torch.device(cfg.MODEL.DEVICE)
    model.to(device)

    optimizer = make_optimizer(cfg, model)
    scheduler = make_lr_scheduler(cfg, optimizer)

    if distributed:
        model = torch.nn.parallel.DistributedDataParallel(
            model, device_ids=[local_rank], output_device=local_rank,
            # this should be removed if we update BatchNorm stats
            broadcast_buffers=False,
        )

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

    output_dir = cfg.OUTPUT_DIR

    save_to_disk = 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(  # clw note:創建數據集
        cfg,
        is_train=True,
        is_distributed=distributed,
        start_iter=arguments["iteration"],
    )

    checkpoint_period = cfg.SOLVER.CHECKPOINT_PERIOD

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

    return model 
開發者ID:clw5180,項目名稱:remote_sensing_object_detection_2019,代碼行數:53,代碼來源:train_net.py

示例15: train

# 需要導入模塊: from maskrcnn_benchmark import data [as 別名]
# 或者: from maskrcnn_benchmark.data import make_data_loader [as 別名]
def train(cfg, local_rank, distributed):
    model = build_detection_model(cfg)
    device = torch.device(cfg.MODEL.DEVICE)
    model.to(device)
    if cfg.SOLVER.ENABLE_FP16:
        model.half()

    optimizer = make_optimizer(cfg, model)
    scheduler = make_lr_scheduler(cfg, optimizer)

    if distributed:
        model = torch.nn.parallel.DistributedDataParallel(
            model, device_ids=[local_rank], output_device=local_rank,
            # this should be removed if we update BatchNorm stats
            # broadcast_buffers=False,
        )
    arguments = {}
    arguments["iteration"] = 0

    output_dir = cfg.OUTPUT_DIR

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

    data_loader = make_data_loader(
        cfg,
        is_train=True,
        is_distributed=distributed,
        start_iter=arguments["iteration"],
    )

    checkpoint_period = cfg.SOLVER.CHECKPOINT_PERIOD

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

    return model 
開發者ID:HRNet,項目名稱:HRNet-MaskRCNN-Benchmark,代碼行數:53,代碼來源:train_net.py


注:本文中的maskrcnn_benchmark.data.make_data_loader方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。