예제 #1
0
파일: dota.py 프로젝트: dinglinghu/DRN2020
 def show_results(self, image, gts, dets, save_dir, img_name):
     debugger = Debugger(dataset='dota',
                         ipynb=(self.opt.debug == 3),
                         theme='white')
     debugger.add_img(image, img_name)
     for j in dets:
         for bbox in dets[j]:
             if bbox[5] > 0.01:
                 debugger.add_rbbox(bbox[:5],
                                    j - 1,
                                    bbox[5],
                                    img_id=img_name)
     for ann in gts:
         bbox = ann['rbbox']
         cat_id = ann['category_id']
         debugger.add_rbbox(bbox, cat_id - 1, 1, img_id=img_name, gt=True)
     save_dir = os.path.join(save_dir, 'voc_results')
     debugger.save_all_imgs(save_dir)
예제 #2
0
파일: rodet.py 프로젝트: dinglinghu/DRN2020
    def debug(self, batch, output, iter_id):
        opt = self.opt
        reg = output['reg'] if opt.reg_offset else None
        dets = rodet_decode(output['hm'],
                            output['wh'],
                            output['angle'],
                            reg=reg,
                            cat_spec_wh=opt.cat_spec_wh,
                            cat_spec_angle=opt.cat_spec_angle,
                            K=opt.K)
        dets = dets.detach().cpu().numpy().reshape(1, -1, dets.shape[2])
        dets[:, :, :4] *= opt.down_ratio

        # dets_gt_dense = rodet_decode(
        #   batch['hm'], batch['dense_wh'], batch['dense_angle'], reg=reg,
        #   cat_spec_wh=opt.cat_spec_wh, cat_spec_angle=opt.cat_spec_angle, K=opt.K)
        # dets_gt_dense = dets_gt_dense.detach().cpu().numpy().reshape(1, -1, dets_gt_dense.shape[2])
        # dets_gt_dense[:, :, :4] *= opt.down_ratio

        dets_gt = batch['meta']['gt_det'].numpy().reshape(1, -1, dets.shape[2])
        img_name = batch['meta']['img_name']
        dets_gt[:, :, :4] *= opt.down_ratio
        for i in range(1):
            debugger = Debugger(dataset=opt.dataset,
                                ipynb=(opt.debug == 3),
                                theme=opt.debugger_theme)
            img = batch['input'][i].detach().cpu().numpy().transpose(1, 2, 0)
            img = np.clip(((img * opt.std + opt.mean) * 255.), 0,
                          255).astype(np.uint8)
            pred = debugger.gen_colormap(
                output['hm'][i].detach().cpu().numpy())
            # gt_ang_mask = debugger.gen_colormap(batch['dense_angle_mask'][i].detach().cpu().numpy())
            # gt_ang = debugger.gen_colormap(batch['dense_angle'][i].detach().cpu().numpy())
            gt = debugger.gen_colormap(batch['hm'][i].detach().cpu().numpy())
            debugger.add_blend_img(img, pred, '{}_pred_hm'.format(img_name))
            # debugger.add_blend_img(img, gt_ang_mask, 'gt_angle_mask')
            # debugger.add_blend_img(img, gt_ang, 'gt_angle')
            debugger.add_blend_img(img, gt, '{}_gt_hm'.format(img_name))
            debugger.add_img(img, img_id='{}_out_pred'.format(img_name))
            for k in range(len(dets[i])):
                if dets[i, k, 5] > opt.center_thresh:
                    # print("pred dets add_rbbox=======================")
                    debugger.add_rbbox(dets[i, k, :5],
                                       dets[i, k, -1],
                                       dets[i, k, 5],
                                       show_txt=False,
                                       img_id='{}_out_pred'.format(img_name))

            # debugger.add_img(img, img_id='{}_dets_gt_dense'.format(img_name))
            # for k in range(len(dets_gt_dense[i])):
            #   if dets_gt_dense[i, k, 5] > opt.center_thresh:
            #     # print("pred dets add_rbbox=======================")
            #     debugger.add_rbbox(dets_gt_dense[i, k, :5], dets_gt_dense[i, k, -1],
            #                        dets_gt_dense[i, k, 5], show_txt=False, img_id='{}_dets_gt_dense'.format(img_name))

            debugger.add_img(img, img_id='{}_out_gt'.format(img_name))
            for k in range(len(dets_gt[i])):
                if dets_gt[i, k, 5] > opt.center_thresh:
                    # print("GT add_rbbox=======================")
                    # 说明add_rbbox(self, rbbox, cat, conf=1, show_txt=True, img_id='default')
                    # gt格式 gt_det.append([ct[0], ct[1], w, h, a, 1, cls_id])
                    debugger.add_rbbox(dets_gt[i, k, :5],
                                       dets_gt[i, k, -1],
                                       dets_gt[i, k, 5],
                                       show_txt=False,
                                       img_id='{}_out_gt'.format(img_name))

            if opt.debug == 4:
                debugger.save_all_imgs(opt.debug_dir,
                                       prefix='{}'.format(iter_id))
            else:
                debugger.show_all_imgs(pause=True)