本文整理汇总了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
示例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()
示例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
示例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
示例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
示例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
示例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
示例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