[BugFix] Fix image_features is None crash in PaddleOCR-VL#8096
[BugFix] Fix image_features is None crash in PaddleOCR-VL#8096nandanadileep wants to merge 2 commits into
Conversation
|
I have read the CLA Document and I hereby sign the CLA |
PaddlePaddle-bot
left a comment
There was a problem hiding this comment.
🤖 Paddle-CI-Agent | pr_review |
2026-07-08 07:39:41
📋 Review 摘要
PR 概述:修复 PaddleOCR-VL 在 image_features=None 时替换图像 token embedding 崩溃的问题,并补充回归单测。
变更范围:fastdeploy/model_executor/models/paddleocr_vl/、tests/model_executor/
影响面 Tag:[Models]
问题
| 级别 | 文件 | 概述 |
|---|---|---|
| 🟡 建议 | tests/model_executor/test_paddleocr_vl.py:71 |
新增测试文件保留了直接执行入口,命中 FastDeploy checklist §C 的 test 入口表层信号 |
历史 Findings 修复情况
| Finding | 问题 | 状态 |
|---|---|---|
| F1 | 当前 PR 缺少 PaddleOCR-VL image_features=None 回归用例 |
✅ 已修复 |
📝 PR 规范检查
符合规范;标题使用官方 Tag,描述已包含 checklist §D2 要求的 Motivation、Modifications、Usage or Command、Accuracy Tests 和 Checklist 结构。
总体评价
主修复将图像 embedding 替换限制在 image_features 非空时执行,能避免 None.cast 崩溃;新增测试覆盖了历史缺口。当前环境缺少 paddle,未能实际运行新增单测,本轮仅完成静态审查和行号/Markdown 校验。
| self.assertTrue(paddle.allclose(result[1], paddle.ones([768]))) | ||
|
|
||
|
|
||
| if __name__ == "__main__": |
There was a problem hiding this comment.
🟡 建议 新增测试文件里保留了 if __name__ == "__main__" 入口。
FastDeploy checklist §C 明确把 test/** 中的 if __name__ == "__main__" 作为环境依赖 hack 表层信号。测试应交给 pytest/unittest 发现机制运行,避免直接执行入口造成 CI/本地执行方式分叉。
建议修复方式:删除文件末尾的入口块,仅保留 TestPaddleOCRVLForConditionalGeneration 用例类。
Motivation
Fix
AttributeError: NoneType object has no attribute castwhenimage\_featuresisNoneduring PaddleOCR-VLget\_input\_embeddings. This can happen when no image feature is available for the current forward path.Modifications
fastdeploy/model\_executor/models/paddleocr\_vl/paddleocr\_vl.py: Changed condition fromif image\_token\_num > 0toif image\_token\_num > 0 and image\_features is not Noneso embedding replacement only runs when both image tokens exist andimage\_featuresis notNone.tests/model\_executor/test\_paddleocr\_vl.py: Added unit tests covering the three cases (no image tokens + None features, image tokens + None features, image tokens + valid features).Usage or Command
N/A
Accuracy Tests
N/A
Checklist
pre-commitbefore commit.releasebranch, make sure the PR has been submitted to thedevelopbranch, then cherry-pick it to thereleasebranch with the[Cherry-Pick]PR tag.Closes #6179