Converting ML-CFD models to ONNX
Project description
cfdonnx
A Python module for exporting pre-trained CFD models to ONNX, making them interoperable with other ML frameworks and compatible with browsers.
It currently supports U-Net architecture and PyTorch models, but it will be soon extended to other frameworks and architectures.
Reproducible examples can be found at openfoam-cfd-rom usign DeepCFD.
Installation
The module can be installed with:
pip3 install cfdonnx
Usage
Usage: python3 -m cfdonnx [OPTIONS]
Options:
-n, --net TEXT network architecture: UNetEx or AutoEncoder (default: UNetEx)
-i, --input PATH checkpoint (default: checkpoint.pt)
-o, --output PATH ONNX output file (default: checkpoint.onnx)
-k, --kernel-size INT kernel size (optional, read from state_dict['kernel_size] by default )
-f, --filters TEXT filter size, e.g. 8,16,32,32 (optional, read from state_dict['filters'] by default)
-c --channels INT number of channels (optional, read from state_dict['input_shape'] by default)
-x --nx INT X dimension (optional, read from state_dict['input_shape'] by default)
-y --ny INT Y dimension (optional, read from state_dict['input_shape'] by default )
-o, --output PATH Save model path (default: mymodel.pt)
Example:
python3 -m cfdonnx \
--net UNetEx \
--input flowAroundObstacles.pt \
--output flowAroundObstacles.onnx
You can use your CFD ONNX models on runtime in Babylon.js as showcased at https://play.simzero.com/#D3SFTH#6 for the flowAroundObstacles example.
A generic template for using ONNX is also available at https://play.simzero.com/#WIB297#1.
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
File details
Details for the file cfdonnx-2.0.0.tar.gz
.
File metadata
- Download URL: cfdonnx-2.0.0.tar.gz
- Upload date:
- Size: 8.4 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/3.8.0 colorama/0.4.4 importlib-metadata/4.6.4 keyring/23.5.0 pkginfo/1.8.2 readme-renderer/34.0 requests-toolbelt/0.9.1 requests/2.25.1 rfc3986/1.5.0 tqdm/4.64.1 urllib3/1.26.5 CPython/3.10.6
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | cb01d0129a1af98cb41ff13f3c04bf415c3832525f9b862f43accd4c80178991 |
|
MD5 | 0b79e794a9ef6cbb3005562362d34cbb |
|
BLAKE2b-256 | 605bf1b770e515d9209c4904821eb3d9eb9ef6cb092c9c46f9a6006dbb7c10b1 |
File details
Details for the file cfdonnx-2.0.0-py3-none-any.whl
.
File metadata
- Download URL: cfdonnx-2.0.0-py3-none-any.whl
- Upload date:
- Size: 9.7 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/3.8.0 colorama/0.4.4 importlib-metadata/4.6.4 keyring/23.5.0 pkginfo/1.8.2 readme-renderer/34.0 requests-toolbelt/0.9.1 requests/2.25.1 rfc3986/1.5.0 tqdm/4.64.1 urllib3/1.26.5 CPython/3.10.6
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 6a3f33515b037fbcc02e26d2d85548dbc20a96b02c064fcec88279fd8982f5a5 |
|
MD5 | b9674b889606a5fc0f841830e58a2b72 |
|
BLAKE2b-256 | 20577676dc1b39e3dafff3dc2a91c53aeab5c95c1e81426998267923a17b09e7 |