def decode_detection(self, output, h, w): ct_hm = output['ct_hm'] wh = output['wh'] ct, detection = snake_decode.decode_ct_hm(torch.sigmoid(ct_hm), wh) detection[..., :4] = data_utils.clip_to_image(detection[..., :4], h, w) output.update({'ct': ct, 'detection': detection}) return ct, detection
def decode_ext_hm(ext_hm, bbox, vote, ct): h, w = ext_hm.size(2), ext_hm.size(3) ext_hm = nms(ext_hm) bbox = data_utils.clip_to_image(bbox, h, w) radius = gaussian_radius(bbox[..., 2] - bbox[..., 0], bbox[..., 3] - bbox[..., 1]) bbox = torch.round(bbox).long() extreme_point = extreme_utils.collect_extreme_point(ext_hm, bbox, radius, vote.permute(0, 2, 3, 1), ct) return extreme_point
def decode_detection(self, output, h, w): ct_hm = output['ct_hm'] wh = output['wh'] if cfg.train.ct_reg: ct_reg = output['reg'] nms_ct_hm, ct, detection = snake_decode.decode_ct_hm( torch.sigmoid(ct_hm), wh, ct_reg) else: nms_ct_hm, ct, detection = snake_decode.decode_ct_hm( torch.sigmoid(ct_hm), wh) detection[..., :4] = data_utils.clip_to_image(detection[..., :4], h, w) output.update({ 'ct': ct, 'detection': detection, 'nms_ct_hm': nms_ct_hm }) return ct, detection