chore: 使用 ppocrv6 OCR 模型 - #2515
Conversation
📝 WalkthroughWalkthroughOCR默认模型、运行时路径和发布资源均从PP-OCRv5切换为PP-OCRv6。配置会持久化使用PP-OCRv6,并仅生成该模型的下载配置。 ChangesOCR模型升级
Estimated code review effort: 2 (Simple) | ~10 minutes Possibly related PRs
Suggested reviewers: 🚥 Pre-merge checks | ✅ 5✅ Passed checks (5 passed)
✨ Finishing Touches🧪 Generate unit tests (beta)
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. Comment |
There was a problem hiding this comment.
🧹 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
📒 Files selected for processing (2)
src/one_dragon/base/config/basic_model_config.pysrc/one_dragon/base/matcher/ocr/onnx_ocr_matcher.py
|
如果下载不动的话,有卡死用户运行流程的风险 |
|
补充:测试侧已单独处理(测试仓 OneDragon-Anything/zzz-od-test#20 ,已合并)。 测试仓 本 PR(主仓默认切 v6)仍按 @ShadowLemoon 建议待资源下载逻辑重构后再推进。 Follow-up:等本 PR 合入(主仓默认变为 |
There was a problem hiding this comment.
🧹 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
📒 Files selected for processing (4)
src/one_dragon/base/config/basic_model_config.pysrc/onnxocr/onnx_paddleocr.pysrc/onnxocr/utils.pytools/ci/prepare_release_assets.py
本地使用 ppocrv6,测试通过;CI 使用默认 ppocrv5,把 99 识别成 9,测试失败

Summary by CodeRabbit
改进