Skip to content

chore: 使用 ppocrv6 OCR 模型 - #2515

Open
Usagi-wusaqi wants to merge 3 commits into
OneDragon-Anything:mainfrom
Usagi-wusaqi:chore/ocr
Open

chore: 使用 ppocrv6 OCR 模型#2515
Usagi-wusaqi wants to merge 3 commits into
OneDragon-Anything:mainfrom
Usagi-wusaqi:chore/ocr

Conversation

@Usagi-wusaqi

@Usagi-wusaqi Usagi-wusaqi commented Jul 19, 2026

Copy link
Copy Markdown
Collaborator

本地使用 ppocrv6,测试通过;CI 使用默认 ppocrv5,把 99 识别成 9,测试失败
image

Summary by CodeRabbit

改进

  • 默认 OCR 模型已更新为 PP-OCRv6,提升 OCR 识别流程的一致性。
  • OCR 相关配置、调试流程及资源下载配置已同步切换至 PP-OCRv6

@coderabbitai

coderabbitai Bot commented Jul 19, 2026

Copy link
Copy Markdown
Contributor

Review Change Stack

📝 Walkthrough

Walkthrough

OCR默认模型、运行时路径和发布资源均从PP-OCRv5切换为PP-OCRv6。配置会持久化使用PP-OCRv6,并仅生成该模型的下载配置。

Changes

OCR模型升级

Layer / File(s) Summary
OCR模型选择
src/one_dragon/base/matcher/ocr/onnx_ocr_matcher.py, src/one_dragon/base/config/basic_model_config.py
默认OCR模型改为PP-OCRv6。配置值不同时会更新为PP-OCRv6。下载候选项仅保留PP-OCRv6。
运行时模型路径
src/onnxocr/onnx_paddleocr.py, src/onnxocr/utils.py
调试流程及推理参数使用PP-OCRv6的检测模型、识别模型和字符字典路径。
发布资源配置
tools/ci/prepare_release_assets.py
OCR发布资源的标签、匹配模式、备用下载地址和备用名称切换为PP-OCRv6。

Estimated code review effort: 2 (Simple) | ~10 minutes

Possibly related PRs

Suggested reviewers: shadowlemoon, a-nony-mous

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed 标题明确概括了本次将 OCR 模型切换为 ppocrv6 的主要变更。
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🧹 Nitpick comments (1)
src/one_dragon/base/matcher/ocr/onnx_ocr_matcher.py (1)

20-21: 🎯 Functional Correctness | 🔵 Trivial | ⚡ Quick win

不要让 ppocrv6 标识依赖默认模型常量。

PPOCRV6_MODEL_NAME 是具体模型标识,而 DEFAULT_OCR_MODEL_NAME 是可变的默认选择;第 117 行还依赖前者判断是否使用 ppocrv6 的模型尺寸。请保持 PPOCRV6_MODEL_NAME: str = 'ppocrv6',仅修改默认模型常量,避免未来切换默认模型后将其他模型误判为 ppocrv6。

🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@src/one_dragon/base/matcher/ocr/onnx_ocr_matcher.py` around lines 20 - 21, 将
PPOCRV6_MODEL_NAME 改为直接固定为字符串“ppocrv6”,不要引用 DEFAULT_OCR_MODEL_NAME;保留
DEFAULT_OCR_MODEL_NAME 作为独立的可变默认模型配置,确保相关模型尺寸判断始终只匹配 ppocrv6。
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Nitpick comments:
In `@src/one_dragon/base/matcher/ocr/onnx_ocr_matcher.py`:
- Around line 20-21: 将 PPOCRV6_MODEL_NAME 改为直接固定为字符串“ppocrv6”,不要引用
DEFAULT_OCR_MODEL_NAME;保留 DEFAULT_OCR_MODEL_NAME 作为独立的可变默认模型配置,确保相关模型尺寸判断始终只匹配
ppocrv6。

ℹ️ Review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro

Run ID: 82be746c-1205-44c9-a8ff-f57f1bd04d5a

📥 Commits

Reviewing files that changed from the base of the PR and between 1b4db5d and 1bbca12.

📒 Files selected for processing (2)
  • src/one_dragon/base/config/basic_model_config.py
  • src/one_dragon/base/matcher/ocr/onnx_ocr_matcher.py

@ShadowLemoon

Copy link
Copy Markdown
Collaborator

如果下载不动的话,有卡死用户运行流程的风险
建议重构资源下载逻辑后再改

@DoctorReid

Copy link
Copy Markdown
Collaborator

补充:测试侧已单独处理(测试仓 OneDragon-Anything/zzz-od-test#20 ,已合并)。

测试仓 conftest 现在在 ctx.init() 前强制 model_config.ocr = 'ppocrv6',让 CI 与本地测试统一用 ppocrv6,解决了 ppocrv5 把 "99" 识别成 "9" 导致 test_check_battery_charge 在 CI 失败的问题(#2348)。这样不动主仓默认模型(仍 ppocrv5),不影响真实用户下载流程 —— 本 PR 的初衷(修 CI 测试失败)已由测试仓方案覆盖。

本 PR(主仓默认切 v6)仍按 @ShadowLemoon 建议待资源下载逻辑重构后再推进。

Follow-up:等本 PR 合入(主仓默认变为 ppocrv6)后,需要去掉测试仓 conftest 里的强制指定(届时默认即 v6,无需强制),避免冗余。

@ShadowLemoon

Copy link
Copy Markdown
Collaborator

#2521

@Usagi-wusaqi Usagi-wusaqi changed the title chore: 新用户和 action 默认使用 ppocrv6 OCR 模型 chore: 使用 ppocrv6 OCR 模型 Aug 3, 2026

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🧹 Nitpick comments (1)
src/onnxocr/onnx_paddleocr.py (1)

208-215: 📐 Maintainability & Code Quality | 🔵 Trivial | ⚡ Quick win

使用 pathlib 构造调试模型路径。

当前修改仍使用 os.path.join。将 models_dir 转为 Path,再使用 / 拼接路径。传给 ONNX 初始化器时再转换为 str

建议修改
 def __debug():
-    import os
-
     from one_dragon.utils import debug_utils, os_utils

-    models_dir = os_utils.get_path_under_work_dir('assets', 'models', 'onnx_ocr', 'ppocrv6')
+    models_dir = Path(
+        os_utils.get_path_under_work_dir('assets', 'models', 'onnx_ocr', 'ppocrv6')
+    )

     model = ONNXPaddleOcr(
                     use_angle_cls=False, use_gpu=False,
-                    det_model_dir=os.path.join(models_dir, 'det.onnx'),
-                    rec_model_dir=os.path.join(models_dir, 'rec.onnx'),
-                    cls_model_dir=os.path.join(models_dir, 'cls.onnx'),
-                    rec_char_dict_path=os.path.join(models_dir, 'ppocrv6_dict.txt'),
+                    det_model_dir=str(models_dir / 'det.onnx'),
+                    rec_model_dir=str(models_dir / 'rec.onnx'),
+                    cls_model_dir=str(models_dir / 'cls.onnx'),
+                    rec_char_dict_path=str(models_dir / 'ppocrv6_dict.txt'),
                 )

As per coding guidelines:src/**/*.py 的路径操作应使用 pathlib
As per path instructions:路径操作使用 pathlib

🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@src/onnxocr/onnx_paddleocr.py` around lines 208 - 215, Update the model path
setup around models_dir to use pathlib.Path and construct each model file path
with the / operator instead of os.path.join; convert the resulting paths to str
only when passing det_model_dir, rec_model_dir, cls_model_dir, and
rec_char_dict_path to ONNXPaddleOcr.

Sources: Coding guidelines, Path instructions

🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Nitpick comments:
In `@src/onnxocr/onnx_paddleocr.py`:
- Around line 208-215: Update the model path setup around models_dir to use
pathlib.Path and construct each model file path with the / operator instead of
os.path.join; convert the resulting paths to str only when passing
det_model_dir, rec_model_dir, cls_model_dir, and rec_char_dict_path to
ONNXPaddleOcr.

ℹ️ Review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro Plus

Run ID: 672b07b2-fc4e-4f3a-bfaf-6d1e0ee2aa56

📥 Commits

Reviewing files that changed from the base of the PR and between 6565788 and c7c8fbe.

📒 Files selected for processing (4)
  • src/one_dragon/base/config/basic_model_config.py
  • src/onnxocr/onnx_paddleocr.py
  • src/onnxocr/utils.py
  • tools/ci/prepare_release_assets.py

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants