docling-project / docling-project/docling
Add default Cyrillic OCR support for EasyOCR, Tesseract and RapidOCR backends
- Dominant language
- Python
- Stars
- 66.4k
- Forks
- 4.8k
- Avg merge
- 2d 21h
- Merged PRs (30d)
- 84
Description
### Requested feature
Вот вариант issue для GitHub в понятном и технически конкретном формате.
---
### Title
Add default Cyrillic OCR support for EasyOCR, Tesseract and RapidOCR backends
### Body
Docling currently does not provide out-of-the-box Cyrillic OCR support for several OCR backends:
* EasyOCR
* Tesseract
* RapidOCR
As a result, PDF documents containing Russian/Cyrillic text are recognized poorly or fail completely unless users manually patch models and configurations.
It would be very useful to add built-in support for Cyrillic models and language assets.
## Proposed changes
### 1. EasyOCR
Add support for loading the Cyrillic recognition model:
* `cyrillic_g2.pth`
Ideally this should be configurable through backend settings or automatically downloaded when Cyrillic languages are requested.
---
### 2. Tesseract
Add support for the Russian language model:
* `rus.traineddata`
This could be automatically installed/downloaded or documented as a built-in optional dependency.
---
### 3. RapidOCR
RapidOCR already supports multilingual OCR models, but Docling currently does not expose Cyrillic-specific model paths.
A possible solution is to add Cyrillic model mappings in `rapid_ocr_model.py`.
Example:
```python
_RAPIDOCR_CYRILLIC_MODEL_PATHS: dict[_ModelPathEngines, dict[_ModelPathTypes, str]] = {
"onnxruntime": {
"det_model_path": "onnx/PP-OCRv4/det/multi_PP-OCRv3_det_mobile.onnx",
"cls_model_path": "onnx/PP-OCRv4/cls/ch_ppocr_mobile_v2.0_cls_mobile.onnx",
"rec_model_path": "onnx/PP-OCRv4/rec/cyrillic_PP-OCRv5_rec_mobile.onnx",
"rec_keys_path": "paddle/PP-OCRv5/rec/cyrillic_PP-OCRv5_rec_mobile/ppocrv5_cyrillic_dict.txt",
"font_path": "resources/fonts/cyrillic.ttf",
},
"torch": {
"det_model_path": "torch/PP-OCRv4/det/multi_PP-OCRv3_det_mobile.pth",
"cls_model_path": "torch/PP-OCRv4/cls/ch_ptocr_mobile_v2.0_cls_mobile.pth",
"rec_model_path": "torch/PP-OCRv4/rec/cyrillic_PP-OCRv3_rec_mobile.pth",
"rec_keys_path": "paddle/PP-OCRv4/rec/cyrillic_PP-OCRv3_rec_mobile/cyrillic_dict.txt",
"font_path": "resources/fonts/cyrillic.ttf",
},
}
```
in _models_by_language dict:
```python
"cyrillic": {
backend: {
key: _build_model_detail(path)
for key, path in _RAPIDOCR_CYRILLIC_MODEL_PATHS[backend].items()
}
for backend in _RAPIDOCR_BACKENDS
},
```
in `_resolve_rapidocr_language`
```python
def _resolve_rapidocr_language(languages: list[str] | None) -> str:
if not languages:
return _RAPIDOCR_DEFAULT_LANGUAGE
normalized_languages = {language.strip().lower() for language in languages}
if {"en", "english"} & normalized_languages:
return "english"
if {"cyrillic", "russian"} & normalized_languages: #and other cyrillics languages
return "cyrillic"
```
Model source:
* [https://www.modelscope.cn/models/RapidAI/RapidOCR/resolve](https://www.modelscope.cn/models/RapidAI/RapidOCR/resolve)
---
## Why this matters
Cyrillic OCR is a common requirement for:
* Russian-language PDFs
* Ukrainian documents
* Kazakh and other Cyrillic-based languages
* multilingual enterprise document processing
Currently users must manually modify OCR backends and download models themselves, which complicates deployment and reduces usability.
Native Cyrillic support would significantly improve the international usability of Docling.
### Alternatives
...
Contributor guide
Assessment
This issue has not been assessed yet.