Skip to content

Conversation

mayiru1021
Copy link
Contributor

PR types

为fourcastnet案例的pretrain.py文件添加export与inference功能

PR changes

添加 export函数,inference函数

Describe

添加 export函数,inference函数,在yaml文件中添加了对应设置,实现了可视化功能。

Copy link

paddle-bot bot commented Apr 3, 2025

Thanks for your contribution!

prefix="wind",
)
visualizer_weather.save(cfg.INFER.export_path, vis_dict)
save_path = save_path = f"{cfg.INFER.export_path}/predict.npz"
Copy link
Collaborator

Choose a reason for hiding this comment

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

Suggested change
save_path = save_path = f"{cfg.INFER.export_path}/predict.npz"
save_path = osp.join(cfg.INFER.export_path, "predict.npz")


# general settings
mode: train # running mode: train/eval
mode: infer # running mode: train/eval
Copy link
Collaborator

Choose a reason for hiding this comment

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

Suggested change
mode: infer # running mode: train/eval
mode: train # running mode: train/eval/export/infer

# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
Copy link
Collaborator

Choose a reason for hiding this comment

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

Suggested change
# limitations under the License.
# limitations under the License.

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.

另外请在fourcastnet.md的开头位置,加上模型导出和推理相关命令

@mayiru1021
Copy link
Contributor Author

另外请在fourcastnet.md的开头位置,加上模型导出和推理相关命令

好的

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.

有几处细节麻烦修改下,没有大问题了

Comment on lines 29 to 49
=== "模型导出命令"

``` sh
# 风速预训练模型导出
python train_pretrain.py mode==export
# 风速微调模型导出
python train_finetune.py mode==export
# 降水量模型导出
python train_precip.py mode==export
```

=== "模型推理命令"

``` sh
# 风速预训练模型推理
python train_pretrain.py mode==infer
# 风速微调模型推理
python train_finetune.py mode==infer
# 降水量模型推理
python train_precip.py mode==infer
```
Copy link
Collaborator

Choose a reason for hiding this comment

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

这里的==是不对的,需要改为=

Comment on lines 43 to 48
# 风速预训练模型推理
python train_pretrain.py mode==infer
# 风速微调模型推理
python train_finetune.py mode==infer
# 降水量模型推理
python train_precip.py mode==infer
Copy link
Collaborator

Choose a reason for hiding this comment

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

Suggested change
# 风速预训练模型推理
python train_pretrain.py mode==infer
# 风速微调模型推理
python train_finetune.py mode==infer
# 降水量模型推理
python train_precip.py mode==infer
# 下载风速预测小样本数据
wget -nc https://paddle-org.bj.bcebos.com/paddlescience%2Fdatasets%2FFourcastNet%2F2018-04-04_n6_precip.npy -P ./datasets/era5/test/
wget -nc https://paddle-org.bj.bcebos.com/paddlescience%2Fdatasets%2FFourcastNet%2F2018-04-04_n6.npy -P ./datasets/era5/test/
# 风速预训练模型推理
python train_pretrain.py mode=infer
# 风速微调模型推理
python train_finetune.py mode=infer
# 降水量模型推理
# 下载降水量预测小样本数据
wget -nc https://paddle-org.bj.bcebos.com/paddlescience%2Fdatasets%2FFourcastNet%2F2018-09-08_n32.npy -P ./datasets/era5/test/
python train_precip.py mode=infer

Comment on lines 424 to 426
xticks=np.linspace(0, 1439, 13),
xticklabels=[str(i) for i in range(360, -1, -30)],
yticks=np.linspace(0, 719, 7),
Copy link
Collaborator

Choose a reason for hiding this comment

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

1439, 719这类magic number建议使用cfg.IMG_W-1之类的变量代替

Comment on lines 366 to 367

output_keys = tuple(f"output_{i}" for i in range(cfg.INFER.num_timestamps))
Copy link
Collaborator

Choose a reason for hiding this comment

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

Suggested change
output_keys = tuple(f"output_{i}" for i in range(cfg.INFER.num_timestamps))
output_keys = tuple(f"output_{i}" for i in range(cfg.INFER.num_timestamps))

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 aab73e3 into PaddlePaddle:develop Apr 9, 2025
3 of 4 checks passed
@luotao1
Copy link
Collaborator

luotao1 commented Apr 22, 2025

hi, @mayiru1021

  • 非常感谢你对飞桨的贡献,我们正在运营一个PFCC组织。PFCC是飞桨开源的贡献者俱乐部,只有给飞桨合入过代码的开发者才能加入,俱乐部里每两周会有一次例会(按兴趣参加),也会时不时办线下meetup面基,详情可见 https://github.com/luotao1 主页说明。
  • 如果你对PFCC有兴趣,请发送邮件至 ext_paddle_oss@baidu.com,我们会邀请你加入~

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.

3 participants