RandomShadow input type wrong
See original GitHub issue🐛 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
Issue Analytics
- State:
- Created 3 years ago
- Reactions:1
- Comments:15 (1 by maintainers)
Top Results From Across the Web
Transforms (augmentations.transforms) - Albumentations
Take an input array where all values should lie in the range [0, 1.0], multiply them by max_value and then cast the resulted...
Read more >Prevent Wrong Input in JS After Submitting A Form
I am creating a sample MabLibs type thing in HTML and JS. When the person inputs stuff in a field, it will use...
Read more >4k round, Descendant set, acolyte lvl 5. Unoptimized, random ...
Unoptimized, random shadow attack spam lol ... I suggest using Catalyst instead just in case the shadow form ended prematurely.
Read more >albumentations - PyPI
The library provides a simple unified API to work with all data types: images ... Pixel-level transforms will change just an input image...
Read more >fastai.pdf
Add 'n_dim' channels at the end of the input. ... Transform the categorical variables to that type. ... RandomShadow. Description.
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
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#L97