Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Revert "[AL-1749] image.rgb and image.gray htypes" #1662

Merged
merged 1 commit into from
May 9, 2022
Merged
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
2 changes: 0 additions & 2 deletions hub/api/tests/test_api.py
Original file line number Diff line number Diff line change
Expand Up @@ -938,8 +938,6 @@ def test_htypes_list():
"dicom",
"generic",
"image",
"image.gray",
"image.rgb",
"json",
"keypoints_coco",
"list",
Expand Down
50 changes: 0 additions & 50 deletions hub/api/tests/test_api_with_compression.py
Original file line number Diff line number Diff line change
Expand Up @@ -269,53 +269,3 @@ def test_exif(memory_ds, compressed_image_paths):
type(image.sample_info["exif"]),
path,
)


def test_forced_htypes(
memory_ds, grayscale_image_paths, color_image_paths, flower_path
):
with memory_ds as ds:
gray = ds.create_tensor("gray", htype="image.gray", sample_compression="jpeg")
rgb = ds.create_tensor("rgb", htype="image.rgb", sample_compression="jpeg")

ds.gray.append(hub.read(grayscale_image_paths["jpeg"]))
ds.gray.append(hub.read(color_image_paths["jpeg"]))
ds.gray.extend(np.ones((4, 10, 10, 3), dtype=np.uint8))
ds.gray.extend(
[hub.read(color_image_paths["jpeg"]), np.ones((10, 10), dtype=np.uint8)]
)

ds.rgb.append(hub.read(grayscale_image_paths["jpeg"]))
ds.rgb.append(hub.read(color_image_paths["jpeg"]))
ds.rgb.extend(np.ones((4, 10, 10), dtype=np.uint8))
ds.rgb.extend(
[
hub.read(grayscale_image_paths["jpeg"]),
np.ones((10, 10, 3), dtype=np.uint8),
]
)

gray_png = ds.create_tensor(
"gray_png", htype="image.gray", sample_compression="png"
)
rgb_png = ds.create_tensor(
"rgb_png", htype="image.rgb", sample_compression="png"
)

gray_png.append(hub.read(flower_path))
gray_png.append(np.ones((10, 10, 4), dtype=np.uint8))

rgb_png.append(hub.read(flower_path))
rgb_png.append(np.ones((10, 10, 4), dtype=np.uint8))

for sample in gray:
assert len(sample.shape) == 2

for sample in rgb:
assert len(sample.shape) == 3

for sample in gray_png:
assert len(sample.shape) == 2

for sample in rgb_png:
assert len(sample.shape) == 3
11 changes: 0 additions & 11 deletions hub/core/chunk_engine.py
Original file line number Diff line number Diff line change
Expand Up @@ -55,9 +55,7 @@
ReadOnlyModeError,
)
from hub.util.remove_cache import get_base_storage
from hub.util.image import convert_sample, convert_img_arr
from hub.compression import VIDEO_COMPRESSIONS
from hub.core.sample import Sample
from itertools import chain, repeat
from collections.abc import Iterable

Expand Down Expand Up @@ -575,15 +573,6 @@ def _sanitize_samples(self, samples):
tensor_meta.set_dtype(get_dtype(samples))
if self._convert_to_list(samples):
samples = list(samples)
if tensor_meta.htype in ("image.gray", "image.rgb"):
mode = "L" if tensor_meta.htype == "image.gray" else "RGB"
converted = []
for sample in samples:
if isinstance(sample, Sample):
converted.append(convert_sample(sample, mode, self.compression))
elif isinstance(sample, np.ndarray):
converted.append(convert_img_arr(sample, mode))
samples = verified_samples = converted
return samples, verified_samples

def _samples_to_chunks(
Expand Down
14 changes: 2 additions & 12 deletions hub/htype.py
Original file line number Diff line number Diff line change
Expand Up @@ -57,12 +57,6 @@
"image": {
"dtype": "uint8",
},
"image.rgb": {
"dtype": "uint8",
},
"image.gray": {
"dtype": "uint8",
},
"class_label": {
"dtype": "uint32",
"class_names": [],
Expand All @@ -89,15 +83,11 @@
"bbox": {"coords": {"type": dict, "keys": ["type", "mode"]}}
}

_image_compressions = (
IMAGE_COMPRESSIONS[:] + BYTE_COMPRESSIONS + list(COMPRESSION_ALIASES)
)
_image_compressions = IMAGE_COMPRESSIONS[:]
_image_compressions.remove("dcm")

HTYPE_SUPPORTED_COMPRESSIONS = {
"image": _image_compressions,
"image.rgb": _image_compressions,
"image.gray": _image_compressions,
"image": _image_compressions + BYTE_COMPRESSIONS + list(COMPRESSION_ALIASES),
"video": VIDEO_COMPRESSIONS[:],
"audio": AUDIO_COMPRESSIONS[:],
"text": BYTE_COMPRESSIONS[:],
Expand Down
51 changes: 0 additions & 51 deletions hub/util/image.py

This file was deleted.