aleju / imgaug

Image augmentation for machine learning experiments.
http://imgaug.readthedocs.io
MIT License
14.38k stars 2.44k forks source link

AttributeError: np.sctypes was removed in NumPy 2.0 release #859

Open qja1998 opened 2 days ago

qja1998 commented 2 days ago

In the latest release of NumPy (2.0), the np.sctypes attribute has been removed. As a result, the following code in the imgaug library causes an AttributeError:

NP_FLOAT_TYPES = set(np.sctypes["float"])
NP_INT_TYPES = set(np.sctypes["int"])
NP_UINT_TYPES = set(np.sctypes["uint"])

This issue can be found in the following link: Problematic code

I think modifying the code to directly reference NumPy's dtypes instead of using np.sctypes. For example:

NP_FLOAT_TYPES = {np.float16, np.float32, np.float64}
NP_INT_TYPES = {np.int8, np.int16, np.int32, np.int64}
NP_UINT_TYPES = {np.uint8, np.uint16, np.uint32, np.uint64}

Feel free to fill in the Python version and operating system, then copy and paste this into a new issue on the GitHub repository. Let me know if you need any more help!

tindo2003 commented 20 hours ago

This works for me. Thanks for your help!