1562 Commits
Author SHA1 Message Date
Mohammad EssamandClaude Opus 5.5 a538d3a75e feat(python): draw Arabic text in vis() with khatt from the rtl extra (#763)
* feat(python): draw Arabic text in vis() with khatt from the rtl extra

Recognized Arabic, Persian and Urdu text is returned in reading order,
but vis() draws it with ImageDraw.text, which only joins Arabic letters
and lays out right-to-left text when Pillow is built with Raqm. Without
it the visualization shows separate letters in reverse order, running
out of the box.

When khatt is installed (now part of the rtl extra on Python 3.10+),
right-to-left lines are shaped, start at the right edge of their box,
are centered vertically and shrink to fit the box. Other text, and RTL
text without khatt, is drawn by Pillow as before.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>

* style(python): ruff format the vis RTL changes

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>

* fix(python): let RTL text shrink below 10px to fit small boxes

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>

---------

Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-04 22:01:00 +08:00
Aryan R. Ganjoo 80b427d69b fix(python): preserve resize ratios across both size limits (#761) 2026-10-25 22:47:58 +08:00
SWHL 8579a91f07 fix(inference): harden infer_argmax and add equivalence tests 2026-10-25 22:25:42 +08:00
ExtReMLapin af69351b76 perf(torch): reduce rec logits on device before copying them to the CPU (#757)
* perf(torch): reduce rec logits on device before copying them to the CPU

Signed-off-by: ExtReMLapin <3909752+ExtReMLapin@users.noreply.github.com>

* refactor: keep __call__ returning raw outputs, add InferSession.infer_argmax for rec

Signed-off-by: ExtReMLapin <3909752+ExtReMLapin@users.noreply.github.com>

---------

Signed-off-by: ExtReMLapin <3909752+ExtReMLapin@users.noreply.github.com>
2026-10-25 21:52:16 +08:00
ExtReMLapin 558f566069 perf(det): keep DetPreProcess mean/std in float32 (#756)
Signed-off-by: ExtReMLapin <3909752+ExtReMLapin@users.noreply.github.com>
2026-10-25 21:42:33 +08:00
b40c0f84b8 fix(word_box): score each word from its own characters (issue #749) (#750)
cal_ocr_word_box returned the line's per-character probabilities, spaces
included, as the word scores, so word n got the probability of character n
of the line. Keep each word's character probabilities in
WordInfo.char_confs and score a grouped word with their mean, like the line
score; a single character keeps its own probability.

Co-authored-by: Paul Faucher <186776257+pfauch741@users.noreply.github.com>
Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com>
2026-10-25 21:41:21 +08:00
Mohammad Hijjawi cee004f994 fix(word_box): place word boxes correctly on 180-degree rotated lines (issue #328) (#747)
When the text classifier turns a crop by 180 degrees, recognition runs on
the rotated crop, but CalRecBoxes mapped the word boxes back as if the crop
had never been rotated. Every word/char box on an upside-down line therefore
landed on its mirror position: the first character got the box of the last.

Pass the classifier's rotation decision (same "180" label and cls_thresh
rule TextClassifier uses) to CalRecBoxes, and rotate the word boxes back
by 180 degrees within the crop before mapping them to the original image.
2026-10-25 08:17:53 +08:00
theofarouk 8ac45f4e73 fix(cls): classify the middle of long lines with the v2.0 model (#748)
Fixes #744.
2026-10-20 22:06:30 +08:00
LI 7cfd3d9ef7 fix(python): honor EXIF orientation for bytes and PIL images (#755) 2026-10-13 08:06:01 +08:00
SWHL 0700743fc8 chore: update cliff template 2026-10-08 23:21:37 +08:00
SWHL bd941dae09 fix: correct model SHA256 v3.10.0 2026-10-08 22:51:03 +08:00
SWHL deea2a03e6 feat: support loading raw memory image buffers with format and stride metadata 2026-10-08 11:51:27 +08:00
SWHL d6e304be35 chore: remove optional OpenCV dependency 2026-10-08 11:16:10 +08:00
SWHL 75946b1d26 feat(model-routing): centralize routes in YAML and expose supported l… (#741)
* feat(model-routing): centralize routes in YAML and expose supported languages

* fix(config): correct mobile CLS architecture key casing

* docs: add Backer

* docs: add Backer

* chore: update sponsor way

* feat: add lang_mapping phrase

* refactor: change model cache name

* tests: fixed path error

* tests: add error catch

* fix(tensorrt): resolve precision against hardware capabilities
2026-10-08 10:16:32 +08:00
Rett Wilson 332b4fcc23 fix(rec): honour model_root_dir for the rec dict and str paths in torch engine (#752)
- TextRecognizer.get_character_dict saved the downloaded character dict to
  the package models dir even when Global.model_root_dir was set, which
  fails with PermissionError on a read-only install. Save it under
  model_root_dir when set; fall back to DEFAULT_MODEL_PATH otherwise.
- The torch ModelLoader used cfg.model_root_dir / ... without Path(), so a
  str model_root_dir raised TypeError. Wrap it in Path() like the other
  engines do.
- Add tests that need no model download.
2026-10-08 09:59:59 +08:00
Mohammad Hijjawi f65c7da00e fix(det): honour limit_side_len when limit_type is max (issue #740) (#742)
TextDetector.get_preprocess replaced limit_side_len with a hard-coded
960/1500/2000 bucket whenever limit_type was "max", so the configured
value was ignored and large images reached the detector unresized.
Pass the configured limit_side_len through for both limit types, matching
PaddleOCR DetResizeForTest.
2026-10-03 06:36:38 +08:00
SWHL 9936171fa4 chore: update sponsor way 2026-10-01 20:29:06 +08:00
SWHL 549847df50 docs: add Backer 2026-09-23 15:11:05 +08:00
SWHL 8eb4aaef9f docs: add Backer 2026-09-23 13:14:58 +08:00
SWHL 64b1c680be feat: support decoding images from memory addresses (issue #738) 2026-09-15 09:48:12 +08:00
SWHL c1ec6054a7 build(python): make OpenCV headless by default with optional GUI support (issue #737) 2026-09-15 09:21:54 +08:00
SWHL cbea36ab3d chore: ignore bundled OCR model files 2026-09-15 08:19:43 +08:00
SWHL 4a3070f304 feat(models): add multilingual model routing and licensing metadata. (issue #739) 2026-09-08 10:37:44 +08:00
Tai An 09f4e3b185 fix(nrtr): let generate_square_subsequent_mask take the device it is given (#731)
Transformer.forward_train calls

    tgt_mask = self.generate_square_subsequent_mask(tgt.shape[0], tgt.device)

but the helper only accepts sz, so the training branch of
Transformer.forward raises

    TypeError: Transformer.generate_square_subsequent_mask() takes 2
    positional arguments but 3 were given

The other two call sites (forward_test and forward_beam) pass one
argument and are unaffected.

Accept an optional device and forward it to the two tensor
constructors. It defaults to None, so the one-argument call sites keep
building the mask on the CPU exactly as before, and the call site that
already asks for a device now gets one.
2026-09-03 17:09:26 +08:00
SWHL 0e629c8be0 feat: validate python-bidi before initializing Arabic OCR (issue #719) 2026-08-31 10:21:10 +08:00
SWHL e7edb01237 fix(pytorch): require PyTorch 1.13+ for secure model loading 2026-08-26 09:40:45 +08:00
Patrick Chilton 1087d4a6ec fix: load torch weights with weights_only=True to prevent code execution (#728) 2026-08-26 09:35:55 +08:00
Yuzhong ZhangandYuzhong Zhang 486ec538d3 fix: lock lazy model load so first use constructs once (#725)
Concurrent first calls could initialize det/cls/rec more than once. Double-check each loader under its own lock.

Fixes #724

Co-authored-by: Yuzhong Zhang <BetterAndBetterII@users.noreply.github.com>
2026-08-24 09:37:01 +08:00
SWHL 9ceb3420f5 chore: update pre-commit configuration 2026-08-18 10:47:05 +08:00
SWHL 0ad7c04d8c perf: lazily initialize OCR models 2026-08-18 10:46:31 +08:00
Horatiu George Todoran 667d04c029 fix(mnn): use getNumpyData() instead of getData() for output extraction (#717)
MNNInferSession.__call__ extracted session output via
np.array(out_tensor.getData()).reshape(out_shape), which marshals
tensor contents through a slow per-element Python path. For a
PP-OCRv6 medium recognizer output (~17MB), this cost ~454ms versus
~210ms for the actual GPU inference that produced it.

Switch to getNumpyData(), which exposes the buffer directly. An
explicit copy is required since getNumpyData() returns a view into
memory owned by out_tensor; without it, out_tensor going out of
scope or being reused across shape changes caused intermittent
segfaults.

On a 39-box real-world image, total recognition time dropped from
~22s to ~8.4s. Per-crop output extraction dropped from ~454ms to
~10ms.

Fixes intermittent segfault risk from unmanaged zero-copy tensor
lifetime as a side effect.
2026-08-18 08:15:26 +08:00
SWHL 3efd66a6ba ci: update star-tracker range 2026-07-29 08:32:23 +08:00
SWHL dd48f2d7be fix: update star-history chart 2026-07-29 08:19:51 +08:00
SWHL 095232a4c9 chore: update default_models url v3.9.2 2026-07-21 17:02:26 +08:00
SWHL 3cc33f8d54 feat: add use_preprocess_img and use_vertical_padding logic 2026-07-21 11:50:49 +08:00
SWHL 83866d6a5c feat: add use_preprocess_img and use_apply_vertical_padding parameter 2026-07-21 10:04:08 +08:00
SWHL 44e2e900ec docs: update star history svg 2026-07-09 14:53:11 +08:00
SWHL 096293330e fix: improve IDE support for lazy package exports 2026-07-09 11:22:07 +08:00
SWHL c4db82f7ac test: remove invalid unit testings of tensorrt module 2026-07-09 06:10:27 +08:00
SWHL bce0c99be9 test: add PP-OCRv3 mobile unit testings 2026-07-08 21:31:33 +08:00
SWHL 0fa7a9664c fix: fixed issue #695 2026-07-08 19:23:17 +08:00
SWHL 802c05647f fix: fixed issue #709 2026-07-08 16:04:02 +08:00
SWHL b64a46ffd4 fix: align the performance of the torch version of the PP-OCRv6 Rec tiny model 2026-07-04 22:42:55 +08:00
SWHL 7fe716f8e3 chore: update pre-commit rule v3.9.1 2026-07-02 21:27:14 +08:00
SWHL 28490093df chore: add missing scripts of PyTorch module 2026-07-02 17:58:08 +08:00
SWHL 370f01d0a8 feat: support PP-OCRv6 PyTor as the inference engine 2026-07-02 17:54:27 +08:00
SWHL c18432567f fix: adjust PP-OCRv6 Paddle model key names in YAML config 2026-06-26 16:52:53 +08:00
JinmingMei 29b812fcac feat(python): add PP-OCRv6 paddle backend support (#696)
* feat(python): add PP-OCRv6 paddle backend support

- init_predictor + device_config: add PPOCRV6 to PPOCRV5 branches (PIR format, enable_new_ir/new_executor)

- have_key + get_character_list: read character_dict from inference.yml instead of always returning False

- default_models.yaml: add paddle.PP-OCRv6 det+rec (tiny/small/medium), rec has no dict_url (dict from yml)

- test_engine.py: add EngineType.PADDLE to v6 det/rec parametrize

- Verified: v6 paddle tests pass; v4/v5 paddle regression tests pass

* refactor(python): revert have_key workaround, use dict_url for paddle v6 rec

Now that dict files are available on RapidAI/RapidOCR, revert the have_key/get_character_list workaround that read character_dict from inference.yml. Add dict_url to paddle v6 rec entries pointing to the official dict files.

- paddle/main.py: have_key returns False, get_character_list returns [], remove yml_path logic

- default_models.yaml: add dict_url to paddle v6 rec (tiny/small/medium)

- init_predictor and device_config v6 branches remain (required for PIR format)
2026-06-26 08:32:26 +08:00
SWHL 7980d1887f ci: update openvino version v3.9.0 2026-06-23 10:27:57 +08:00
SWHL 4f4d675a79 chore: update files 2026-06-23 09:54:53 +08:00