-
Notifications
You must be signed in to change notification settings - Fork 178
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
Conversation
Thanks for your contribution! |
examples/bracket/bracket.py
Outdated
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, | ||
) | ||
|
||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
这两个函数辛苦移动到evaluate下方吧,按照一般流程的顺序排列
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done.不辛苦(●ˇ∀ˇ●)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM
* 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]>
PR types
Others
PR changes
Others
Describe
#788