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


Python mmcv.ProgressBar方法代碼示例

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


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

示例1: single_gpu_test

# 需要導入模塊: import mmcv [as 別名]
# 或者: from mmcv import ProgressBar [as 別名]
def single_gpu_test(model, data_loader, show=False):
    model.eval()
    results = []
    dataset = data_loader.dataset
    prog_bar = mmcv.ProgressBar(len(dataset))
    for i, data in enumerate(data_loader):
        with torch.no_grad():
            result = model(return_loss=False, rescale=not show, **data)

        if show:
            model.module.show_result(data, result, dataset.img_norm_cfg)

        # encode mask results
        if isinstance(result, tuple):
            bbox_results, mask_results = result
            encoded_mask_results = encode_mask_results(mask_results)
            result = bbox_results, encoded_mask_results
        results.append(result)

        batch_size = data['img'][0].size(0)
        for _ in range(batch_size):
            prog_bar.update()
    return results 
開發者ID:open-mmlab,項目名稱:mmdetection,代碼行數:25,代碼來源:test_robustness.py

示例2: main

# 需要導入模塊: import mmcv [as 別名]
# 或者: from mmcv import ProgressBar [as 別名]
def main():
    args = parse_args()
    cfg = retrieve_data_cfg(args.config, args.skip_type)

    dataset = build_dataset(cfg.data.train)

    progress_bar = mmcv.ProgressBar(len(dataset))
    for item in dataset:
        filename = os.path.join(args.output_dir,
                                Path(item['filename']).name
                                ) if args.output_dir is not None else None
        mmcv.imshow_det_bboxes(
            item['img'],
            item['gt_bboxes'],
            item['gt_labels'] - 1,
            class_names=dataset.CLASSES,
            show=not args.not_show,
            out_file=filename,
            wait_time=args.show_interval)
        progress_bar.update() 
開發者ID:open-mmlab,項目名稱:mmdetection,代碼行數:22,代碼來源:browse_dataset.py

示例3: single_gpu_test

# 需要導入模塊: import mmcv [as 別名]
# 或者: from mmcv import ProgressBar [as 別名]
def single_gpu_test(model, data_loader, show=False):
    model.eval()
    results = []
    dataset = data_loader.dataset
    prog_bar = mmcv.ProgressBar(len(dataset))
    for i, data in enumerate(data_loader):
        with torch.no_grad():
            result = model(return_loss=False, rescale=not show, **data)
        results.append(result)

        if show:
            model.module.show_result(data, result, dataset.img_norm_cfg)

        batch_size = data['img'][0].size(0)
        for _ in range(batch_size):
            prog_bar.update()
    return results 
開發者ID:dingjiansw101,項目名稱:AerialDetection,代碼行數:19,代碼來源:test_robustness.py

示例4: multi_gpu_test

# 需要導入模塊: import mmcv [as 別名]
# 或者: from mmcv import ProgressBar [as 別名]
def multi_gpu_test(model, data_loader, tmpdir=None):
    model.eval()
    results = []
    dataset = data_loader.dataset
    rank, world_size = get_dist_info()
    if rank == 0:
        prog_bar = mmcv.ProgressBar(len(dataset))
    for i, data in enumerate(data_loader):
        with torch.no_grad():
            result = model(return_loss=False, rescale=True, **data)
        results.append(result)

        if rank == 0:
            batch_size = data['img'][0].size(0)
            for _ in range(batch_size * world_size):
                prog_bar.update()

    # collect results from all ranks
    results = collect_results(results, len(dataset), tmpdir)

    return results 
開發者ID:dingjiansw101,項目名稱:AerialDetection,代碼行數:23,代碼來源:test_robustness.py

示例5: single_gpu_test

# 需要導入模塊: import mmcv [as 別名]
# 或者: from mmcv import ProgressBar [as 別名]
def single_gpu_test(model, data_loader, show=False, log_dir=None):
    model.eval()
    results = []
    dataset = data_loader.dataset
    if log_dir != None:
        filename = 'inference{}.log'.format(get_time_str())
        log_file = osp.join(log_dir, filename)
        f = open(log_file, 'w')
        prog_bar = mmcv.ProgressBar(len(dataset), file=f)
    else:
        prog_bar = mmcv.ProgressBar(len(dataset))
    for i, data in enumerate(data_loader):
        with torch.no_grad():
            result = model(return_loss=False, rescale=not show, **data)
        results.append(result)

        if show:
            model.module.show_result(data, result, dataset.img_norm_cfg)

        batch_size = data['img'][0].size(0)
        for _ in range(batch_size):
            prog_bar.update()

    return results 
開發者ID:dingjiansw101,項目名稱:AerialDetection,代碼行數:26,代碼來源:test.py

示例6: single_gpu_test

# 需要導入模塊: import mmcv [as 別名]
# 或者: from mmcv import ProgressBar [as 別名]
def single_gpu_test(model, data_loader, show=False):
    model.eval()
    results = []
    dataset = data_loader.dataset
    prog_bar = mmcv.ProgressBar(len(dataset))
    for i, data in enumerate(data_loader):
        with torch.no_grad():
            result = model(return_loss=False, rescale=not show, **data)
        results.append(result)

        if show:
            model.module.show_result(data, result)

        batch_size = data['img'][0].size(0)
        for _ in range(batch_size):
            prog_bar.update()
    return results 
開發者ID:tascj,項目名稱:kaggle-kuzushiji-recognition,代碼行數:19,代碼來源:test.py

示例7: single_gpu_test

# 需要導入模塊: import mmcv [as 別名]
# 或者: from mmcv import ProgressBar [as 別名]
def single_gpu_test(model, data_loader, show=False):
    model.eval()
    results = []
    dataset = data_loader.dataset
    prog_bar = mmcv.ProgressBar(len(dataset))
    for i, data in enumerate(data_loader):
        with torch.no_grad():
            result = model(return_loss=False, rescale=not show, **data)
        results.append(result)

        if show:
            model.module.show_result(data, result, score_thr=0.3)

        batch_size = data['img'][0].size(0)
        for _ in range(batch_size):
            prog_bar.update()
    return results 
開發者ID:wangsr126,項目名稱:RDSNet,代碼行數:19,代碼來源:test.py

示例8: single_test

# 需要導入模塊: import mmcv [as 別名]
# 或者: from mmcv import ProgressBar [as 別名]
def single_test(model, data_loader, show=False):
    model.eval()
    results = []
    dataset = data_loader.dataset
    prog_bar = mmcv.ProgressBar(len(dataset))
    for i, data in enumerate(data_loader):
        with torch.no_grad():
            result = model(return_loss=False, rescale=not show, **data)
        results.append(result)

        if show:
            model.module.show_result(data, result, dataset.img_norm_cfg,
                                     dataset='vg', score_thr=0.4, save_num='work_dirs/fpn_hkrm/0.3_vghkrm_%08d'%i + '.jpg')
                                     # dataset=dataset.CLASSES)

        batch_size = data['img'][0].size(0)
        for _ in range(batch_size):
            prog_bar.update()
    return results 
開發者ID:chanyn,項目名稱:Reasoning-RCNN,代碼行數:21,代碼來源:test.py


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