question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

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:closed
  • Created 3 years ago
  • Reactions:1
  • Comments:15 (1 by maintainers)

github_iconTop GitHub Comments

2reactions
Dipetcommented, May 5, 2020

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:

x_np = albu_shadow(image=x_np.astype(np.uint8).copy())['image']

You need directly create numpy copy of image before provide it into albumentations transfromation

1reaction
Dipetcommented, Oct 6, 2021

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

Read more comments on GitHub >

github_iconTop 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 >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found