How open-mmlab/mmocr works
Main Components
• Core Framework Modules: Include the essential libraries (mmocr, mmengine, mmcv, mmdetection) that provide the backbone for training and inference.
• Data Handling Pipeline:
• Datasets: Represented by folders like mmocr/datasets, dataset_zoo, and the numerous dataset preparers, parsers, dumpers, gatherers, and samplers.
• Data Converters: The tools/dataset_converters ensure external data can be brought in or transformed.
• Model Components:
• Models: The mmocr/models directory is sub-modularized by task (textdet, textrecog, kie) with further breakdown into backbones, necks, heads, pre-processors, decoders, and losses.
• Configurations: The various configs and project-specific configurations (in projects/*) that define model architectures, training schedules, datasets, etc.
• Inference and Evaluation:
• Inferencers/API: The mmocr/apis/inferencers highlight real-time prediction components and evaluation functions.
• Evaluator & Metrics: Separate modules in mmocr/evaluation to calculate hmean, IoU, and other metrics.
• Engine:
• Training and Inference Engine: The mmocr/engine directory deals with training pipelines, hooks (e.g., visualization hook), and custom runtime routines.
• Utilities:
• Essential utilities from mmocr/utils and visualization modules, which include file I/O, transforms, and visualization utilities.
• Supporting scripts and pipelines:
• Tools: Scripts for training (tools/train.py), testing (tools/test.py, tools/infer.py), distributed training (tools/dist_train.sh, tools/dist_test.sh) and model converters.
• CI/CD and documentation: Directories like .circleci, .github, and docs illustrate integration/testing and documentation pipelines, but they might appear as peripheral “infrastructure” components.
• Projects and Community Extensions:
• Projects: Separate sub-projects (e.g., ABCNet, SPTS, example_project) capturing specialized or extended pipelines for text spotting.
• Demo and sample notebooks, which provide usage examples.
Architectural Patterns and Design Principles
• Modular design principle – each module (e.g., dataset preparers, parsers, model decoders) is individually developed and replaceable.
• “config-driven” approach: separate configuration files allow the user to easily adjust model parameters, training schedules, and data pipelines.
Technologies and Frameworks
• Clearly label use of PyTorch as the core deep learning framework.
• Dependencies on OpenMMLab libraries such as MMEngine, MMCV, and MMDetection.
• Integration with CI/CD tools (CircleCI, GitHub Actions) as part of automated testing and deployment workflows.
• External interfaces (APIs) for inferencing.