Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

【WIP】update for infer config #13524

Open
wants to merge 4 commits into
base: main
Choose a base branch
from

Conversation

tink2123
Copy link
Collaborator

att

Comment on lines 233 to 238
if paddle.__version__ == "0.0.0" or paddle.__version__ >= "3.0.0":
model_path = model_dir
model_prefix = file_name
config = inference.Config(model_path, model_prefix)
else:
config = inference.Config(model_file_path, params_file_path)
Copy link
Collaborator

Choose a reason for hiding this comment

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

这里的改动,是为了适配 PIR 启用后,存储下来的模型文件的变化吧?
正确的判断应该使用 API, 而不是版本号,因为,即便是在 3.0.0 及后续的版本下,也可以通过环境变量来设定是否使用 PIR 。

我不太确定应该用 paddle.framework.in_pir_mode() 还是用paddle.framework.in_pir_executor_mode 来判断。

另外,根据我的理解,如果使用 inference.Config(model_path, model_prefix) 的话,paddle.load 就会自己对新旧模式兼容了?

cc: @phlrain @Aurelius84

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

是的,为了适应PIR。 根据现在的说明文档,inference.Config 只在3.0 以上生效,因此在版本号小于3.0时无法自动判断。

注意:如果套件库需要兼容支持paddle2.x ,需要按照版本做分支处理(config 的新接口只在3.0 beta 版之后提供)

环境变量的使用方式我再确认一下~

Copy link
Collaborator

Choose a reason for hiding this comment

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

注意:如果套件库需要兼容支持paddle2.x ,需要按照版本做分支处理(config 的新接口只在3.0 beta 版之后提供)

这个说明是来自哪儿?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

这个说明是来自哪儿?

是内部的开发文档

Copy link
Collaborator

Choose a reason for hiding this comment

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

我查到了,是新的版本下 inference Config 才能支持传入的是模型目录名的原因吧。
真是令人头大~

@tink2123 tink2123 changed the title update for infer config 【WIP】update for infer config Jul 26, 2024
Copy link

@xiaoguoguo626807 xiaoguoguo626807 left a comment

Choose a reason for hiding this comment

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

LGTM

@CLAassistant
Copy link

CLA assistant check
Thank you for your submission! We really appreciate it. Like many open source projects, we ask that you sign our Contributor License Agreement before we can accept your contribution.
You have signed the CLA already but the status is still pending? Let us recheck it.

GreatV added a commit to GreatV/PaddleOCR that referenced this pull request Nov 16, 2024
jzhang533 added a commit that referenced this pull request Nov 18, 2024
* update infer/utility.py to support json format model

* merge from #13524

* fix bug

* fix bug

* Update tools/infer/utility.py

Co-authored-by: jzhang533 <[email protected]>

* fix codestyle

---------

Co-authored-by: jzhang533 <[email protected]>
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.

4 participants