Description of the bug
Normalization of image arrays using the normalize function in the array_utils.py (line: 57) uses a significant amount of memory due to conversion of the initial array dtype from np.int16 to np.float64 for the returned array.
To Reproduce/Check
Simply amend the code to be as follows:
@validate(array=array_not_empty)
def normalize(array: np.ndarray, value: float | None = None) -> np.ndarray:
"""Normalize an array to the passed value. If not value is passed, normalize to the maximum value"""
print("dtype before: ", array.dtype)
if value is None:
val = array.max()
else:
val = value
array = array / val
print("dtype after: ", array.dtype)
return array
Possible solution
Return the array with dtype np.float16 using:
Description of the bug Normalization of image arrays using the normalize function in the
array_utils.py (line: 57)
uses a significant amount of memory due to conversion of the initial array dtype fromnp.int16
tonp.float64
for the returned array.To Reproduce/Check Simply amend the code to be as follows:
Possible solution Return the array with dtype
np.float16
using: