robertknight / ocrs

Rust library and CLI tool for OCR (extracting text from images)
Apache License 2.0
1.1k stars 46 forks source link

Library Performance Versus CLI #7

Closed Grant3W closed 8 months ago

Grant3W commented 8 months ago

Thank you for your work on this project. It looks really exciting and I can't wait to start using this in my projects. I've spun up the example you give from the library, however, the performance seems to be degraded compare to the CLI.

When running from a Rust project with ocrs as a library, my image took ~30 seconds, whereas the same image took ~1 second with the CLI.

Any idea where I could be going wrong? I can see from debugging that the delay is coming from the phase1 and phase 3 calls from the example. I tried turning debug off, but that hasn't helped.

Grant3W commented 8 months ago

Please disregard this. I simply needed to mark the build as release with --release and this resolved the issue.

robertknight commented 8 months ago

The rten dependency is the machine learning runtime which has to always be compiled in release mode for reasonable performance. Other parts of the code can be compiled in debug mode for better backtraces etc. I should make a note of this in the README.

Grant3W commented 8 months ago

That's good to know, I appreciate the explanation.