You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
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)defnormalize(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)
ifvalueisNone:
val=array.max()
else:
val=valuearray=array/valprint("dtype after: ", array.dtype)
returnarray
Possible solution
Return the array with dtype np.float16 using:
returnarray.astype(np.float16)
The text was updated successfully, but these errors were encountered:
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:The text was updated successfully, but these errors were encountered: