Skip to content
This repository has been archived by the owner on Oct 31, 2023. It is now read-only.

Raise error if no GT or proposals available during training #37

Merged
merged 1 commit into from
Dec 4, 2018
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 9 additions & 3 deletions maskrcnn_benchmark/modeling/matcher.py
Original file line number Diff line number Diff line change
Expand Up @@ -51,9 +51,15 @@ def __call__(self, match_quality_matrix):
be matched.
"""
if match_quality_matrix.numel() == 0:
# handle empty case
device = match_quality_matrix.device
return torch.empty((0,), dtype=torch.int64, device=device)
# empty targets or proposals not supported during training
if match_quality_matrix.shape[0] == 0:
raise ValueError(
"No ground-truth boxes available for one of the images "
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

make it tell the user which image / filename if possible. otherwise it becomes a bit of a nightmare to track back

Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I agree with @soumith

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I agree as well, but for the image names to be displayed in the error message means that the assert would need to be applied in the user code as well, when they create a new Dataset class

"during training")
else:
raise ValueError(
"No proposal boxes available for one of the images "
"during training")

# match_quality_matrix is M (gt) x N (predicted)
# Max over gt elements (dim 0) to find best gt candidate for each prediction
Expand Down