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

【Export Add No.35】nowcastnet #790

Closed
wants to merge 4 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions examples/nowcastnet/conf/nowcastnet.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ hydra:
- TRAIN.checkpoint_path
- TRAIN.pretrained_model_path
- EVAL.pretrained_model_path
- INFER.pretrained_model_path
- mode
- output_dir
- log_freq
Expand Down Expand Up @@ -55,3 +56,6 @@ MODEL:
# evaluation settings
EVAL:
pretrained_model_path: checkpoints/paddle_mrms_model

INFER:
pretrained_model_path: checkpoints/paddle_mrms_model
Copy link
Collaborator

Choose a reason for hiding this comment

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

INFER的预训练模型路径默认值和EVAL不同,需要填写官方提供的预训练模型,避免用户再手动下载再通过参数指定。改为:https://paddle-org.bj.bcebos.com/paddlescience/models/nowcastnet/nowcastnet_pretrained.pdparams

28 changes: 28 additions & 0 deletions examples/nowcastnet/nowcastnet.py
Original file line number Diff line number Diff line change
Expand Up @@ -82,12 +82,40 @@ def evaluate(cfg: DictConfig):
solver.visualize(batch_id)


def export(cfg: DictConfig):
if cfg.CASE_TYPE == "large":
model_cfg = cfg.MODEL.large
elif cfg.CASE_TYPE == "normal":
model_cfg = cfg.MODEL.normal
else:
raise ValueError(
f"cfg.CASE_TYPE should in ['normal', 'large'], but got '{cfg.mode}'"
)
model = ppsci.arch.NowcastNet(**model_cfg)

# 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},
]
Comment on lines +105 to +107
Copy link
Collaborator

Choose a reason for hiding this comment

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

该模型的形状不是[None, 1],应该是[None, 29, 512, 512, 2]

solver.export(input_spec, cfg.INFER.export_path)


@hydra.main(version_base=None, config_path="./conf", config_name="nowcastnet.yaml")
def main(cfg: DictConfig):
if cfg.mode == "train":
train(cfg)
elif cfg.mode == "eval":
evaluate(cfg)
elif cfg.mode == "export":
export(cfg)
else:
raise ValueError(f"cfg.mode should in ['train', 'eval'], but got '{cfg.mode}'")
Copy link
Collaborator

Choose a reason for hiding this comment

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

error信息里加上export


Expand Down