Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

The max distance in Weighted Hausdorff Loss is not the actual max distance #48

Open
donguklim opened this issue Jul 5, 2022 · 0 comments

Comments

@donguklim
Copy link

donguklim commented Jul 5, 2022

The maximum possible distance is calculated with resized image size.

self.max_dist = math.sqrt(resized_height**2 + resized_width**2)

But this should be calculated with the original image size, as bellow code also calculates distances in the original image.

Bellow two lines need to be changed

weighted_d_matrix = (1 - p_replicated)*self.max_dist + p_replicated*d_matrix

terms_2.append(torch.tensor([self.max_dist],

Suggested change

            max_dist = (orig_size_b **2).sum().sqrt()
....
            # Corner case: no GT points
            if gt_b.ndimension() == 1 and (gt_b < 0).all().item() == 0:
                terms_1.append(torch.tensor([0],
                                            dtype=torch.get_default_dtype()))
                terms_2.append(torch.tensor([max_dist],
                                            dtype=torch.get_default_dtype()))
                continue
.....
            weighted_d_matrix = (1 - p_replicated)*max_dist  + p_replicated*d_matrix

I am sorry, too lazy to make pull request to fix it by myself now.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant