Skip to content

Conversation

wjj19950828
Copy link
Contributor

PR types

New features

PR changes

Others

Description

Add ONNX model export option

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
Contributor

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
Contributor

@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