PaddleOCR icon indicating copy to clipboard operation
PaddleOCR copied to clipboard

fixbug: change DetOp.postprocess's result from string(ndarray) to string(list)

Open diana-pwf opened this issue 1 year ago • 3 comments

image In web_service_det.py, DetOp.postprocess function, I find dt_boxes is a ndarray and it is converted to string, but the string representation 'str(a)' of a numpy array "a" is not sufficient to exactly restore the original array, particularly for arrays with many elements. This is because the string representation may truncate large arrays for brevity. So I change it to a list converted to string.

diana-pwf avatar May 18 '23 06:05 diana-pwf

Thanks for your contribution!

paddle-bot[bot] avatar May 18 '23 06:05 paddle-bot[bot]

I completely agree with this Pull Request. I've encountered a similar issue before, where the conversion of the ndarray to a string representation using 'str(a)' resulted in potential data loss due to truncation, especially for arrays with a large number of elements. Converting the ndarray to a list before converting it to a string is a better approach as it preserves the entire array without truncation. This change will ensure the accuracy and integrity of the data. Thank you for addressing this issue and proposing the solution!

xiaoliou008 avatar May 18 '23 07:05 xiaoliou008

This PR saved my day! I use paddleocr for a long text, and the str(dt_boxes) caused all the trouble.

youkaichao avatar May 22 '23 07:05 youkaichao