Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Restore comaptibilty with skimage 0.19 & fix corruption determinism #27

Open
wants to merge 3 commits into
base: master
Choose a base branch
from

Conversation

erjel
Copy link

@erjel erjel commented Dec 16, 2024

Hi 👋 ,

thank you for providing imagecorruptions as open source package via github and via pypi!

I try to bring the (currently unmaintained) package imgaug back to live. Fortunately the original maintainer provided an extensive collection of test cases I can run and check for breaking changes.

imagecorruptions is one of the dependencies which changed it's behavior in the recent years. Mostly due to changes in upstream libraries and recent commits to this github repository.

supported scikit-image version

For a smooth transition between the (now 4 years old) imgaug 0.4.0 and an upcomming 0.4.1 I would like to support at skimage down to pre-0.19 times. Although the current master branch of imagecorruptions claims to support skimage down to version >= 0.15 the recent commits 2393c18 and 6b18b82 broke that compatibility.

This pull request contains my suggestion on how to mitigate this depending on the installed skimage version. Since the fix is neither elegant nor pretty, I would suggest to introduce it as a temporary fix and drop the scikit-image compatibility for < 0.19 completely in upcoming releases of imagecorruptions.

impulse_noise determinism for scikit-image >= 0.19

The later versions of scikit-image use the "new" numpy random generator interface in contrast to the legacy one. This comes with two implications for everyone who wants to create reproducible outputs with imagecorruptions:

  • It is not sufficient to reset the global numpy random state (i.e. by reseeding outside the function call) for getting reproducible impulse_noise outputs
  • If the corrupt function is used, the additional seed needs to be propagated to impulse_noise as keyword argument.

I made the corresponding changes. At least for the imgaug test cases this is sufficient to restore reproducibility.

glass_blur determinism with njit

Commit 2393c18 introduces a speed up for glass_blur by using numba jit. The flip side for this speed-up is broken reproducibility. Numba provides documentation on how to seed numpy random functions within a njit-decorated function.

I added the corresponding changes to this pull request.

Again: Thank you for providing imagecorruptions and I hope that my changes will be helpful for other imagecorruption users!

Best wishes,
Eric

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant