Update image resizing algorithm

This commit is contained in:
Anyexyz 2023-12-18 09:39:28 +00:00
parent e4f04c90d2
commit 3348bda098

View File

@ -559,7 +559,7 @@ class DdddOcr(object):
image = Image.open(io.BytesIO(img_bytes)) image = Image.open(io.BytesIO(img_bytes))
else: else:
image = base64_to_image(img_base64) image = base64_to_image(img_base64)
image = image.resize((int(image.size[0] * (64 / image.size[1])), 64), Image.ANTIALIAS).convert('L') image = image.resize((int(image.size[0] * (64 / image.size[1])), 64), Image.LANCZOS).convert('L')
image = np.array(image).astype(np.float32) image = np.array(image).astype(np.float32)
image = np.expand_dims(image, axis=0) / 255. image = np.expand_dims(image, axis=0) / 255.
image = (image - 0.5) / 0.5 image = (image - 0.5) / 0.5