Skip to content

Commit

Permalink
Pr 1679 (#1687)
Browse files Browse the repository at this point in the history
* Adds error message to the add_label_fields_to_data function.

When the lengths os bboxes and labels mismatch, raise the ValueError with a proper error message.

* Fixed minor error to enable merging of PR #1679

---------

Co-authored-by: Wilder Rodrigues <wilder.rodrigues@gmail.com>
  • Loading branch information
ternaus and wilderrodrigues committed Apr 25, 2024
1 parent cba0fa4 commit bbe1854
Showing 1 changed file with 4 additions and 1 deletion.
5 changes: 4 additions & 1 deletion albumentations/core/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -133,7 +133,10 @@ def add_label_fields_to_data(self, data: Dict[str, Any]) -> Dict[str, Any]:
for data_name in self.data_fields:
for field in self.params.label_fields:
if not len(data[data_name]) == len(data[field]):
raise ValueError
raise ValueError(
f"The lengths of bboxes and labels do not match. Got {len(data[data_name])} "
f"and {len(data[field])} respectively.",
)

data_with_added_field = []
for d, field_value in zip(data[data_name], data[field]):
Expand Down

0 comments on commit bbe1854

Please sign in to comment.