Metadata-Version: 2.4
Name: flow-gym-suite
Version: 0.2.1
Summary: Flow Gym is a toolkit for research and deployment in flow quantification inspired by OpenAI Gym and Stable-Baselines3.
Author-email: Antonio Terpin <aterpin@ethz.ch>, Francesco Banelli <fbanelli@ethz.ch>, Alan Bonomi <abonomi@ethz.ch>
License: MIT License
        
        Copyright (c) 2025 Antonio Terpin
        
        Permission is hereby granted, free of charge, to any person obtaining a copy
        of this software and associated documentation files (the "Software"), to deal
        in the Software without restriction, including without limitation the rights
        to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
        copies of the Software, and to permit persons to whom the Software is
        furnished to do so, subject to the following conditions:
        
        The above copyright notice and this permission notice shall be included in all
        copies or substantial portions of the Software.
        
        THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
        IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
        FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
        AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
        LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
        OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
        SOFTWARE.
        
Project-URL: Homepage, https://github.com/antonioterpin/flowgym
Project-URL: Repository, https://github.com/antonioterpin/flowgym
Project-URL: Documentation, https://github.com/antonioterpin/flowgym#readme
Project-URL: Issues, https://github.com/antonioterpin/flowgym/issues
Classifier: Development Status :: 4 - Beta
Classifier: Intended Audience :: Science/Research
Classifier: Intended Audience :: Developers
Classifier: License :: OSI Approved :: MIT License
Classifier: Operating System :: OS Independent
Classifier: Programming Language :: Python :: 3
Requires-Python: >=3.11
Description-Content-Type: text/markdown
License-File: LICENSE
Requires-Dist: jax>=0.6.0
Requires-Dist: flax>=0.12.7
Requires-Dist: ipywidgets
Requires-Dist: robo-goggles>=0.3.7
Requires-Dist: pip>=26.1
Requires-Dist: scipy>=1.11.0
Requires-Dist: typeguard>=4.4
Provides-Extra: docs
Requires-Dist: Sphinx==9.0.4; extra == "docs"
Requires-Dist: myst-parser==5.1.0; extra == "docs"
Requires-Dist: sphinx-rtd-theme==3.1.0; extra == "docs"
Provides-Extra: other-methods
Requires-Dist: pyoptflow; extra == "other-methods"
Requires-Dist: openpiv; extra == "other-methods"
Requires-Dist: opencv-contrib-python-headless; extra == "other-methods"
Requires-Dist: torch>=1.13.1; extra == "other-methods"
Requires-Dist: torchvision>=0.14.1; extra == "other-methods"
Provides-Extra: wandb
Requires-Dist: robo-goggles[wandb]; extra == "wandb"
Provides-Extra: hf
Requires-Dist: synthpix[hf]>=0.4.0; extra == "hf"
Provides-Extra: cuda12
Requires-Dist: jax[cuda12]>=0.6.0; extra == "cuda12"
Provides-Extra: cuda13
Requires-Dist: jax[cuda13]>=0.10.1; extra == "cuda13"
Dynamic: license-file

# Flow Gym: a research toolkit for flow-field quantification

[![arXiv](https://img.shields.io/badge/arXiv-2512.20642-b31b1b.svg)](https://arxiv.org/abs/2512.20642)
[![Python 3.10+](https://img.shields.io/badge/python-3.10%2B-blue.svg)](https://www.python.org/downloads/)
[![GitHub stars](https://img.shields.io/github/stars/antonioterpin/flowgym?style=social)](https://github.com/antonioterpin/flowgym/stargazers)
[![PyPI version](https://img.shields.io/pypi/v/flow-gym-suite.svg)](https://pypi.org/project/flow-gym-suite)
[![License: MIT](https://img.shields.io/badge/License-MIT-yellow.svg)](https://opensource.org/licenses/MIT)
[![uv](https://img.shields.io/endpoint?url=https://raw.githubusercontent.com/astral-sh/uv/main/assets/badge/v0.json)](https://github.com/astral-sh/uv)

Flow Gym is a Python toolkit for developing, benchmarking, training, and
deploying flow-field quantification methods. It provides a standardized
estimator interface, JAX-first implementations, interoperable wrappers for
external methods, and shared workflows for repeatable evaluation and
training.

![The Flow Gym environment](docs/flowgym.jpg)

## What Flow Gym provides

- Unified estimator construction through `flowgym.make`
- A shared `Estimator` interface for classical and learning-based methods
- Flow-field and density estimator implementations under `flowgym.flow` and
  `flowgym.density`
- JAX-native implementations together with wrappers for representative
  external libraries
- Training, evaluation, benchmarking, and comparison orchestration through
  `src/main.py`
- Cache-backed helpers for repeated dataset passes and expensive derived
  data

## Install

```bash
uv add flow-gym-suite
```

With `pip` instead:

```bash
pip install flow-gym-suite
```

For local repository work:

```bash
uv sync --group dev
```

## Minimal API example

```python
import jax
import jax.numpy as jnp

from flowgym.make import make_estimator

estimator_config = {
    "estimator": "dis_jax",
    "estimate_type": "flow",
    "config": {
        "jit": False,
        "preset": 1,
    },
}

image_shape = (1, 64, 64)
estimate_shape = (1, 64, 64, 2)

trained_state, create_state_fn, compute_estimate_fn, estimator = make_estimator(
    estimator_config=estimator_config,
    image_shape=image_shape,
    estimate_shape=estimate_shape,
    rng=0,
)

prev = jnp.zeros(image_shape, dtype=jnp.float32)
curr = jnp.ones(image_shape, dtype=jnp.float32)
state = create_state_fn(prev, jax.random.PRNGKey(0))
new_state, metrics = compute_estimate_fn(curr, state, trained_state)
```

This is the smallest public API loop in Flow Gym. For repository-backed
examples, benchmarking workflows, and CLI usage, use the docs pages linked
below.

## CLI example

```bash
uv run python src/main.py \
  --mode eval \
  --estimator src/flowgym/config/estimators/flow/real_dis.yaml \
  --dataset src/flowgym/config/piv_dataset_class1_eval.yaml
```

## Documentation

The canonical human-facing docs start at [docs/index.md](docs/index.md).

- [Getting started](docs/getting-started/index.md)
- [Example workflows](docs/examples/index.md)
- [API reference](docs/api/index.md)
- [Architecture guide](docs/contribute/architecture.md)
- [Contributing guide](docs/contribute/contributing.md)

If you are new to the project, start with
[docs/getting-started/index.md](docs/getting-started/index.md) for the motivation,
installation paths, and first estimator example.

## Caching examples

The repository includes two documented caching walkthroughs:

- [DIS caching example](docs/examples/caching.md) backed by
  `examples/10_caching.py`
- [RAFT caching example](docs/examples/caching.md) backed by
  `examples/11_caching.py`

## Contributing

Contributions are welcome. For current setup, quality gates, docs workflow,
and repository navigation, use [docs/contribute/contributing.md](docs/contribute/contributing.md).

## Citation

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

```bibtex
@article{banelli2026flowgym,
   title={Flow Gym: A framework for the development, benchmarking, training, and deployment of flow-field quantification methods},
   author={Banelli, Francesco and Terpin, Antonio and Bonomi, Alan and D'Andrea, Raffaello},
   journal={SoftwareX},
   volume={34},
   pages={102641},
   year={2026},
   doi={10.1016/j.softx.2026.102641}
}
```

## License

This project is licensed under the MIT License. See [LICENSE](LICENSE).
