Repository navigation
ultralytics-inference 0.0.56 Shape right-to-left and complex-script labels in native and web, with up to 2.3x faster label drawing - #604
Conversation
…notator Signed-off-by: Onuralp SEZER <thunderbirdtr@gmail.com>
Signed-off-by: Onuralp SEZER <onuralp@ultralytics.com>
Signed-off-by: Onuralp SEZER <thunderbirdtr@gmail.com>
Signed-off-by: Onuralp SEZER <thunderbirdtr@gmail.com>
|
👋 Hello @onuralpszr, thank you for submitting a
For more guidance, please refer to our Contributing Guide. Don't hesitate to leave a comment if you have any questions. Thank you for contributing to Ultralytics! 🚀 |
Codecov Report❌ Patch coverage is
📢 Thoughts on this report? Let us know! |
UltralyticsAssistant
left a comment
There was a problem hiding this comment.
🔍 PR Review
Made with ❤️ by Ultralytics Actions
Reviewed the native Arabic joining and bidi implementation, web canvas direction changes, and version/documentation updates. The main RTL paths are updated, but native labels with paired punctuation around embedded LTR text still render incorrectly.
💬 Posted 1 inline comment
- 💡 MEDIUM
src/annotate.rs:710This only reorders clusters; it never mirrors characters at odd RTL levels. For an RTL label containing an LTR word in parentheses, such as Hebrew or Arabic text followed by(cat), the rendered parentheses face outward as)cat(instead of enclosing the word.draw_text_mutreceives only this reordered string, so no later bidi-aware renderer corrects it. Apply Unicode bidi mirroring to odd-level characters before collecting the output. (unicode.org)
📋 Skipped 2 files (lock files, generated, images, etc.)
Cargo.lockweb/package-lock.json
…percent handling Signed-off-by: Onuralp SEZER <thunderbirdtr@gmail.com>
UltralyticsAssistant
left a comment
There was a problem hiding this comment.
🔍 PR Review 2
Made with ❤️ by Ultralytics Actions
Since review 1, odd-level bracket mirroring was added, addressing the earlier punctuation finding. The version and web changes look consistent, but native bidi still misorders RTL labels with a trailing percent sign.
💬 Posted 1 inline comment
- 💡 MEDIUM
src/annotate.rs:664For an RTL label ending in a percentage, e.g.عربي 50%,%is classified asNeutralhere. The neutral pass gives it level 1, so reordering puts it before the digits (%50). Unicode bidi rule W5 treats a percent sign adjacent to European digits as part of the number run; resolve ET characters before the neutral pass so the output remains50%. (unicode.org)
📋 Skipped 2 files (lock files, generated, images, etc.)
Cargo.lockweb/package-lock.json
… each label glyph once per frame Signed-off-by: Onuralp SEZER <thunderbirdtr@gmail.com>
UltralyticsAssistant
left a comment
There was a problem hiding this comment.
🔍 PR Review 3
Made with ❤️ by Ultralytics Actions
Since review 2, the percent resolver distinguishes European from Arabic numbers. I withdraw review 2's requested 50% visual order for Arabic-context digits: UAX #9 applies W2 before W5, converting EN after AL to AN, while W5 attaches terminators to EN. The previous parenthesis-mirroring fix remains; one bounded native mirroring gap remains for other Unicode mirrored characters. Reviewed the native annotator, web canvas direction, and version/documentation updates. (unicode.org)
💬 Posted 1 inline comment
- 📝 LOW
src/annotate.rs:831For an RTL class name containing≤, this fallback leaves U+2264 unchanged, although Unicode's bidi mirroring data maps it to≥(U+2265), so the operator still faces the wrong way. Since odd-level clusters reach this helper, use the Unicode mirroring mapping or cover the supported mirrored operators instead of returning every unlisted character unchanged. (unicode.org)
📋 Skipped 2 files (lock files, generated, images, etc.)
Cargo.lockweb/package-lock.json
…in right-to-left labels Signed-off-by: Onuralp SEZER <thunderbirdtr@gmail.com>
UltralyticsAssistant
left a comment
There was a problem hiding this comment.
🔍 PR Review 4
Made with ❤️ by Ultralytics Actions
Since review 3, the added mirror-pair table addresses the earlier ≤ example. Native RTL mirroring still misses Unicode pairs such as ∈/∋; the rest of the reviewed native, web, and version/documentation changes show no new actionable issue.
💬 Posted 1 inline comment
- 📝 LOW
src/annotate.rs:807Since review 3, this table adds the≤/≥pair, fixing that example, but other mirrored characters still pass through unchanged. For an RTL label such asעברית ∈ שלום, U+2208 (∈) should mirror to U+220B (∋), but that pair is absent here, so the operator faces the wrong way. Use the Unicode mirroring mapping or add the supported pairs.
📋 Skipped 2 files (lock files, generated, images, etc.)
Cargo.lockweb/package-lock.json
… only Arabic-Indic digits Signed-off-by: Onuralp SEZER <thunderbirdtr@gmail.com>
UltralyticsAssistant
left a comment
There was a problem hiding this comment.
🔍 PR Review 5
Made with ❤️ by Ultralytics Actions
Since review 4, the mirror table adds the ∈/∋ pair and resolves the prior finding. The native RTL formatting, glyph caching, browser direction, and version updates otherwise look consistent, but classification-only and OBB-only RTL labels can still use the non-Unicode font. Reviewed scope: native annotations, browser canvas changes, and release/version documentation; this font-selection gap remains.
💬 Posted 1 inline comment
- 💡 MEDIUM
src/annotate.rs:1464For classification-only results (probsset,boxesabsent), the font-selection flag inannotate_image_with_optionschecks onlyresult.boxes, so this new RTL path still loadsArial.ttfinstead of the Unicode font and Arabic/Hebrew names render as missing glyphs. The same gap affects OBB-only results routed throughdraw_label. Include names from every rendered task, including classification and OBB, when selecting the Unicode font.
📋 Skipped 2 files (lock files, generated, images, etc.)
Cargo.lockweb/package-lock.json
…I names too Signed-off-by: Onuralp SEZER <thunderbirdtr@gmail.com>
UltralyticsAssistant
left a comment
There was a problem hiding this comment.
🔍 PR Review 6
Made with ❤️ by Ultralytics Actions
Since review 5, the Unicode-font selection gap for classification and OBB labels is addressed. The native RTL, browser direction, and version/documentation changes otherwise look consistent. One rendering issue remains: combining marks are reordered with their base but are not positioned over it.
💬 Posted 1 inline comment
- 💡 MEDIUM
src/annotate.rs:901For labels containing Hebrew points or Arabic harakat,visual_orderkeeps each mark with its base character, but this rasterizer still places the mark at the current caret—after the base glyph’s advance—and does not apply mark-to-base positioning. The marks therefore render beside or after the base instead of over it. Position combining-mark glyphs relative to their base before rasterizing so vowelized RTL labels render correctly.
📋 Skipped 2 files (lock files, generated, images, etc.)
Cargo.lockweb/package-lock.json
Signed-off-by: Onuralp SEZER <thunderbirdtr@gmail.com>
UltralyticsAssistant
left a comment
There was a problem hiding this comment.
🔍 PR Review 7
Made with ❤️ by Ultralytics Actions
Since review 6, combining marks now receive explicit horizontal placement over their base. I reviewed the native RTL rendering, browser direction handling, and version/documentation updates; one bounded rendering issue remains for Arabic Extended-A combining marks, which can break joining and detach from their base.
💬 Posted 1 inline comment
- 📝 LOW
src/annotate.rs:535Arabic Extended-A combining marks such as U+08D3 (ARABIC SMALL LOW WAW) are omitted fromis_mark. In a label such asب࣓ت,join_arabictreats the mark as a boundary, so the adjacent letters do not join;visual_ordercan also separate the mark from its base. Include the relevant Arabic Extended-A combining-mark code points here. (unicode.org)
📋 Skipped 2 files (lock files, generated, images, etc.)
Cargo.lockweb/package-lock.json
…luding Arabic Extended-A Signed-off-by: Onuralp SEZER <thunderbirdtr@gmail.com>
Signed-off-by: Onuralp SEZER <thunderbirdtr@gmail.com>
…dth digits and grouped numbers keep their order Signed-off-by: Onuralp SEZER <thunderbirdtr@gmail.com>
…o-left labels Signed-off-by: Onuralp SEZER <thunderbirdtr@gmail.com>
Signed-off-by: Onuralp SEZER <thunderbirdtr@gmail.com>
…d sin dots sit on the right side Signed-off-by: Onuralp SEZER <thunderbirdtr@gmail.com>
UltralyticsAssistant
left a comment
There was a problem hiding this comment.
🔍 PR Review 9
Made with ❤️ by Ultralytics Actions
Since review 8, the author’s FriBiDi verification settles the Arabic-Indic digit-order concern. This pass found a native kerning regression for labels containing kerning pairs; the other reviewed RTL, web, and version changes show no new actionable issues.
💬 Posted 1 inline comment
- 📝 LOW
src/annotate.rs:1065When a label contains a kerning pair, this applieskern(id, prev)after the current glyph's position and advance have already been computed. The pair is therefore drawn without kerning, and the adjustment is applied to the following glyph instead, changing native label spacing from the previous renderer. Apply kerning before computing the current glyph's position and advance.
📋 Skipped 2 files (lock files, generated, images, etc.)
Cargo.lockweb/package-lock.json
…rabic and bidi tables Signed-off-by: Onuralp SEZER <onuralp@ultralytics.com>
UltralyticsAssistant
left a comment
There was a problem hiding this comment.
🔍 PR Review 10
Made with ❤️ by Ultralytics Actions
Since review 9, the author clarified that kerning behavior matches imageproc, and the earlier font-selection, combining-mark, mirroring, and digit-order concerns are resolved. I reviewed the current native annotation, browser direction, and version/documentation changes; no new actionable issue remains. LGTM.
📋 Skipped 2 files (lock files, generated, images, etc.)
Cargo.lockweb/package-lock.json
Signed-off-by: Onuralp SEZER <onuralp@ultralytics.com>
… text Signed-off-by: Onuralp SEZER <onuralp@ultralytics.com>
Signed-off-by: Onuralp SEZER <onuralp@ultralytics.com>
…ure the classification panel from that layout Signed-off-by: Onuralp SEZER <thunderbirdtr@gmail.com>
…es shaping as fast as the hand-written layout Signed-off-by: Onuralp SEZER <thunderbirdtr@gmail.com>
…ts and measure each run once Signed-off-by: Onuralp SEZER <thunderbirdtr@gmail.com>
… READMEs Signed-off-by: Onuralp SEZER <thunderbirdtr@gmail.com>
…bracket runs Signed-off-by: Onuralp SEZER <thunderbirdtr@gmail.com>
Signed-off-by: Onuralp SEZER <thunderbirdtr@gmail.com>
…has loaded it in this thread Signed-off-by: Onuralp SEZER <thunderbirdtr@gmail.com>
… in its resolved direction Signed-off-by: Onuralp SEZER <thunderbirdtr@gmail.com>
…s for the label background Signed-off-by: Onuralp SEZER <thunderbirdtr@gmail.com>
…web READMEs Signed-off-by: Onuralp SEZER <thunderbirdtr@gmail.com>
ultralytics-inference 0.0.56 Draw Arabic and Hebrew labels right to left in native and webultralytics-inference 0.0.56 Shape right-to-left and complex-script labels in native and web for up to 2.3x faster label drawing
ultralytics-inference 0.0.56 Shape right-to-left and complex-script labels in native and web for up to 2.3x faster label drawingultralytics-inference 0.0.56 Shape right-to-left and complex-script labels in native and web, with up to 2.3x faster label drawing
|
🎉 PR #604 has been merged—thank you, @onuralpszr, for improving right-to-left label rendering and speeding up annotation in
That attention to shaping, measurement, and bidi handling helps Arabic, Hebrew, and mixed-script labels render correctly across native and browser annotations. |
✨ Highlights
harfrust(the Rust port of HarfBuzz) and ordered withunicode-bidi, the same pictures as Python with Raqm📈 Speed
Native label drawing on a 1280x720 frame, release build, median of 41 runs:
Browser
annotate()keeps main's speed for labels without right-to-left text (300 COCO labels: 0.53 ms in WebKit, 0.62 ms in Chromium, 1.5 ms in Firefox). Right-to-left labels are drawn as resolved runs with each run measured once, so 300 Arabic labels take 3.48, 1.57 and 5.83 ms (main 1.68, 0.55 and 5.0 ms), and 20 take 0.28, 0.22 and 0.72 ms.✅ Checked
%, currency signs, vowel marks, direction marks and isolates draw the same glyphs at the same positions as Pillow with Raqm (FriBiDi and HarfBuzz) on the Ultralytics Arial Unicode font, plus 57 focused cases such as shin and sin dots, lam-alef with a vowel, shadda with fatha, full-width digits and numbers grouped with no-break spaces.ffkerning intraffic light, so Latin labels move by at most a pixel of rounding compared with main.🛠️ PR Summary
Made with ❤️ by Ultralytics Actions
🌟 Summary
Releases
ultralytics-inferenceand@ultralytics/yolo0.0.56 with correct right-to-left Arabic and Hebrew labels in native and browser annotations, and up to 2.3x faster label drawing.📊 Key Changes
unicode-bidiruns split by script and shaped byharfrust, and draws the shaped glyphs withab_glyph, so measuring and drawing use the same layout.猫no longer draw as boxes.unicode-bidiruns, each wrapped in an override for its resolved direction, since Safari does not pair brackets in right-to-left canvas text, and letsannotate()take awasmUrlfor pages that load the engine only in a worker.harfrustandunicode-bidito theannotatefeature andunicode-bidito the web crate, and lists them in the READMEs.Cargo.toml,crates/web/Cargo.toml,web/package.json, both lockfiles and the docs.🎯 Purpose & Impact
📋 Skipped 2 files (lock files, generated, images, etc.)
Cargo.lockweb/package-lock.json