Skip to content

Commit

Permalink
bits and bytes
Browse files Browse the repository at this point in the history
  • Loading branch information
Benjamin Lefaudeux committed Dec 18, 2024
1 parent 925f90f commit 1d81af6
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 2 deletions.
2 changes: 1 addition & 1 deletion pkg/serdes.go
Original file line number Diff line number Diff line change
Expand Up @@ -111,7 +111,7 @@ func imageFromBuffer(buffer []byte, transform *ARAwareTransform, aspect_ratio fl
channels = img.Bands()

// Define bit depth de facto, not exposed in the vips interface
bit_depth = len(img_bytes) / (width * height * channels)
bit_depth = len(img_bytes) / (width * height * channels) * 8 // 8 bits per byte
}

if bit_depth == 0 && !pre_encode_image {
Expand Down
20 changes: 19 additions & 1 deletion python/test_datago_db.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@


def get_test_source() -> str:
test_source = os.getenv("DATAROOM_TEST_SOURCE")
test_source = os.getenv("DATAROOM_TEST_SOURCE", "COYO")
assert test_source is not None, "Please set DATAROOM_TEST_SOURCE"
return test_source

Expand Down Expand Up @@ -160,6 +160,24 @@ def no_test_jpg_compression():
), "Embedding should be set"


def test_original_image():
# Check that the images are transmitted as expected
client_config = get_json_config()
client_config["image_config"]["pre_encode_images"] = False
client_config["image_config"]["crop_and_resize"] = False
dataset = DatagoIterDataset(client_config, return_python_types=False)

sample = next(iter(dataset))

assert go_array_to_pil_image(sample.Image).mode == "RGB", "Image should be RGB"
assert (
go_array_to_pil_image(sample.AdditionalImages["masked_image"]).mode == "RGB"
), "Image should be RGB"
assert (
go_array_to_pil_image(sample.Masks["segmentation_mask"]).mode == "L"
), "Mask should be L"


def test_duplicate_state():
client_config = get_json_config()
client_config["source_config"]["return_duplicate_state"] = True
Expand Down

0 comments on commit 1d81af6

Please sign in to comment.