From b2052b1200aef7fb7c300b8c07c8dce2dcbdaf3e Mon Sep 17 00:00:00 2001 From: AuroraWright Date: Tue, 30 Jan 2024 11:18:31 +0100 Subject: [PATCH] Make apple vision and easy ocr faster --- owocr/ocr.py | 9 +++------ 1 file changed, 3 insertions(+), 6 deletions(-) diff --git a/owocr/ocr.py b/owocr/ocr.py index 3e7e376..c10e424 100644 --- a/owocr/ocr.py +++ b/owocr/ocr.py @@ -263,7 +263,7 @@ class AppleVision: def _preprocess(self, img): image_bytes = io.BytesIO() - img.save(image_bytes, format='png') + img.save(image_bytes, format='bmp') return image_bytes.getvalue() class WinRTOCR: @@ -321,7 +321,7 @@ class WinRTOCR: def _preprocess(self, img): image_bytes = io.BytesIO() - img.save(image_bytes, format='png') + img.save(image_bytes, format='png', compress_level=1) return image_bytes.getvalue() class AzureComputerVision: @@ -418,9 +418,7 @@ class EasyOCR: return x def _preprocess(self, img): - image_bytes = io.BytesIO() - img.save(image_bytes, format='png') - return image_bytes.getvalue() + return np.array(img.convert('RGB')) class RapidOCR: name = 'rapidocr' @@ -466,4 +464,3 @@ class RapidOCR: def _preprocess(self, img): return np.array(img.convert('RGB')) -