mirror of
https://github.com/RapidAI/RapidOCR.git
synced 2026-11-11 05:20:49 +08:00
MNNInferSession.__call__ extracted session output via np.array(out_tensor.getData()).reshape(out_shape), which marshals tensor contents through a slow per-element Python path. For a PP-OCRv6 medium recognizer output (~17MB), this cost ~454ms versus ~210ms for the actual GPU inference that produced it. Switch to getNumpyData(), which exposes the buffer directly. An explicit copy is required since getNumpyData() returns a view into memory owned by out_tensor; without it, out_tensor going out of scope or being reused across shape changes caused intermittent segfaults. On a 39-box real-world image, total recognition time dropped from ~22s to ~8.4s. Per-crop output extraction dropped from ~454ms to ~10ms. Fixes intermittent segfault risk from unmanaged zero-copy tensor lifetime as a side effect.