diff --git a/iscc_sci/code_semantic_image.py b/iscc_sci/code_semantic_image.py index 6125110..c8d21e6 100644 --- a/iscc_sci/code_semantic_image.py +++ b/iscc_sci/code_semantic_image.py @@ -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) diff --git a/tests/test_iscc_sci.py b/tests/test_iscc_sci.py index 8436db1..3d363b2 100644 --- a/tests/test_iscc_sci.py +++ b/tests/test_iscc_sci.py @@ -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(): @@ -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):