bethgelab / imagecorruptions

Python package to corrupt arbitrary images.
https://pypi.org/project/imagecorruptions/
Apache License 2.0
403 stars 64 forks source link

improving glass blur using numba #18

Closed prakass1 closed 3 years ago

prakass1 commented 3 years ago

This pull request is to speed up the computation of glass_blur using numba (https://numba.pydata.org/numba-doc/latest/user/5minguide.html). Since, the glass_blur had only numpy and loop based computations, I was able to move it to a separate method with @njit decorator improving the speed significantly. I also have added the requirements.txt and the setup.py is also updated and have added a demo file to test the same.

Steps done to run is:

pip install -r requirements.txt
python test_demo.py

Results obtained:

defocus_blur 0.9493465423583984
glass_blur 5.243793964385986 (Improved from about 1 minute to 5 seconds)
motion_blur 2.2798967361450195
zoom_blur 19.582147359848022
michaelisc commented 3 years ago

Looks great! Thanks for adding the demo script as well!