RapidAI / RapidOCR

Awesome OCR multiple programing languages toolkits based on ONNXRuntime, OpenVION and PaddlePaddle. (将PaddleOCR模型做了转换,采用ONNXRuntime推理,速度很快)
https://rapidai.github.io/RapidOCRDocs
Apache License 2.0
2.81k stars 349 forks source link

[Bug] 当前图像处理过程中,未考虑 Grayscale with alpha #115

Closed imClumsyPanda closed 1 year ago

imClumsyPanda commented 1 year ago

请提供下述完整信息以便快速定位问题 (Please provide the following information to quickly locate the problem)

处理文献中存在的 Grayscale with alpha 类型图像时,将图像读取为ndarray时,ndarray的shape为[1007, 915, 2],经检查属于Grayscale with alpha 类型图像,目前的处理程序中 utils 中 LoadImage 类的 call 函数 暂未考虑该类型图像的处理,仅考虑了2维ndarray、3维ndarray且第3维size为4的情况。

img_array = np.frombuffer(samples, dtype=np.uint8).reshape(height, width, 2)
img_gray = img_array[:, :, 0]
img_gray = cv2.cvtColor(img_gray, cv2.COLOR_GRAY2BGR)
img_alpha = img_array[:, :, 1] 

可参考如上代码进行 img_array 中 gray 和 alpha 两层的读取。

SWHL commented 1 year ago

已经在rapidocr_onnxruntime==1.3.1中修复,请再次尝试。

imClumsyPanda commented 1 year ago

实际测试已解决该问题,非常感谢🙏