Metadata-Version: 2.4
Name: flowgym
Version: 1.3
Summary: Flow Gym
Project-URL: Homepage, https://github.com/cristianpjensen/flowgym
Project-URL: Issues, https://github.com/cristianpjensen/flowgym/issues
Author: Cristian Perez Jensen
License: MIT License
        
        Copyright (c) 2025 Cristian Perez Jensen
        
        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.
License-File: LICENSE
Requires-Python: <3.12,>=3.8
Requires-Dist: polars<2,>=1.34.0
Requires-Dist: torch==2.3.1
Requires-Dist: torchvision==0.18.1
Requires-Dist: tqdm
Requires-Dist: typing-extensions
Provides-Extra: all
Requires-Dist: clip; extra == 'all'
Requires-Dist: dgl; extra == 'all'
Requires-Dist: diffusers==0.33.1; extra == 'all'
Requires-Dist: image-reward; extra == 'all'
Requires-Dist: meeko==0.6.1; extra == 'all'
Requires-Dist: open-clip-torch; extra == 'all'
Requires-Dist: peft==0.5.0; extra == 'all'
Requires-Dist: prody; extra == 'all'
Requires-Dist: rdkit-stubs; extra == 'all'
Requires-Dist: rdkit>=2023.9.4; extra == 'all'
Requires-Dist: transformers<4.43; extra == 'all'
Provides-Extra: images
Requires-Dist: clip; extra == 'images'
Requires-Dist: diffusers==0.33.1; extra == 'images'
Requires-Dist: image-reward; extra == 'images'
Requires-Dist: open-clip-torch; extra == 'images'
Requires-Dist: peft==0.5.0; extra == 'images'
Requires-Dist: transformers<4.43; extra == 'images'
Provides-Extra: molecules
Requires-Dist: dgl; extra == 'molecules'
Requires-Dist: meeko==0.6.1; extra == 'molecules'
Requires-Dist: prody; extra == 'molecules'
Requires-Dist: rdkit-stubs; extra == 'molecules'
Requires-Dist: rdkit>=2023.9.4; extra == 'molecules'
Description-Content-Type: text/markdown

# Flow Gym

<div align="center">
  <img src="docs/_static/teaser.gif" width="100%" />
</div>

<p align="center">
<a href="https://github.com/cristianpjensen/flow-gym/blob/master/LICENSE"><img alt="License" src="https://img.shields.io/github/license/cristianpjensen/flowgym"></a>
<a href="https://github.com/astral-sh/ruff"><img alt="Code style: ruff" src="https://img.shields.io/badge/code%20style-ruff-000000.svg"></a>
</p>

`flowgym` is a library for reward adaptation of any pre-trained flow model on any data modality.

## Installation

In order to install *flowgym*, execute the following command:
```bash
pip install flowgym
```

If you want access to pre-trained image or molecular generation models, specify them as options:
```bash
pip install flowgym[images]
pip install flowgym[molecules]
```

If you want to run value matching on your environment, you will need to install it:
```bash
pip install value_matching
```

## High-level overview

Diffusion and flow models are largely agnostic to their data modality. They only require that the underlying data type supports a small set of operations. Building on this idea, *flowgym* is designed to be fully modular. You only need to provide the following:
 * Data type that implements `DataProtocol`, which defines basic arithmetic operations, factory methods, and gradient methods.
 * Base model `BaseModel[YourDataType]`, which defines the scheduler, how to sample $p_0$, how to compute the forward pass, and how to preprocess and postprocess data.
 * Reward function `Reward[YourDataType]`.

Once these are defined, you can sample from the flow model and apply reward adaptation methods, such as Value Matching.

## Documentation

Much more information can be found in [the documentation](https://cristianpjensen.github.io/flowgym/), including tutorials and API references.
