Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Perform OCR on OCR-only processes #5

Merged
merged 4 commits into from
Jan 29, 2024

Conversation

phu54321
Copy link
Contributor

@phu54321 phu54321 commented Jan 22, 2024

Spawn multiple _ocrProcess process and do all the OCR job there

Caveats:

  • pytorch is not thread-safe, so use of multiprocessing module is necessary
  • OCR processes are NOT gracefully terminated. I don't know when to terminate them.

New options:

  • --easyocr-workers [number]: # of OCR processes. VRAM usage increases proportionally. IDK if this could be reduced, as EasyOCR doesn't seem to be multiprocessing-safe
  • --easyocr-batch-size [number]: Set batch_size parameter of easyocr. Don't expect a lot of performance gain, though.

Before (See GPU usage)

2024-01-22 14_46_20-

After (See GPU usage)

2024-01-22 14_37_58-작업 관리자

not a fair comparison: Old implementation wants to use 12GB of ram, so it doesn't fit in my 3060. New implementation allows you to configure the amount of ram you want.

I'm seeing a speedup of 4x, but this may vary for people with lots of VRAMs. Further testing needed.

Fixes #3

@phu54321
Copy link
Contributor Author

Force-pushed typo fix :)

@jbarlow83 jbarlow83 merged commit 6e0bf0a into ocrmypdf:main Jan 29, 2024
2 checks passed
@jbarlow83
Copy link
Contributor

Thanks - I added child process cleanup.

@phu54321 phu54321 deleted the feature-ocrthread branch January 29, 2024 09:55
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Share easyocr.Reader instance
2 participants