Skip to content
This repository has been archived by the owner on Oct 9, 2023. It is now read-only.

Load Numpy arrays of incompatible dtypes #1507

Draft
wants to merge 17 commits into
base: master
Choose a base branch
from
Draft
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 7 additions & 1 deletion src/flash/core/data/utilities/loading.py
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,13 @@


def _load_image_from_numpy(file):
return Image.fromarray(np.load(file).astype("uint8")).convert("RGB")
arr = np.load(file)
if not (arr == arr.astype("uint8")).all():
# Max pixel value -> 255, min -> 0
low = arr.min()
arr = 255 * (arr - low) / (arr.max() - low)

Check warning on line 79 in src/flash/core/data/utilities/loading.py

View check run for this annotation

Codecov / codecov/patch

src/flash/core/data/utilities/loading.py#L78-L79

Added lines #L78 - L79 were not covered by tests

return Image.fromarray(arr.astype("uint8")).convert("RGB")


def _load_spectrogram_from_image(file):
Expand Down
Loading