The new release of albumentations 0.5.0 introduced breaking changes, the error is currently being avoided by specifying a version lower than 0.5.0 in setup.cfg
How to reproduce
Update albumentations and run: pytest tests/transforms/test_albu_transform.py
Stracktrace
internal_data_name = 'masks'
def _check_args(self, **kwargs):
checked_single = ["image", "mask"]
checked_multi = ["masks"]
# ["bboxes", "keypoints"] could be almost any type, no need to check them
for data_name, data in kwargs.items():
internal_data_name = self.additional_targets.get(data_name, data_name)
if internal_data_name in checked_single:
if not isinstance(data, np.ndarray):
raise TypeError("{} must be numpy array type".format(data_name))
if internal_data_name in checked_multi:
> if data:
E ValueError: The truth value of an array with more than one element is ambiguous. Use a.any() or a.all()
/opt/hostedtoolcache/Python/3.6.12/x64/lib/python3.6/site-packages/albumentations/core/composition.py:223: ValueError
I think I might benefit from learning how to effectively debug, so I can take this one if you accept.
Thanks Francesco!!! You're on fire 馃敟
I think I found the culprit.
The problem is in the tfms applied to masks.
This line should look like params["masks"] = list(masks.data).
In the albumentations docs they specify that masks needs to be a list (here).
I made the edit and now tests are passing.
Before I create a PR, does this make sense to you?
Also, not sure how to handle the dependency.
Assuming the fix works, shall we also edit this line removing the <0.5 constraint?
I mean, in the same PR.
I also tested the change (e.g. params["masks"] = list(masks.data)) with albumentations version 0.4.6 and it still works, so it looks backwards compatible.
This line should look like params["masks"] = list(masks.data)
Interesting, for some reason they decided not to accept a numpy array anymore?
Before I create a PR, does this make sense to you?
Yeah yeah! To get the tests passing were the only thing required on this one
I mean, in the same PR.
Yes, both changes in the same PR, but instead of removing the condition put it <0.6, so it doesn't break unexpectedly in the future
PR created!
Most helpful comment
I also tested the change (e.g.
params["masks"] = list(masks.data)) withalbumentationsversion0.4.6and it still works, so it looks backwards compatible.