Skip to content

Latest commit

 

History

History
75 lines (51 loc) · 3.83 KB

README.md

File metadata and controls

75 lines (51 loc) · 3.83 KB

Interactive painter to experiment with oriented and non-oriented mean curvature models found by machine learning

nnpf

For the original article about the associated models and results, see Learning phase field mean curvature flows with neural networks, Bretin & Denis & Masnou & Terii, 2022 and on arXiv. It relies on PyTorch and Lightning throught the dedicated package nnpf (see also the GitHub repository).

Requirements

You need at least a Python 3.8 and the nnpf package available on Pypi:

pip install nnpf

Models

Three models are available:

  • for an oriented isotropic mean-curvature flow,
  • for an non-oriented isotropic mean-curvature flow,
  • for an non-oriented anisotropic mean-curvature flow (distance from l⁴ norm).

The models code are in models.py`.

The checkpoints are available in logs of the main branch of this repository. If you want to train it by yourself, you can checkout the no_data branch instead or remove the logs folder and launch the training using:

make

If you want to use a GPU:

make options="--gpus=1"

And if your GPU has enough memory to store the whole dataset (~2.5GiB):

make options="--gpus=1 --force_gpu"

Launching

You need to specify the checkpoint path when launching the script anim.py:

  • for the oriented isotropic mean-curvature flow: python anim.py logs/ModelDR/oriented_lp2_k17_zeros_s0
  • for the non-oriented isotropic mean-curvature flow: python anim.py logs/ResidualParallel/nonoriented_lp2_k17_zeros_s1
  • for the non-oriented anisotropic mean-curvature flow: python anim.py logs/ResidualParallel/nonoriented_lp4_k17_zeros_s1

Note that the script must be launched from the folder where the model lies (commonly where the logs folder is) so that the loading process can find the model's file and class.

If you want to use a GPU for the inference, add the --gpu options. You can also specify the domain's bounds with the --bounds option:

python anim.py --bounds [-1,1]x[-1,1] logs/ResidualParallel/nonoriented_lp4_k17_zeros_s1

and start paused with --display_step 0.

Usage

Once launched, you can draw a phase with the left click and erase with the right click.

You can add an inclusion disk (there will be always a phase at that positon) at the cursor position with the d key, change its radius using the left click, move it using the middle click and delete it with the Suppr key.

The same way, you can add an exclusion disk (there will be never be a phase at that positon) with the D key, an inclusion/exclusion circle (c and C keys) or an inclusion/exclusion segment (t and T keys, use the left click to validat the end point).

You can also add passive particles that will (try) to follow the flow of the animation. It can be added at current position with p key, or initialy projected to the nearest interface with the P key.

Animation speed can be modified through the number of iterations per frame that is initialy set at 1 but can be decreased with the - key (0 means that the animation is paused) and increased with the + key.

Additionally, some informations may be displayed on the figure with the i key (otherwise, they are only displayed in the terminal).

And finally, you can record the animation using the r key to start and stop recording.

Enjoy!

Demo

nnpf_paint2d_record.webm