(self, targets)
| 2659 | nn.init.constant_(proj[0].bias, 0) |
| 2660 | |
| 2661 | def prepare_for_dn2(self, targets): |
| 2662 | if not self.training: |
| 2663 | device = targets[0]['boxes'].device |
| 2664 | bs = len(targets) |
| 2665 | |
| 2666 | num_points = 4 |
| 2667 | attn_mask2 = torch.zeros( |
| 2668 | bs, |
| 2669 | self.nheads, |
| 2670 | self.num_group * 4, |
| 2671 | self.num_group * 4, |
| 2672 | device=device, |
| 2673 | dtype=torch.bool) |
| 2674 | |
| 2675 | group_bbox_kpt = 4 |
| 2676 | # body bbox index |
| 2677 | kpt_index = [x for x in range(self.num_group * 4) if x % 4 in [0]] |
| 2678 | |
| 2679 | for matchj in range(self.num_group * 4): |
| 2680 | sj = (matchj // group_bbox_kpt) * group_bbox_kpt |
| 2681 | ej = (matchj // group_bbox_kpt + 1)*group_bbox_kpt |
| 2682 | |
| 2683 | # for each instance, they should associate with their query (body hand face) |
| 2684 | if sj > 0: |
| 2685 | attn_mask2[:, :, matchj, :sj] = True |
| 2686 | if ej < self.num_group * 4: |
| 2687 | attn_mask2[:, :, matchj, ej:] = True |
| 2688 | |
| 2689 | for match_x in range(self.num_group * 4): |
| 2690 | if match_x % group_bbox_kpt in [0, 1, 2, 3]: |
| 2691 | # each query (hand face body) should associate with all body query |
| 2692 | attn_mask2[:,:,match_x, kpt_index]=False |
| 2693 | |
| 2694 | num_points = 4 |
| 2695 | attn_mask3 = torch.zeros( |
| 2696 | bs, |
| 2697 | self.nheads, |
| 2698 | self.num_group * 4, |
| 2699 | self.num_group * 4, |
| 2700 | device=device, |
| 2701 | dtype=torch.bool) |
| 2702 | |
| 2703 | group_bbox_kpt = 4 |
| 2704 | kpt_index = [x for x in range(self.num_group * 4) if x % 4 in [0]] |
| 2705 | for matchj in range(self.num_group * 4): |
| 2706 | sj = (matchj // group_bbox_kpt) * group_bbox_kpt |
| 2707 | ej = (matchj // group_bbox_kpt + 1)*group_bbox_kpt |
| 2708 | # for each instance, they should associate with their query (body hand face) |
| 2709 | if sj > 0: |
| 2710 | attn_mask3[:, :, matchj, :sj] = True |
| 2711 | if ej < self.num_group * 4: |
| 2712 | attn_mask3[:, :, matchj, ej:] = True |
| 2713 | |
| 2714 | for match_x in range(self.num_group * 4): |
| 2715 | if match_x % group_bbox_kpt in [0, 1, 2, 3]: |
| 2716 | # each query (hand face body) should associate with all body query |
| 2717 | attn_mask3[:, :, match_x, kpt_index] = False |
| 2718 |
no test coverage detected