(self, batch, output, iter_id)
| 51 | return loss_states, loss |
| 52 | |
| 53 | def debug(self, batch, output, iter_id): |
| 54 | opt = self.opt |
| 55 | detections = self.decode(output['hm_t'], output['hm_l'], |
| 56 | output['hm_b'], output['hm_r'], |
| 57 | output['hm_c']).detach().cpu().numpy() |
| 58 | detections[:, :, :4] *= opt.input_res / opt.output_res |
| 59 | for i in range(1): |
| 60 | debugger = Debugger( |
| 61 | dataset=opt.dataset, ipynb=(opt.debug==3), theme=opt.debugger_theme) |
| 62 | pred_hm = np.zeros((opt.input_res, opt.input_res, 3), dtype=np.uint8) |
| 63 | gt_hm = np.zeros((opt.input_res, opt.input_res, 3), dtype=np.uint8) |
| 64 | img = batch['input'][i].detach().cpu().numpy().transpose(1, 2, 0) |
| 65 | img = ((img * self.opt.std + self.opt.mean) * 255.).astype(np.uint8) |
| 66 | for p in self.parts: |
| 67 | tag = 'hm_{}'.format(p) |
| 68 | pred = debugger.gen_colormap(output[tag][i].detach().cpu().numpy()) |
| 69 | gt = debugger.gen_colormap(batch[tag][i].detach().cpu().numpy()) |
| 70 | if p != 'c': |
| 71 | pred_hm = np.maximum(pred_hm, pred) |
| 72 | gt_hm = np.maximum(gt_hm, gt) |
| 73 | if p == 'c' or opt.debug > 2: |
| 74 | debugger.add_blend_img(img, pred, 'pred_{}'.format(p)) |
| 75 | debugger.add_blend_img(img, gt, 'gt_{}'.format(p)) |
| 76 | debugger.add_blend_img(img, pred_hm, 'pred') |
| 77 | debugger.add_blend_img(img, gt_hm, 'gt') |
| 78 | debugger.add_img(img, img_id='out') |
| 79 | for k in range(len(detections[i])): |
| 80 | if detections[i, k, 4] > 0.1: |
| 81 | debugger.add_coco_bbox(detections[i, k, :4], detections[i, k, -1], |
| 82 | detections[i, k, 4], img_id='out') |
| 83 | if opt.debug == 4: |
| 84 | debugger.save_all_imgs(opt.debug_dir, prefix='{}'.format(iter_id)) |
| 85 | else: |
| 86 | debugger.show_all_imgs(pause=True) |
nothing calls this directly
no test coverage detected