π Awesome OCR multiple programing languages toolkits based on ONNX Runtime, OpenVINO, MNN, PaddlePaddle, TensorRT and PyTorch.
Fix LoadImage error when bytes comes from gif
SWHLf68f98b0952d
diff --git a/python/rapidocr_onnxruntime/utils.py b/python/rapidocr_onnxruntime/utils.pyindex 2dad7e9..4952d7d 100644--- a/python/rapidocr_onnxruntime/utils.py+++ b/python/rapidocr_onnxruntime/utils.py@@ -3,6 +3,7 @@# @Contact: [email protected]import argparseimport warnings+from io import BytesIOfrom pathlib import Pathfrom typing import Union@@ -121,8 +122,8 @@ class LoadImage():return imgif isinstance(img, bytes):- img = np.frombuffer(img, dtype=np.uint8)- img = cv2.imdecode(img, cv2.IMREAD_COLOR)+ img = np.array(Image.open(BytesIO(img)))+ img = cv2.cvtColor(img, cv2.COLOR_RGB2BGR)return imgif isinstance(img, np.ndarray):diff --git a/python/rapidocr_openvino/utils.py b/python/rapidocr_openvino/utils.pyindex cdef222..4f01f38 100644--- a/python/rapidocr_openvino/utils.py+++ b/python/rapidocr_openvino/utils.py@@ -2,6 +2,7 @@# @Author: SWHL# @Contact: [email protected]import argparse+from io import BytesIOfrom pathlib import Pathfrom typing import Union@@ -69,8 +70,8 @@ class LoadImage():return imgif isinstance(img, bytes):- img = np.frombuffer(img, dtype=np.uint8)- img = cv2.imdecode(img, cv2.IMREAD_COLOR)+ img = np.array(Image.open(BytesIO(img)))+ img = cv2.cvtColor(img, cv2.COLOR_RGB2BGR)return imgif isinstance(img, np.ndarray):