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

Add ONNX Export #2061

Merged
merged 7 commits into from
May 6, 2022
Merged

Add ONNX Export #2061

merged 7 commits into from
May 6, 2022

Conversation

wjj19950828
Copy link
Contributor

PR types

New features

PR changes

Others

Description

Add ONNX model export option


Args:
input_spec (paddle.static.InputSpec, optional): InputSpec describes the signature information of the model input,
such as shape , dtype , name. Defaults to None.
load_best_model (bool, optional): Load best model. Defaults to False.
output_dir (Optional[str], optional): Output dir to save the exported model. Defaults to None.
export_model_format (Optional[str], optional): Export model format. Defaults to Paddle.
Copy link
Contributor

Choose a reason for hiding this comment

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

注释写清楚有哪些可选项

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Done.

save_path = os.path.join(output_dir, "onnx", "model")
logger.info("Exporting ONNX model to %s" % save_path)
paddle.onnx.export(model, save_path, input_spec=input_spec)
logger.info("ONNX model exported.")
Copy link
Contributor

Choose a reason for hiding this comment

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

处理else的情况,给出明确的提示

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Done.

output_dir: Optional[str]=None):
""" Export paddle inference model.
output_dir: Optional[str]=None,
export_model_format: Optional[str]="Paddle"):
Copy link
Collaborator

Choose a reason for hiding this comment

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

export_model_format 建议小写,内部处理的时候,再统一转一下小写。

export_model_format = export_model_format.lower()

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Done.

ZHUI
ZHUI previously approved these changes May 5, 2022
Copy link
Collaborator

@ZHUI ZHUI left a comment

Choose a reason for hiding this comment

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

LGTM

jiangjiajun
jiangjiajun previously approved these changes May 5, 2022
Copy link
Member

@ZeyuChen ZeyuChen left a comment

Choose a reason for hiding this comment

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

似乎没看见在requirements中新增paddle2onnx依赖

output_dir: Optional[str]=None):
""" Export paddle inference model.
output_dir: Optional[str]=None,
export_model_format: Optional[str]="paddle"):
Copy link
Member

Choose a reason for hiding this comment

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

export_model_format -> model_format
因为函数已经表示当作export,参数变量更多是修饰这个动作即可。

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Done.并在requirements中新增paddle2onnx依赖

@ZeyuChen ZeyuChen self-assigned this May 5, 2022
@ZeyuChen ZeyuChen added the enhancement New feature or request label May 5, 2022
@wjj19950828 wjj19950828 dismissed stale reviews from jiangjiajun and ZHUI via 4091b6a May 6, 2022 02:35
@ZeyuChen ZeyuChen merged commit caa386f into PaddlePaddle:develop May 6, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants