albumentations: RandomShadow input type wrong
π Bug
Weather transformation. For RandomRain, RandomSnow, RandomSunFlare the inputs are just numpy uint8. However, RandomShadow does not allow the same input format.
To Reproduce
albu_shadow = albu.RandomShadow(p=1, num_shadows_lower=1, num_shadows_upper=1, shadow_dimension=5, shadow_roi=(0, 0.5, 1, 1))
x_np = albu_shadow(image=x_np)['image']
Error:
TypeError: Expected Ptr<cv::UMat> for argument img
Expected behavior
It should take the same uint8 numpy array as input.
Environment
- Albumentations version: 0.4.5
- Python version: 3.7.6
- OS (e.g., Linux): Linux
- How you installed albumentations: pip
About this issue
- Original URL
- State: closed
- Created 4 years ago
- Reactions: 1
- Comments: 15 (1 by maintainers)
Very interesting. Problem how pytorch, numpy and OpenCV share memory. Until we find solution how to resolve problem you can use this fix to avoid problem:
You need directly create numpy copy of image before provide it into albumentations transfromation
Good point! Thank you for your comment. I reproduced that problem in the last version. I think we could resolve this problem by just adding
np.ascontiguousarray
for the image there https://github.com/albumentations-team/albumentations/blob/master/albumentations/core/transforms_interface.py#L97Please provide a minimal code snippet to reproduce the issue.
Π²Ρ, 5 ΠΌΠ°Ρ 2020 Π³. Π² 11:59 AM, Tsun-Yi Yang notifications@github.com: