Skip to content

Conversation

@Echo-Nie
Copy link
Contributor

@Echo-Nie Echo-Nie commented Nov 6, 2025

PR Category

Inference

PR Types

Bug fixes

Description

Issue Reproduction

import os
import paddle

model_tag = os.path.exists(r".\模型\PP-DocLayoutV2\inference.pdmodel")
params_tag = os.path.exists(r".\模型\PP-DocLayoutV2\inference.pdiparams")
print("="*20)
print(f"exists: {model_tag}, {params_tag}")
print("="*20)

config = paddle.inference.Config(r".\模型\PP-DocLayoutV2\inference.pdmodel", r".\模型\PP-DocLayoutV2\inference.pdiparams")

dae22e050ed4f9604f05e403fec52add

Solution

  • Fix the issue on Windows where Paddle Inference Config cannot recognize .pdmodel and .json files with Chinese characters in the path.

  • Modify paddle/fluid/inference/api/helper.h for IsFileExists and IsDirectory functions:

    • On Windows, use the WideChar API (_wfopen) to open UTF-8 encoded paths.
    • Keep the Linux/Unix logic unchanged.
  • Add conditional compilation using _WIN32 to ensure cross-platform compatibility.

  • Resolves the previous RuntimeError: Cannot open file caused by Windows ANSI encoding limitations.

Test Results

699ca344d26e36a40baad505da805978

@paddle-bot
Copy link

paddle-bot bot commented Nov 6, 2025

你的PR提交成功,感谢你对开源项目的贡献!
请关注后续CI自动化测试结果,详情请参考Paddle-CI手册
Your PR has been submitted. Thanks for your contribution!
Please wait for the result of CI firstly. See Paddle CI Manual for details.

@paddle-bot paddle-bot bot added the contributor External developers label Nov 6, 2025
@YuanRisheng YuanRisheng merged commit 56dd87e into PaddlePaddle:develop Nov 6, 2025
72 of 74 checks passed
Manfredss pushed a commit to Manfredss/PaddleDebug that referenced this pull request Nov 7, 2025
@Echo-Nie Echo-Nie deleted the fix_CNPath_Windows branch November 11, 2025 10:21
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

contributor External developers

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants