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

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

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!

ppsci/autodiff/ad.py Outdated Show resolved Hide resolved
examples/bracket/conf/bracket.yaml Outdated Show resolved Hide resolved
examples/bracket/conf/bracket.yaml Outdated Show resolved Hide resolved
examples/bracket/conf/bracket.yaml Outdated Show resolved Hide resolved
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
huohuohuohuohuo123 pushed a commit to huohuohuohuohuo123/PaddleScience that referenced this pull request Aug 12, 2024
* ppsci.equation.PDE.parameters/state_dict/set_state_dict api fix

* ppsci.equation.PDE.parameters/state_dict/set_state_dict api fix

* fix api docs in the timedomain

* fix api docs of timedomain

* fix api docs of timedomain

* ppsci api docs fixed

* ppsci api docs fixed

* ppsci api docs fixed

* add export and infer for bracket

* updata bracket doc

* solve conflict according to the branch named develop

* Update examples/bracket/conf/bracket.yaml

* Update examples/bracket/conf/bracket.yaml

* Update examples/bracket/conf/bracket.yaml

* add export&inference for bracket

---------

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