Skip to content

【PPSCI Export&Infer No.25】bracket #878

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

Merged
merged 27 commits into from
May 8, 2024

Conversation

1want2sleep
Copy link
Contributor

PR types

Others

PR changes

Others

Describe

#788

Copy link

paddle-bot bot commented May 6, 2024

Thanks for your contribution!

Comment on lines 14 to 72
def export(cfg: DictConfig):
# set model
disp_net = ppsci.arch.MLP(**cfg.MODEL.disp_net)
stress_net = ppsci.arch.MLP(**cfg.MODEL.stress_net)
# wrap to a model_list
model = ppsci.arch.ModelList((disp_net, stress_net))

# initialize solver
solver = ppsci.solver.Solver(
model,
pretrained_model_path=cfg.INFER.pretrained_model_path,
)

# export model
from paddle.static import InputSpec

input_spec = [
{key: InputSpec([None, 1], "float32", name=key) for key in model.input_keys},
]
solver.export(input_spec, cfg.INFER.export_path)


def inference(cfg: DictConfig):
from deploy.python_infer import pinn_predictor

predictor = pinn_predictor.PINNPredictor(cfg)
ref_xyzu = ppsci.utils.reader.load_csv_file(
cfg.DEFORMATION_X_PATH,
("x", "y", "z", "u"),
{
"x": "X Location (m)",
"y": "Y Location (m)",
"z": "Z Location (m)",
"u": "Directional Deformation (m)",
},
"\t",
)
input_dict = {
"x": ref_xyzu["x"],
"y": ref_xyzu["y"],
"z": ref_xyzu["z"],
}
output_dict = predictor.predict(input_dict, cfg.INFER.batch_size)

# mapping data to cfg.INFER.output_keys
output_keys = cfg.MODEL.disp_net.output_keys + cfg.MODEL.stress_net.output_keys
output_dict = {
store_key: output_dict[infer_key]
for store_key, infer_key in zip(output_keys, output_dict.keys())
}

ppsci.visualize.save_vtu_from_dict(
"./bracket_pred",
{**input_dict, **output_dict},
input_dict.keys(),
output_keys,
)


Copy link
Collaborator

Choose a reason for hiding this comment

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

这两个函数辛苦移动到evaluate下方吧,按照一般流程的顺序排列

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.不辛苦(●ˇ∀ˇ●)

Copy link
Collaborator

@HydrogenSulfate HydrogenSulfate left a comment

Choose a reason for hiding this comment

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

LGTM

@HydrogenSulfate HydrogenSulfate merged commit 2a1e85a into PaddlePaddle:develop May 8, 2024
2 of 4 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
contributor HappyOpenSource 快乐开源活动issue与PR
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants