Skip to main content

SynthPix: A lightspeed PIV images generator 🌊

GitHub stars License: MIT codecov Tests PyPI version

SynthPix is a synthetic image generator for Particle Image Velocimetry (PIV) with a focus on performance and parallelism on accelerators, implemented in JAX. SynthPix supports the same configuration parameters as existing tools but achieves a throughput several orders of magnitude higher in image-pair generation per second, enabling comprehensive validation and comparison of PIV algorithms, rapid experimental design iterations, and the development of data-hungry methods. The SynthPix image generation pipeline

In a nutshell, if you need many synthetic PIV images and you do not want to wait ages, you are better off with SynthPix 😄. Below are the performances (image pairs per second) with and without GPU for different batch sizes B. Performances

SynthPix is also fairly easy to use:

import synthpix

sampler = synthpix.make(config_path)
for i, batch in enumerate(sampler):
   """batch contains images1, images2, flow_fields, params"""
sampler.shutdown()

See src/main.py for a fully working example. For long-running training, check out our Checkpointing Guide to ensure bit-perfect reproducibility 💾.

Getting started 🚀

Alright, now that hopefully we convinced you to try SynthPix, let's get to it. Don't worry, installing it is even easier than using it:

uv add synthpix

If you have CUDA GPUs,

uv add "synthpix[cuda12]"

If you have issues with CUDA drivers, please follow the official instructions for cuda12 and cudnn (Note: wheels only available on linux). Make sure that LD_LIBRARY_PATH is not set; see the JAX docs:

unset LD_LIBRARY_PATH

Check out our instructions for installing SynthPix from source. You can of course also use pip.

To generate the images, you need flow data. We provide two scripts to download the commonly used PIV datasets:

sh scripts/download_piv_1.sh <output_folder> <configs_directory>
sh scripts/download_piv_2.sh <output_folder> <configs_directory>

These scripts will automatically save also one configuration file each in <configs_directory>. You can use these paths as in the example above.

For more examples and tutorials to use custom flow data or real-world data, check out our tutorials page.

Configuring the synthetic images ⚙️

Configuration is handled through a YAML file, organized into four main groups. Here’s a quick guide to what each set of parameters does:

1. Dataset Parameters

These parameters allow you to customize how flow field extraction works and the shape of the output batch.

Parameter Description
seed Random seed for reproducibility
batch_size Number of image pairs generated at once
flow_fields_per_batch Number of unique flow fields per batch
batches_per_flow_batch Number of batches generated before updating to a new set of flow fields

2. Image Generation Parameters

Define the look and realism of your synthetic PIV images.

Parameter Description
image_shape Output image size [height, width] (pixels)
dt Time between frames (seconds)
seeding_density_range Range of particle densities (particles per pixel)
diameter_ranges List of possible ranges for particle sizes (in pixels). (see below)
diameter_var Variability in particle size
intensity_ranges List of possible intensity (brightness) ranges. (see below)
intensity_var Variability in intensity
p_hide_img1 / p_hide_img2 Per-particle probability of being hidden in image 1 (or 2).
rho_ranges List of possible correlation coefficients ranges. (see below)
rho_var Variability in correlation
noise_uniform Maximum amplitude of uniform noise added to the image.
noise_gaussian_mean Mean of Gaussian noise added to the image.
noise_gaussian_std Standard deviation of Gaussian noise added to the image.
mask (optional) Path to a .npy file containing a binary mask (0 and 1) with shape image_shape.
histogram (optional) Path to a .npy file with a 1D array of shape (256,), summing to the number of image pixels. Used to remap output intensities.

For diameter_ranges, intensity_ranges, and rho_ranges, each parameter is a list of possible ranges. For every image pair, one range is randomly selected (uniformly) from each list, and then the particle parameters are sampled from these selected ranges.

Each *_var parameter controls how much the property of each particle can change between the first and second image of a pair. The change is applied as Gaussian noise with zero mean and variance given by the corresponding *_var value.

Here’s what each *_var parameter controls:

diameter_var: Simulates changes in particle size between frames, making the effect of focus, depth movement, or slight deformations more realistic.

Effect of diameter_var on particle size

Low Medium High

diameter = 2.0 diameter = 2.5 diameter = 3.0

Increasing diameter_var makes particles appear larger and more diffuse.

intensity_var: Models natural brightness changes due to variations in illumination, camera response, or particles moving in and out of the light sheet mimicking out-of-plane motion.

Effect of intensity_var on particle brightness

Low Medium High

intensity = 50 intensity = 150 intensity = 255

Raising the intensity_var parameter produces brighter particles (higher signal-to-noise).

rho_var: Adds variability to the shape and orientation (elongation/rotation) of particles between frames.

Effect of rho_var on particle shape:

Too Low Negative Zero Positive Too High

ρ = -0.9 ρ = -0.5 ρ = 0.0 ρ = 0.5 ρ = 0.9

Increasing the absolute value of rho (correlation coefficient) makes particle spots more elliptical and/or rotated.
Very high values (|ρ| > 0.5, leftmost and rightmost) lead to elongated, line-like particles that are not realistic for PIV images.
For best results, keep rho in the range -0.5 ≤ ρ ≤ 0.5.

Note: The example above uses particles with diameter 2.5. The visual effect of ρ also depends on particle size, larger diameters make elongation more noticeable. As a result, the recommended "safe range" for realistic particle shapes may vary depending on your chosen diameter_ranges.

3. Flow generation parameters

Parameter Description
velocities_per_pixel Spatial resolution of the velocity field
resolution Pixels per unit of physical length

Examples:

Use Case velocities_per_pixel resolution Explanation
Normalized flow field 1.0 100 Flow field has 1 velocity vector per pixel; 100 px = 1 unit of length and flow velocity vectors are in units/s.
Real-world flow in m/s 10.0 50 Flow field has 10 velocity vectors per image pixel (very fine spatial resolution); 50 px = 1 meter and flow in m/s.
Pixel displacement flow 1.0 1.0 Flow field has 1 velocity per pixel; 1 px = 1 unit → flow directly describes pixels/second displacements. (use dt = 1 to convert it in pixels/frame)

4. Flow field parameters

Describe which region of your flow field is captured, and its velocity bounds.

Parameter Description
flow_field_size Physical size of the entire flow field (e.g., in mm × mm). Units must match those in your flow files.
img_offset 2D offset (in physical units, matching flow_field_size) specifying the top-left corner of the region of interest to extract from the flow field.
min_speed_x/y, max_speed_x/y Range of allowed velocities in each direction,
output_units Units used in the returned flow field: "pixels" (converts physical velocities to displacements in pixels using dt and resolution), or "measure units per second" (same units as the input flow field, e.g., mm/s).
file_list List of ground-truth flow field files (e.g. .mat)
scheduler_class Loader class for your flow files (usually by extension). See tutorials for detailed explanations.

Note: min_speed_x/y and max_speed_x/y are not absolute cutoffs, but define the full expected velocity range (positive and negative) along each axis.

These bounds are used to estimate the maximum particle displacement over time (dt). A larger intermediate image is generated accordingly, and the final image pair is cropped from this larger region. This ensures that particles entering the visible frame (image 2) have realistic origins — possibly outside the region of interest in image 1 — making particle "appearance" at the boundaries realistic.

Hugging Face Hub integration 🤗

SynthPix ships an optional integration to push and pull built PIV datasets through a Hugging Face Hub dataset repository, with the on-disk layout preserved byte-for-byte. See the Hugging Face Hub integration guide for installation, authentication, the CLI / Python / build-script workflows, and the license-aware safety gate that defaults to private hosting.

Contributing 🤗

Contributions are more than welcome! 🙏 Please check out our how to contribute page, and feel free to open an issue for problems and feature requests⚠️.

Citation 📈

If you use this code in your research, please cite our paper:

   @article{terpin2026synthpix,
        title={SynthPix: A lightspeed PIV images generator},
        author={Antonio Terpin and Alan Bonomi and Francesco Banelli and Raffaello D'Andrea},
        journal={SoftwareX},
        volume={34},
        pages={102642},
        year={2026},
        doi={10.1016/j.softx.2026.102642},
        url={https://doi.org/10.1016/j.softx.2026.102642},
    }

Metadata

Release files for synthpix 0.4.0

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for synthpix 0.4.0
File Size Uploaded Provenance Actions
synthpix-0.4.0.tar.gz 122.9 kB With provenance Details for synthpix-0.4.0.tar.gz

Built distribution (wheel)

Table of built distributions (wheels) for synthpix 0.4.0
File Interpreter ABI Platform Actions
synthpix-0.4.0-py3-none-any.whl Python 3 none any Details for synthpix-0.4.0-py3-none-any.whl

Total release size: 230.5 kB

Release files / synthpix-0.4.0.tar.gz

Download URL synthpix-0.4.0.tar.gz
Size 122.9 kB
Tags Source
SHA-256 checksum
How to use checksums
d614a250c0557d423ddaff5b8821c7664706de03d7efda39c6f20316eb853f6d
BLAKE2b-256 checksum
How to use checksums
10bfd40112e070a102112685284827c1513c02c652d8c08323ab5862d636e05d
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.16

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Oct 28, 2026.

Transparency log

Release files / synthpix-0.4.0-py3-none-any.whl

Download URL synthpix-0.4.0-py3-none-any.whl
Size 107.6 kB
Tags Python 3
SHA-256 checksum
How to use checksums
f0719c24a53d0e8e307eaf325831a375906844576999a7a3c527bb4017bed8f8
BLAKE2b-256 checksum
How to use checksums
3c61fd47b44bafffd26b52a84ec9fd3686e2a519f441f0818df3784d358e9db1
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.16

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Oct 28, 2026.

Transparency log

Security for synthpix 0.4.0

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

Full provenance

All 2 files in this release have been uploaded with provenance metadata.

Select from 2 files

Attestation for synthpix-0.4.0.tar.gz

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Oct 28, 2026.

Transparency log

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page