Skip to content

[BugFix] Fix image_features is None crash in PaddleOCR-VL#8096

Open
nandanadileep wants to merge 2 commits into
PaddlePaddle:developfrom
nandanadileep:fix/paddleocr-vl-image-features-none
Open

[BugFix] Fix image_features is None crash in PaddleOCR-VL#8096
nandanadileep wants to merge 2 commits into
PaddlePaddle:developfrom
nandanadileep:fix/paddleocr-vl-image-features-none

Conversation

@nandanadileep

@nandanadileep nandanadileep commented Jul 7, 2026

Copy link
Copy Markdown

Motivation

Fix AttributeError: NoneType object has no attribute cast when image\_features is None during PaddleOCR-VL get\_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 from if image\_token\_num > 0 to if image\_token\_num > 0 and image\_features is not None so embedding replacement only runs when both image tokens exist and image\_features is not None.
  • 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

  • Add at least a tag in the PR title.
  • Format your code, run pre-commit before commit.
  • Add unit tests.
  • Provide accuracy results.
  • If the current PR is submitting to the release branch, make sure the PR has been submitted to the develop branch, then cherry-pick it to the release branch with the [Cherry-Pick] PR tag.

Closes #6179

@CLAassistant

CLAassistant commented Jul 7, 2026

Copy link
Copy Markdown

CLA assistant check
All committers have signed the CLA.

PaddlePaddle-bot

This comment was marked as outdated.

@nandanadileep

Copy link
Copy Markdown
Author

I have read the CLA Document and I hereby sign the CLA

@PaddlePaddle-bot PaddlePaddle-bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

🤖 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 要求的 MotivationModificationsUsage or CommandAccuracy TestsChecklist 结构。

总体评价

主修复将图像 embedding 替换限制在 image_features 非空时执行,能避免 None.cast 崩溃;新增测试覆盖了历史缺口。当前环境缺少 paddle,未能实际运行新增单测,本轮仅完成静态审查和行号/Markdown 校验。

self.assertTrue(paddle.allclose(result[1], paddle.ones([768])))


if __name__ == "__main__":

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

🟡 建议 新增测试文件里保留了 if __name__ == "__main__" 入口。

FastDeploy checklist §C 明确把 test/** 中的 if __name__ == "__main__" 作为环境依赖 hack 表层信号。测试应交给 pytest/unittest 发现机制运行,避免直接执行入口造成 CI/本地执行方式分叉。

建议修复方式:删除文件末尾的入口块,仅保留 TestPaddleOCRVLForConditionalGeneration 用例类。

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.

PaddleOCR-VL runtime error: image_features is None in FastDeploy 2.4.0

3 participants