$ show PaddlePaddle/PaddleOCR
PaddleOCR is a production-grade OCR and document parsing toolkit built on PaddlePaddle. It provides a comprehensive suite of models for text detection, text recognition, layout analysis, table extraction, formula recognition, key information extraction (KIE), and document conversion (PDF/Image to Markdown/JSON). The system is deployed as a Python CLI, a Python library, a C++ inference engine, mobile SDKs (Android, iOS), a JavaScript browser SDK, a Go SDK, a TypeScript SDK, and a Model Context Protocol (MCP) server for AI agent integration. It also includes a cloud API client for remote inference. The architecture is modular: models are configurable via YAML, pipelines orchestrate multi-stage workflows, and deployment targets range from edge devices to cloud servers. The codebase is actively maintained with extensive testing, CI/CD, and support for multiple hardware accelerators (GPU, NPU, XPU, etc.). While primarily an application toolkit, it also contains research-grade training infrastructure, custom loss functions, and data augmentation modules, making it a hybrid project with a strong application focus.
The LLM identified 6 files worth highlighting for reuse:
Provides `snake_to_camel` and `snake_keys_to_camel` functions for converting snake_case identifiers to camelCase. This is a self-contained, reusable utility that can be extracted into any Python project needing consistent naming transformations. It demonstrates clean, well-documented code with no external dependencies beyond standard library.
Implements an asynchronous job poller with exponential backoff for polling long-running OCR/document parsing tasks. The `AsyncPoller` class is isolated, parameterized, and handles cancellation, timeout, and status transitions. This pattern is reusable for any API client that needs to poll for job completion.
Provides LMDB-based dataset loaders for OCR training with a secure unpickling mechanism (`_RestrictedDatasetUnpickler`) that restricts allowed globals to prevent arbitrary code execution. The `LMDBDataSet` base class supports hierarchical multi-env loading, sample traversal, and transformed data pipelines. This pattern is reusable for any project needing safe LMDB data loading.
Defines a `BasePredictor` abstract class with a registration system for pre/post processors, batch sampling, and static inference engine management. The template-based `Register<T>(key, args...)` pattern allows pluggable processing steps. This is a well-architected C++ base class that can be reused for other inference pipelines beyond OCR.
Defines a typed message-passing protocol (`TransportRequest`, `TransportResponse`) for offloading OCR inference to web workers. The protocol includes request IDs, serialization/deserialization, and error handling. This pattern is reusable for any JavaScript project that needs to communicate between main thread and worker for compute-intensive tasks.
Implements modular loss functions for text detection: `DiceLoss`, `MaskedFocalLoss`, `DiceFocalLoss`, and `BalanceLoss`. Each loss is a self-contained PaddlePaddle `nn.Layer` with configurable parameters. These are reusable for any segmentation or detection task requiring dice-based or focal losses.