javiribera / locating-objects-without-bboxes

PyTorch code for "Locating objects without bounding boxes" - Loss function and trained models
Other
249 stars 52 forks source link

Mismatch of tensor in WHD forward? #49

Open zlyin opened 2 years ago

zlyin commented 2 years ago

Hello Javier, I'm trying to understand your WHD forward function, but fail to understand the dimension of normalized_y.

            # One by one
            prob_map_b = prob_map[b, :, :]
            gt_b = gt[b]
            orig_size_b = orig_sizes[b, :]
            norm_factor = (orig_size_b/self.resized_size).unsqueeze(0)

            # Pairwise distances between all possible locations and the GTed locations
            n_gt_pts = gt_b.size()[0]
            normalized_x = norm_factor.repeat(self.n_pixels, 1) * self.all_img_locations
            normalized_y = norm_factor.repeat(len(gt_b), 1) * gt_b
            d_matrix = cdist(normalized_x, normalized_y)

From my understanding, gt_b.size() = [H, W], normal_factor.size = (1, 2), then n_gt_pts = H; self.all_img_locations.size() = [HxW, 2] which leads to normalized_x.size() = [HxW, 2] ;

Then, here comes my puzzle. norm_factor.repeat(len(gt_b), 1) gives me [B, 2], but gt_b.size() = [H, W], how to multiply these 2 tensors?? Did you use some special reshape operations here?

Thank you!