robertknight / ocrs

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

Extremely slow when invoking `engine.recognize_text` when in `debug` builds #117

Closed ezkangaroo closed 1 month ago

ezkangaroo commented 1 month ago

Rust version information:

rustc --version; 
# rustc 1.83.0-nightly (f79a912d9 2024-09-18)

Steps to replicate:

; git clone https://github.com/robertknight/ocrs.git --depth 1

# following instruction from readme
; cd ocrs/ocrs/examples 
; ./download-models.sh
; cargo run --example hello_ocr rust-book.jpg # note that we did not use --release

# takes roughly 2-3s on my m1 machine
robertknight commented 1 month ago

Did you mean 2-3 seconds or 20-30?

This is expected. You need to compile the rten and rten- prefixed dependencies with at least some optimizations enabled. The easiest way is to compile the whole project with --release, but an alternative that won't affect your whole project is to enable optimizations for just those packages. See https://stackoverflow.com/a/60752451/434243.

ezkangaroo commented 1 month ago

Sweet - that makes sense; feel free to close this issue.