From d0a15c54d71ca0e57a712d96b25878c079e3a919 Mon Sep 17 00:00:00 2001 From: Fansure Grin <47016740+fansuregrin@users.noreply.github.com> Date: Mon, 10 Jul 2023 21:32:48 +0800 Subject: [PATCH 1/4] Update _utils.py Correct the example of `gt_pred_pairs_of_highest_quality`. `torch.where(condition)` is identical to `torch.nonzero(condition, as_tuple=True)`. So the `gt_pred_pairs_of_highest_quality` is a tuple of LongTensor. --- torchvision/models/detection/_utils.py | 13 ++----------- 1 file changed, 2 insertions(+), 11 deletions(-) diff --git a/torchvision/models/detection/_utils.py b/torchvision/models/detection/_utils.py index a25bdc1d42c..8f288433eee 100644 --- a/torchvision/models/detection/_utils.py +++ b/torchvision/models/detection/_utils.py @@ -408,17 +408,8 @@ def set_low_quality_matches_(self, matches: Tensor, all_matches: Tensor, match_q # Find the highest quality match available, even if it is low, including ties gt_pred_pairs_of_highest_quality = torch.where(match_quality_matrix == highest_quality_foreach_gt[:, None]) # Example gt_pred_pairs_of_highest_quality: - # tensor([[ 0, 39796], - # [ 1, 32055], - # [ 1, 32070], - # [ 2, 39190], - # [ 2, 40255], - # [ 3, 40390], - # [ 3, 41455], - # [ 4, 45470], - # [ 5, 45325], - # [ 5, 46390]]) - # Each row is a (gt index, prediction index) + # (tensor([0, 1, 1, 2, 2, 3, 3, 4, 5, 5]), tensor([39796, 32055, 32070, 39190, 40255, 40390, 41455, 45470, 45325, 46390])) + # Each element in the first tensor is a gt index, and each element in second tensor is a prediction index # Note how gt items 1, 2, 3, and 5 each have two ties pred_inds_to_update = gt_pred_pairs_of_highest_quality[1] From 79a3691117afc99f33266e8f96a8e21c34ef2d08 Mon Sep 17 00:00:00 2001 From: Fansure Grin <47016740+fansuregrin@users.noreply.github.com> Date: Mon, 10 Jul 2023 23:23:21 +0800 Subject: [PATCH 2/4] Fix the confusing example of `gt_pred_pairs_of_highest_quality` --- torchvision/models/detection/_utils.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/torchvision/models/detection/_utils.py b/torchvision/models/detection/_utils.py index 8f288433eee..6b04b3248ce 100644 --- a/torchvision/models/detection/_utils.py +++ b/torchvision/models/detection/_utils.py @@ -408,7 +408,8 @@ def set_low_quality_matches_(self, matches: Tensor, all_matches: Tensor, match_q # Find the highest quality match available, even if it is low, including ties gt_pred_pairs_of_highest_quality = torch.where(match_quality_matrix == highest_quality_foreach_gt[:, None]) # Example gt_pred_pairs_of_highest_quality: - # (tensor([0, 1, 1, 2, 2, 3, 3, 4, 5, 5]), tensor([39796, 32055, 32070, 39190, 40255, 40390, 41455, 45470, 45325, 46390])) + # (tensor([0, 1, 1, 2, 2, 3, 3, 4, 5, 5]), + #. tensor([39796, 32055, 32070, 39190, 40255, 40390, 41455, 45470, 45325, 46390])) # Each element in the first tensor is a gt index, and each element in second tensor is a prediction index # Note how gt items 1, 2, 3, and 5 each have two ties From 08503adf24722c1fe4984f4c2be803641af3de49 Mon Sep 17 00:00:00 2001 From: Fansure Grin <47016740+fansuregrin@users.noreply.github.com> Date: Mon, 10 Jul 2023 23:29:18 +0800 Subject: [PATCH 3/4] Fix the confusing example of gt_pred_pairs_of_highest_quality --- torchvision/models/detection/_utils.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/torchvision/models/detection/_utils.py b/torchvision/models/detection/_utils.py index 6b04b3248ce..8bf90b539de 100644 --- a/torchvision/models/detection/_utils.py +++ b/torchvision/models/detection/_utils.py @@ -409,7 +409,7 @@ def set_low_quality_matches_(self, matches: Tensor, all_matches: Tensor, match_q gt_pred_pairs_of_highest_quality = torch.where(match_quality_matrix == highest_quality_foreach_gt[:, None]) # Example gt_pred_pairs_of_highest_quality: # (tensor([0, 1, 1, 2, 2, 3, 3, 4, 5, 5]), - #. tensor([39796, 32055, 32070, 39190, 40255, 40390, 41455, 45470, 45325, 46390])) + # tensor([39796, 32055, 32070, 39190, 40255, 40390, 41455, 45470, 45325, 46390])) # Each element in the first tensor is a gt index, and each element in second tensor is a prediction index # Note how gt items 1, 2, 3, and 5 each have two ties From f3a6799ac46c1caf46e8aa157a546c52b6e6db26 Mon Sep 17 00:00:00 2001 From: Nicolas Hug Date: Tue, 11 Jul 2023 09:57:25 +0100 Subject: [PATCH 4/4] Update torchvision/models/detection/_utils.py --- torchvision/models/detection/_utils.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/torchvision/models/detection/_utils.py b/torchvision/models/detection/_utils.py index 8bf90b539de..559db858ac3 100644 --- a/torchvision/models/detection/_utils.py +++ b/torchvision/models/detection/_utils.py @@ -408,8 +408,8 @@ def set_low_quality_matches_(self, matches: Tensor, all_matches: Tensor, match_q # Find the highest quality match available, even if it is low, including ties gt_pred_pairs_of_highest_quality = torch.where(match_quality_matrix == highest_quality_foreach_gt[:, None]) # Example gt_pred_pairs_of_highest_quality: - # (tensor([0, 1, 1, 2, 2, 3, 3, 4, 5, 5]), - # tensor([39796, 32055, 32070, 39190, 40255, 40390, 41455, 45470, 45325, 46390])) + # (tensor([0, 1, 1, 2, 2, 3, 3, 4, 5, 5]), + # tensor([39796, 32055, 32070, 39190, 40255, 40390, 41455, 45470, 45325, 46390])) # Each element in the first tensor is a gt index, and each element in second tensor is a prediction index # Note how gt items 1, 2, 3, and 5 each have two ties