Skip to content

fix: prevent HF Space OOM crashes by caching OCR engines#12

Merged
mauryasameer merged 3 commits into
devfrom
fix/hf-space-oom
Apr 7, 2026
Merged

fix: prevent HF Space OOM crashes by caching OCR engines#12
mauryasameer merged 3 commits into
devfrom
fix/hf-space-oom

Conversation

@mauryasameer

Copy link
Copy Markdown
Owner

Fixes 'Memory limit exceeded (16Gi)' crashes by globally caching instantiated PyTorch/Paddle inference sessions in OCRFactory, preventing unbounded memory leaks on repetitive Gradio requests.

chore: promote dev to main (HF Space Crash Fix)
- In `OCRFactory`, cached instantiated engines in `_instances` dict to prevent multi-GB memory leaks on every Gradio request.
- Explicitly disabled `use_gpu` and `show_log` during `PaddleOCR` initialization to minimize host probing and stdout noise in constrained environments.
@mauryasameer mauryasameer merged commit 40b0286 into dev Apr 7, 2026
3 checks passed
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.

1 participant