-
Notifications
You must be signed in to change notification settings - Fork 64
Open
Description
Brain-Tumor-Segmentation/api.py
Line 91 in 3655ee9
output = np.resize((output * 255), (512, 512)) |
Current code:
output = np.resize((output * 255), (512, 512))
Proposed replacement:
output = (output * 255).reshape(512, 512)
Behavioral difference:
np.reshape only works if the number of elements matches the new shape. If not, it raises an error, making shape mismatches explicit.
np.resize always returns the requested shape, but if the target has more elements, it repeats data; if fewer, it truncates. In image data, this silently produces corrupted results that may still “look” valid.
Performance: reshape is faster and typically returns a view without copying.
Robustness: For images, preserving pixel integrity is critical — silent repetition/truncation from resize can cause serious bugs in downstream tasks.
Metadata
Metadata
Assignees
Labels
No labels