MCPcopy
hub / github.com/xingyizhou/CenterNet / debug

Method debug

src/lib/detectors/exdet.py:57–83  ·  view source on GitHub ↗
(self, debugger, images, dets, output, scale=1)

Source from the content-addressed store, hash-verified

55 return output, dets
56
57 def debug(self, debugger, images, dets, output, scale=1):
58 detection = dets.detach().cpu().numpy().copy()
59 detection[:, :, :4] *= self.opt.down_ratio
60 for i in range(1):
61 inp_height, inp_width = images.shape[2], images.shape[3]
62 pred_hm = np.zeros((inp_height, inp_width, 3), dtype=np.uint8)
63 img = images[i].detach().cpu().numpy().transpose(1, 2, 0)
64 img = ((img * self.std + self.mean) * 255).astype(np.uint8)
65 parts = ['t', 'l', 'b', 'r', 'c']
66 for p in parts:
67 tag = 'hm_{}'.format(p)
68 pred = debugger.gen_colormap(
69 output[tag][i].detach().cpu().numpy(), (inp_height, inp_width))
70 if p != 'c':
71 pred_hm = np.maximum(pred_hm, pred)
72 else:
73 debugger.add_blend_img(
74 img, pred, 'pred_{}_{:.1f}'.format(p, scale))
75 debugger.add_blend_img(img, pred_hm, 'pred_{:.1f}'.format(scale))
76 debugger.add_img(img, img_id='out_{:.1f}'.format(scale))
77 for k in range(len(detection[i])):
78 # print('detection', detection[i, k, 4], detection[i, k])
79 if detection[i, k, 4] > 0.01:
80 # print('detection', detection[i, k, 4], detection[i, k])
81 debugger.add_coco_bbox(detection[i, k, :4], detection[i, k, -1],
82 detection[i, k, 4],
83 img_id='out_{:.1f}'.format(scale))
84
85 def post_process(self, dets, meta, scale=1):
86 out_width, out_height = meta['out_width'], meta['out_height']

Callers

nothing calls this directly

Calls 4

gen_colormapMethod · 0.80
add_blend_imgMethod · 0.80
add_imgMethod · 0.80
add_coco_bboxMethod · 0.80

Tested by

no test coverage detected