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
6 changes: 3 additions & 3 deletions iscc_sci/code_semantic_image.py
Original file line number Diff line number Diff line change
Expand Up @@ -127,15 +127,15 @@ def preprocess_image(image):
# Transpose the image according to its orientation tag (if available).
image = ImageOps.exif_transpose(image)

# Convert to RGB and add a white background if the image contains transparency.
image = remove_transparency(image)

# Crop uniformly colored borders if applicable.
image = trim_border(image)

# Resize the image
image = image.resize((512, 512), Resampling.BILINEAR)

# Convert to RGB and add a white background if the image contains transparency.
image = remove_transparency(image)

# Convert to a numpy array and ensure type consistency
image = np.array(image, dtype=np.float32)

Expand Down
6 changes: 3 additions & 3 deletions tests/test_iscc_sci.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ def test_code_image_semantic_default():

def test_code_image_semantic_256bit():
result = sci.code_image_semantic(images()[1], bits=256)
assert result["iscc"] == "ISCC:CEDQ2WT7K2Q7YTO47HLGYUURO2RCI24K5VUZOHFMMY42C6O6VLQ6FEA"
assert result["iscc"] == "ISCC:CEDQ2UTPK2Q7ZTK47HLOYUUTO3TCA36INUUZODFMMY46S6O6VLSWFEA"


def test_code_image_semantic_embedding_precision():
Expand All @@ -27,8 +27,8 @@ def test_code_image_semantic_embedding_precision():
assert result["features"][0]["maintype"] == "semantic"
assert result["features"][0]["subtype"] == "image"
assert result["features"][0]["version"] == 0
assert result["features"][0]["embedding"][0] == -0.0557
assert result["features"][0]["embedding"][-1] == -0.1192
assert result["features"][0]["embedding"][0] == -0.0647
assert result["features"][0]["embedding"][-1] == -0.109


def test_gen_image_code_semantic(img_array):
Expand Down
Loading