Repository navigation
perf(ocr): bound EasyOCR memory (skip Apple MPS, smaller detector canvas) - #23
Closed
Venopacman wants to merge 1 commit into
Closed
Venopacman wants to merge 1 commit into
Venopacman wants to merge 1 commit into
Conversation
…vas) On an Apple Silicon Mac the screenmind process held ~8 GB: EasyOCR's gpu=True picks MPS, and PyTorch's MPS allocator kept ~7.5 GB of unified memory between frames. Moving to CPU alone did not help (peak ~8.6 GB of RAM). The cost is the CRAFT detector running over the whole image at canvas_size=2560. Memory scales with that size, while recognition still reads crops from the full-resolution image. Measured on 12 real 3024x1964 screenshots, CPU: canvas peak RAM text kept sec/frame 1920 7.7 GB 100% 7.8 1280 6.0 GB ~100% 2.5 960 4.0 GB 96% 1.9 800 3.1 GB 90% 1.7 640 2.1 GB 71% 1.1 - Use the GPU only when CUDA is available (NVIDIA users keep GPU OCR). - Pass canvas_size=800 to readtext (OCR_CANVAS_SIZE). Process footprint went from ~8.1 GB to ~1.5 GB between frames. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Contributor
Author
|
sorry - claude was too much initiative :D |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Problem
On an Apple Silicon Mac (M5, 24 GB), the ScreenMind process used about 8.1 GB. About 7.5 GB of that was GPU memory:
gpu=Truemakes EasyOCR use Apple's MPS backend, and PyTorch keeps that memory between frames.Switching to CPU alone didn't help: peak was about 8.6 GB of normal RAM. The real cost is the CRAFT text detector running over the whole image at the default
canvas_size=2560.Fix
canvas_size=800toreadtext(OCR_CANVAS_SIZE). Recognition still reads crops from the full-resolution image, so most text survives.Numbers
12 real 3024x1964 screenshots, CPU:
canvas_sizeThe process went from about 8.1 GB to about 1.5 GB between frames. OCR is also faster than before (1.7s vs 3s per frame on MPS). It runs next to a model call of about 12s, so the speed doesn't matter much either way.
The 10% of text lost is mostly very short words (1–2 letters). If you'd rather trade memory for text, 960 keeps 96% at about 4 GB.
Testing
canvas_sizereachesreadtext, and_use_gpu()followstorch.cuda.is_available().🤖 Generated with Claude Code