MCPcopy Create free account
hub / github.com/OpenGVLab/HumanBench / vis_one_from_batch

Function vis_one_from_batch

PATH/helper/vis_helper.py:37–72  ·  view source on GitHub ↗
(vis_list, range_low=0, range_high=1,
                       vis_height=140, vis_width=140, vis_channel=3, to_rgb=True, return_CHW=True)

Source from the content-addressed store, hash-verified

35
36
37def vis_one_from_batch(vis_list, range_low=0, range_high=1,
38 vis_height=140, vis_width=140, vis_channel=3, to_rgb=True, return_CHW=True):
39
40 vis_dict = dict()
41 for item in vis_list:
42 '''
43 vis_list = [{
44 'name': 'lap_adv',
45 'image': laplace_adv
46 }]
47 '''
48 vis_image = get_vis_data(item['image'], range_low, range_high, vis_height, vis_width, to_rgb=to_rgb)
49 vis_dict[item['name']] = vis_image
50
51 cnt = 0
52 for tag, item in vis_dict.items():
53 if item is not None:
54 cnt += 1
55
56 # adapt to visualize format
57 rst = np.zeros((vis_height, vis_width * cnt, vis_channel))
58 pos = 0
59 for tag, item in vis_dict.items():
60 if item is not None:
61 left = vis_width * pos
62 right = vis_width * (pos + 1)
63 rst[:, left: right] = item
64 cv2.putText(rst, tag, (left + 2, 15), cv2.FONT_HERSHEY_SIMPLEX, 0.4, (0, 255, 0), 1)
65 pos += 1
66
67 rst = rst.clip(0, 255).astype(np.uint8, copy=False)
68 if return_CHW:
69 # prepare for tensorboard [RGB, CHW]
70 rst = rst.transpose((2, 0, 1)) # HWC -> CHW
71
72 return rst
73
74
75def get_features_indices(feature_maps, topk=1):

Callers

nothing calls this directly

Calls 2

get_vis_dataFunction · 0.85
clipMethod · 0.80

Tested by

no test coverage detected