Skip to content
Open
Show file tree
Hide file tree
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
15 changes: 9 additions & 6 deletions tensorflow_datasets/core/utils/image_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -171,10 +171,9 @@ def _postprocess_convert_rgb(img: PilImage) -> PilImage:
def create_thumbnail(
ex: np.ndarray, *, use_colormap: bool, default_dimensions: bool = True
) -> PilImage:
"""Creates the image from the np.array input."""
PIL_Image = lazy_imports_lib.lazy_imports.PIL_Image # pylint: disable=invalid-name
PIL_Image = lazy_imports_lib.lazy_imports.PIL_Image

if use_colormap: # Apply the colormap first as it modify the shape/dtype
if use_colormap:
ex = apply_colormap(ex)

_, _, c = ex.shape
Expand All @@ -183,12 +182,16 @@ def create_thumbnail(
ex = ex.squeeze(axis=-1)
mode = 'L'
elif ex.dtype == np.uint16:
mode = 'I;16'
postprocess = _postprocess_convert_rgb
if c in (3, 4):
ex = (ex / 257).astype(np.uint8)
mode = None
else:
mode = 'I;16'
postprocess = _postprocess_convert_rgb
else:
mode = None
img = PIL_Image.fromarray(ex, mode=mode)
img = postprocess(img)
if default_dimensions:
img.thumbnail((THUMBNAIL_SIZE, THUMBNAIL_SIZE)) # Resize the image in-place
img.thumbnail((THUMBNAIL_SIZE, THUMBNAIL_SIZE))
return img
4 changes: 2 additions & 2 deletions tensorflow_datasets/ranking/mslr_web/mslr_web.py
Original file line number Diff line number Diff line change
Expand Up @@ -61,8 +61,8 @@
"""

_URLS = {
"10k": "https://api.onedrive.com/v1.0/shares/s!AtsMfWUz5l8nbOIoJ6Ks0bEMp78/root/content",
"30k": "https://api.onedrive.com/v1.0/shares/s!AtsMfWUz5l8nbXGPBlwD1rnFdBY/root/content",
"10k": "https://1drv.ms/u/s!AtsMfWUz5l8nbOIoJ6Ks0bEMp78",
"30k": "https://1drv.ms/u/s!AtsMfWUz5l8nbXGPBlwD1rnFdBY",
}

_FEATURE_NAMES = {
Expand Down