示例#1
0
 def post_process(self, dets, meta, scale=1):
     dets = dets.detach().cpu().numpy().reshape(1, -1, dets.shape[2])
     dets = multi_pose_post_process(dets.copy(), [meta['c']], [meta['s']],
                                    meta['out_height'], meta['out_width'])
     for j in range(1, self.num_classes + 1):
         dets[0][j] = np.array(dets[0][j], dtype=np.float32).reshape(-1, 56)
         dets[0][j][:, :4] /= scale
         dets[0][j][:, 5:39] /= scale
     return dets[0]
示例#2
0
 def post_process(self, dets, meta, scale=1):
     # print('-------->>> post_process')
     dets = dets.detach().cpu().numpy().reshape(1, -1, dets.shape[2])
     dets = multi_pose_post_process(dets.copy(), [meta['c']], [meta['s']],
                                    meta['out_height'], meta['out_width'])
     for j in range(1, self.num_classes + 1):
         dets[0][j] = np.array(dets[0][j], dtype=np.float32).reshape(-1, 39)
         # import pdb; pdb.set_trace()
         dets[0][j][:, :4] /= scale
         dets[0][j][:, 5:] /= scale
     return dets[0]
示例#3
0
 def post_process(self, dets, meta, scale=1):  # 1*100*40
     dets = dets.detach().cpu().numpy().reshape(
         1, -1, dets.shape[2])  # dets:dets: (1,100,40)
     dets = multi_pose_post_process(  # [{1:1*100*39}]
         dets.copy(), [meta['c']], [meta['s']], meta['out_height'],
         meta['out_width'])
     for j in range(1, self.num_classes + 1):
         dets[0][j] = np.array(dets[0][j],
                               dtype=np.float32).reshape(-1, 39)  # 100*39
         # import pdb; pdb.set_trace()
         dets[0][j][:, :4] /= scale  #
         dets[0][j][:, 5:] /= scale  #
     return dets[0]
示例#4
0
 def save_result(self, output, batch, results):
   reg = output['reg'] if self.opt.reg_offset else None
   hm_hp = output['hm_hp'] if self.opt.hm_hp else None
   hp_offset = output['hp_offset'] if self.opt.reg_hp_offset else None
   dets = multi_pose_decode(
     output['hm'], output['wh'], output['hps'], 
     reg=reg, hm_hp=hm_hp, hp_offset=hp_offset, K=self.opt.K)
   dets = dets.detach().cpu().numpy().reshape(1, -1, dets.shape[2])
   
   dets_out = multi_pose_post_process(
     dets.copy(), batch['meta']['c'].cpu().numpy(),
     batch['meta']['s'].cpu().numpy(),
     output['hm'].shape[2], output['hm'].shape[3])
   results[batch['meta']['img_id'].cpu().numpy()[0]] = dets_out[0]
示例#5
0
    def save_result(self, output, batch, results):
        reg = output[3] if self.cfg.LOSS.REG_OFFSET else None
        hm_hp = output[4] if self.cfg.LOSS.HM_HP else None
        hp_offset = output[5] if self.cfg.LOSS.REG_HP_OFFSET else None
        dets = multi_pose_decode(
          output[0], output[1], output[2], 
          reg=reg, hm_hp=hm_hp, hp_offset=hp_offset, K=self.cfg.TEST.TOPK)
        dets = dets.detach().cpu().numpy().reshape(1, -1, dets.shape[2])

        dets_out = multi_pose_post_process(
          dets.copy(), batch['meta']['c'].cpu().numpy(),
          batch['meta']['s'].cpu().numpy(),
          output[0].shape[2], output[0].shape[3])
        results[batch['meta']['img_id'].cpu().numpy()[0]] = dets_out[0]
示例#6
0
 def post_process(self, dets, meta, scale=1):
   dets = dets.detach().cpu().numpy().reshape(1, -1, dets.shape[2])
   dets = multi_pose_post_process(
     dets.copy(), [meta['c']], [meta['s']],
     meta['out_height'], meta['out_width'],self.opt.down_ratio)
   for j in range(1, self.num_classes + 1):
     l = 39
     if self.opt.mdn:
       l += 42 if self.opt.flip_test or self.opt.flip_test_max  else 40
     dets[0][j] = np.array(dets[0][j], dtype=np.float32).reshape(-1, l)
     # import pdb; pdb.set_trace()
     dets[0][j][:, :4] /= scale
     dets[0][j][:, 5:39] /= scale
     if self.opt.mdn:
       if self.opt.flip_test or self.opt.flip_test_max:
         dets[0][j][:, 43:81] /= scale
       else:
         dets[0][j][:, 41:79] /= scale
   return dets[0]
示例#7
0
    def save_result(self, output, batch, results):
        opt = self.opt
        if opt.task == 'ctdet':
            reg = output['reg'] if self.opt.reg_offset else None
            dets = ctdet_decode(output['hm'],
                                output['wh'],
                                reg=reg,
                                cat_spec_wh=self.opt.cat_spec_wh,
                                K=self.opt.K)
            dets = dets.detach().cpu().numpy().reshape(1, -1, dets.shape[2])
            dets_out = ctdet_post_process(dets.copy(),
                                          batch['meta']['c'].cpu().numpy(),
                                          batch['meta']['s'].cpu().numpy(),
                                          output['hm'].shape[2],
                                          output['hm'].shape[3],
                                          output['hm'].shape[1])
            results[batch['meta']['img_id'].cpu().numpy()[0]] = dets_out[0]

        elif opt.task == 'multi_pose':
            reg = output['reg'] if self.opt.reg_offset else None
            hm_hp = output['hm_hp'] if self.opt.hm_hp else None
            hp_offset = output['hp_offset'] if self.opt.reg_hp_offset else None
            dets = multi_pose_decode(output['hm'],
                                     output['wh'],
                                     output['hps'],
                                     reg=reg,
                                     hm_hp=hm_hp,
                                     hp_offset=hp_offset,
                                     K=self.opt.K)
            dets = dets.detach().cpu().numpy().reshape(1, -1, dets.shape[2])

            dets_out = multi_pose_post_process(
                dets.copy(), batch['meta']['c'].cpu().numpy(),
                batch['meta']['s'].cpu().numpy(), output['hm'].shape[2],
                output['hm'].shape[3])
            results[batch['meta']['img_id'].cpu().numpy()[0]] = dets_out[0]

        else:
            assert 0, 'task not defined!'