Skip to main content

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


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

cfdonnx-2.0.1.tar.gz (8.4 kB view details)

Uploaded Source

Built Distribution

cfdonnx-2.0.1-py3-none-any.whl (9.7 kB view details)

Uploaded Python 3

File details

Details for the file cfdonnx-2.0.1.tar.gz.

File metadata

  • Download URL: cfdonnx-2.0.1.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

Hashes for cfdonnx-2.0.1.tar.gz
Algorithm Hash digest
SHA256 c27302268541e9c1ffd703dd4b4e1b21ed93e3e453225be6843c48063d325216
MD5 c46e66b8f34246c8da605f552d69c354
BLAKE2b-256 db63da3c5c60e697c1b732f9e8dd7d2da52a8eb40f38de29c3b3d65afdb86f00

See more details on using hashes here.

File details

Details for the file cfdonnx-2.0.1-py3-none-any.whl.

File metadata

  • Download URL: cfdonnx-2.0.1-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

Hashes for cfdonnx-2.0.1-py3-none-any.whl
Algorithm Hash digest
SHA256 784690635f6fedb4f4a5bcf98b170f434a60ad5ffe7da4428dba94745fa32c73
MD5 3e229a44dc363eedcc7ca81b5af22ff9
BLAKE2b-256 4ff3b2afcd5d89e6cb453c8fed9599bcde387ebcc9e32315b847aabc62f61c5f

See more details on using hashes here.

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page