rectified-flow-pytorch 0.5.3__tar.gz
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- rectified_flow_pytorch-0.5.3/.github/workflows/python-publish.yml +36 -0
- rectified_flow_pytorch-0.5.3/.github/workflows/test.yml +21 -0
- rectified_flow_pytorch-0.5.3/.gitignore +164 -0
- rectified_flow_pytorch-0.5.3/LICENSE +21 -0
- rectified_flow_pytorch-0.5.3/PKG-INFO +350 -0
- rectified_flow_pytorch-0.5.3/README.md +272 -0
- rectified_flow_pytorch-0.5.3/images/oxford-flowers.sample.png +0 -0
- rectified_flow_pytorch-0.5.3/pyproject.toml +93 -0
- rectified_flow_pytorch-0.5.3/rectified_flow_pytorch/__init__.py +17 -0
- rectified_flow_pytorch-0.5.3/rectified_flow_pytorch/mean_flow.py +320 -0
- rectified_flow_pytorch-0.5.3/rectified_flow_pytorch/nano_flow.py +129 -0
- rectified_flow_pytorch-0.5.3/rectified_flow_pytorch/nano_flow_multi_obj.py +179 -0
- rectified_flow_pytorch-0.5.3/rectified_flow_pytorch/rectified_flow.py +1197 -0
- rectified_flow_pytorch-0.5.3/rectified_flow_pytorch/reflow.py +192 -0
- rectified_flow_pytorch-0.5.3/rectified_flow_pytorch/soflow.py +508 -0
- rectified_flow_pytorch-0.5.3/rectified_flow_pytorch/split_mean_flow.py +283 -0
- rectified_flow_pytorch-0.5.3/rf.png +0 -0
- rectified_flow_pytorch-0.5.3/tests/test_flow.py +122 -0
- rectified_flow_pytorch-0.5.3/train_fpo.py +635 -0
- rectified_flow_pytorch-0.5.3/train_mean_flow.py +57 -0
- rectified_flow_pytorch-0.5.3/train_mean_flow_ql.py +370 -0
- rectified_flow_pytorch-0.5.3/train_nano_rf.py +54 -0
- rectified_flow_pytorch-0.5.3/train_nano_rf_multi_obj.py +54 -0
- rectified_flow_pytorch-0.5.3/train_oxford.py +52 -0
- rectified_flow_pytorch-0.5.3/train_soflow.py +80 -0
- rectified_flow_pytorch-0.5.3/train_split_mean_flow.py +58 -0
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
# This workflow will upload a Python Package using Twine when a release is created
|
|
2
|
+
# For more information see: https://help.github.com/en/actions/language-and-framework-guides/using-python-with-github-actions#publishing-to-package-registries
|
|
3
|
+
|
|
4
|
+
# This workflow uses actions that are not certified by GitHub.
|
|
5
|
+
# They are provided by a third-party and are governed by
|
|
6
|
+
# separate terms of service, privacy policy, and support
|
|
7
|
+
# documentation.
|
|
8
|
+
|
|
9
|
+
name: Upload Python Package
|
|
10
|
+
|
|
11
|
+
on:
|
|
12
|
+
release:
|
|
13
|
+
types: [published]
|
|
14
|
+
|
|
15
|
+
jobs:
|
|
16
|
+
deploy:
|
|
17
|
+
|
|
18
|
+
runs-on: ubuntu-latest
|
|
19
|
+
|
|
20
|
+
steps:
|
|
21
|
+
- uses: actions/checkout@v2
|
|
22
|
+
- name: Set up Python
|
|
23
|
+
uses: actions/setup-python@v2
|
|
24
|
+
with:
|
|
25
|
+
python-version: '3.x'
|
|
26
|
+
- name: Install dependencies
|
|
27
|
+
run: |
|
|
28
|
+
python -m pip install --upgrade pip
|
|
29
|
+
pip install build
|
|
30
|
+
- name: Build package
|
|
31
|
+
run: python -m build
|
|
32
|
+
- name: Publish package
|
|
33
|
+
uses: pypa/gh-action-pypi-publish@27b31702a0e7fc50959f5ad993c78deac1bdfc29
|
|
34
|
+
with:
|
|
35
|
+
user: __token__
|
|
36
|
+
password: ${{ secrets.PYPI_API_TOKEN }}
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
name: Pytest
|
|
2
|
+
on: [push, pull_request]
|
|
3
|
+
|
|
4
|
+
jobs:
|
|
5
|
+
build:
|
|
6
|
+
|
|
7
|
+
runs-on: ubuntu-latest
|
|
8
|
+
|
|
9
|
+
steps:
|
|
10
|
+
- uses: actions/checkout@v4
|
|
11
|
+
- name: Set up Python 3.10
|
|
12
|
+
uses: actions/setup-python@v5
|
|
13
|
+
with:
|
|
14
|
+
python-version: "3.10"
|
|
15
|
+
- name: Install dependencies
|
|
16
|
+
run: |
|
|
17
|
+
python -m pip install --upgrade pip
|
|
18
|
+
python -m pip install -e .[test]
|
|
19
|
+
- name: Test with pytest
|
|
20
|
+
run: |
|
|
21
|
+
python -m pytest tests/
|
|
@@ -0,0 +1,164 @@
|
|
|
1
|
+
results/
|
|
2
|
+
|
|
3
|
+
# Byte-compiled / optimized / DLL files
|
|
4
|
+
__pycache__/
|
|
5
|
+
*.py[cod]
|
|
6
|
+
*$py.class
|
|
7
|
+
|
|
8
|
+
# C extensions
|
|
9
|
+
*.so
|
|
10
|
+
|
|
11
|
+
# Distribution / packaging
|
|
12
|
+
.Python
|
|
13
|
+
build/
|
|
14
|
+
develop-eggs/
|
|
15
|
+
dist/
|
|
16
|
+
downloads/
|
|
17
|
+
eggs/
|
|
18
|
+
.eggs/
|
|
19
|
+
lib/
|
|
20
|
+
lib64/
|
|
21
|
+
parts/
|
|
22
|
+
sdist/
|
|
23
|
+
var/
|
|
24
|
+
wheels/
|
|
25
|
+
share/python-wheels/
|
|
26
|
+
*.egg-info/
|
|
27
|
+
.installed.cfg
|
|
28
|
+
*.egg
|
|
29
|
+
MANIFEST
|
|
30
|
+
|
|
31
|
+
# PyInstaller
|
|
32
|
+
# Usually these files are written by a python script from a template
|
|
33
|
+
# before PyInstaller builds the exe, so as to inject date/other infos into it.
|
|
34
|
+
*.manifest
|
|
35
|
+
*.spec
|
|
36
|
+
|
|
37
|
+
# Installer logs
|
|
38
|
+
pip-log.txt
|
|
39
|
+
pip-delete-this-directory.txt
|
|
40
|
+
|
|
41
|
+
# Unit test / coverage reports
|
|
42
|
+
htmlcov/
|
|
43
|
+
.tox/
|
|
44
|
+
.nox/
|
|
45
|
+
.coverage
|
|
46
|
+
.coverage.*
|
|
47
|
+
.cache
|
|
48
|
+
nosetests.xml
|
|
49
|
+
coverage.xml
|
|
50
|
+
*.cover
|
|
51
|
+
*.py,cover
|
|
52
|
+
.hypothesis/
|
|
53
|
+
.pytest_cache/
|
|
54
|
+
cover/
|
|
55
|
+
|
|
56
|
+
# Translations
|
|
57
|
+
*.mo
|
|
58
|
+
*.pot
|
|
59
|
+
|
|
60
|
+
# Django stuff:
|
|
61
|
+
*.log
|
|
62
|
+
local_settings.py
|
|
63
|
+
db.sqlite3
|
|
64
|
+
db.sqlite3-journal
|
|
65
|
+
|
|
66
|
+
# Flask stuff:
|
|
67
|
+
instance/
|
|
68
|
+
.webassets-cache
|
|
69
|
+
|
|
70
|
+
# Scrapy stuff:
|
|
71
|
+
.scrapy
|
|
72
|
+
|
|
73
|
+
# Sphinx documentation
|
|
74
|
+
docs/_build/
|
|
75
|
+
|
|
76
|
+
# PyBuilder
|
|
77
|
+
.pybuilder/
|
|
78
|
+
target/
|
|
79
|
+
|
|
80
|
+
# Jupyter Notebook
|
|
81
|
+
.ipynb_checkpoints
|
|
82
|
+
|
|
83
|
+
# IPython
|
|
84
|
+
profile_default/
|
|
85
|
+
ipython_config.py
|
|
86
|
+
|
|
87
|
+
# pyenv
|
|
88
|
+
# For a library or package, you might want to ignore these files since the code is
|
|
89
|
+
# intended to run in multiple environments; otherwise, check them in:
|
|
90
|
+
# .python-version
|
|
91
|
+
|
|
92
|
+
# pipenv
|
|
93
|
+
# According to pypa/pipenv#598, it is recommended to include Pipfile.lock in version control.
|
|
94
|
+
# However, in case of collaboration, if having platform-specific dependencies or dependencies
|
|
95
|
+
# having no cross-platform support, pipenv may install dependencies that don't work, or not
|
|
96
|
+
# install all needed dependencies.
|
|
97
|
+
#Pipfile.lock
|
|
98
|
+
|
|
99
|
+
# poetry
|
|
100
|
+
# Similar to Pipfile.lock, it is generally recommended to include poetry.lock in version control.
|
|
101
|
+
# This is especially recommended for binary packages to ensure reproducibility, and is more
|
|
102
|
+
# commonly ignored for libraries.
|
|
103
|
+
# https://python-poetry.org/docs/basic-usage/#commit-your-poetrylock-file-to-version-control
|
|
104
|
+
#poetry.lock
|
|
105
|
+
|
|
106
|
+
# pdm
|
|
107
|
+
# Similar to Pipfile.lock, it is generally recommended to include pdm.lock in version control.
|
|
108
|
+
#pdm.lock
|
|
109
|
+
# pdm stores project-wide configurations in .pdm.toml, but it is recommended to not include it
|
|
110
|
+
# in version control.
|
|
111
|
+
# https://pdm.fming.dev/latest/usage/project/#working-with-version-control
|
|
112
|
+
.pdm.toml
|
|
113
|
+
.pdm-python
|
|
114
|
+
.pdm-build/
|
|
115
|
+
|
|
116
|
+
# PEP 582; used by e.g. github.com/David-OConnor/pyflow and github.com/pdm-project/pdm
|
|
117
|
+
__pypackages__/
|
|
118
|
+
|
|
119
|
+
# Celery stuff
|
|
120
|
+
celerybeat-schedule
|
|
121
|
+
celerybeat.pid
|
|
122
|
+
|
|
123
|
+
# SageMath parsed files
|
|
124
|
+
*.sage.py
|
|
125
|
+
|
|
126
|
+
# Environments
|
|
127
|
+
.env
|
|
128
|
+
.venv
|
|
129
|
+
env/
|
|
130
|
+
venv/
|
|
131
|
+
ENV/
|
|
132
|
+
env.bak/
|
|
133
|
+
venv.bak/
|
|
134
|
+
|
|
135
|
+
# Spyder project settings
|
|
136
|
+
.spyderproject
|
|
137
|
+
.spyproject
|
|
138
|
+
|
|
139
|
+
# Rope project settings
|
|
140
|
+
.ropeproject
|
|
141
|
+
|
|
142
|
+
# mkdocs documentation
|
|
143
|
+
/site
|
|
144
|
+
|
|
145
|
+
# mypy
|
|
146
|
+
.mypy_cache/
|
|
147
|
+
.dmypy.json
|
|
148
|
+
dmypy.json
|
|
149
|
+
|
|
150
|
+
# Pyre type checker
|
|
151
|
+
.pyre/
|
|
152
|
+
|
|
153
|
+
# pytype static type analyzer
|
|
154
|
+
.pytype/
|
|
155
|
+
|
|
156
|
+
# Cython debug symbols
|
|
157
|
+
cython_debug/
|
|
158
|
+
|
|
159
|
+
# PyCharm
|
|
160
|
+
# JetBrains specific template is maintained in a separate JetBrains.gitignore that can
|
|
161
|
+
# be found at https://github.com/github/gitignore/blob/main/Global/JetBrains.gitignore
|
|
162
|
+
# and can be added to the global gitignore or merged into this file. For a more nuclear
|
|
163
|
+
# option (not recommended) you can uncomment the following to ignore the entire idea folder.
|
|
164
|
+
#.idea/
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2024 Phil Wang
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
|
@@ -0,0 +1,350 @@
|
|
|
1
|
+
Metadata-Version: 2.4
|
|
2
|
+
Name: rectified-flow-pytorch
|
|
3
|
+
Version: 0.5.3
|
|
4
|
+
Summary: Rectified Flow in Pytorch
|
|
5
|
+
Project-URL: Homepage, https://pypi.org/project/rectified-flow-pytorch/
|
|
6
|
+
Project-URL: Repository, https://github.com/lucidrains/rectified-flow-pytorch
|
|
7
|
+
Author-email: Phil Wang <lucidrains@gmail.com>
|
|
8
|
+
License: MIT License
|
|
9
|
+
|
|
10
|
+
Copyright (c) 2024 Phil Wang
|
|
11
|
+
|
|
12
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
13
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
14
|
+
in the Software without restriction, including without limitation the rights
|
|
15
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
16
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
17
|
+
furnished to do so, subject to the following conditions:
|
|
18
|
+
|
|
19
|
+
The above copyright notice and this permission notice shall be included in all
|
|
20
|
+
copies or substantial portions of the Software.
|
|
21
|
+
|
|
22
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
23
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
24
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
25
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
26
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
27
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
28
|
+
SOFTWARE.
|
|
29
|
+
License-File: LICENSE
|
|
30
|
+
Keywords: artificial intelligence,deep learning,rectified flow
|
|
31
|
+
Classifier: Development Status :: 4 - Beta
|
|
32
|
+
Classifier: Intended Audience :: Developers
|
|
33
|
+
Classifier: License :: OSI Approved :: MIT License
|
|
34
|
+
Classifier: Programming Language :: Python :: 3.8
|
|
35
|
+
Classifier: Topic :: Scientific/Engineering :: Artificial Intelligence
|
|
36
|
+
Requires-Python: >=3.8
|
|
37
|
+
Requires-Dist: accelerate
|
|
38
|
+
Requires-Dist: einops>=0.8.0
|
|
39
|
+
Requires-Dist: einx>=0.3.0
|
|
40
|
+
Requires-Dist: ema-pytorch>=0.5.2
|
|
41
|
+
Requires-Dist: hyper-connections>=0.1.8
|
|
42
|
+
Requires-Dist: pillow>=9.4.0
|
|
43
|
+
Requires-Dist: scipy
|
|
44
|
+
Requires-Dist: torch>=2.0
|
|
45
|
+
Requires-Dist: torchdiffeq
|
|
46
|
+
Requires-Dist: torchvision
|
|
47
|
+
Provides-Extra: examples
|
|
48
|
+
Requires-Dist: datasets; extra == 'examples'
|
|
49
|
+
Provides-Extra: examples-fpo
|
|
50
|
+
Requires-Dist: adam-atan2-pytorch; extra == 'examples-fpo'
|
|
51
|
+
Requires-Dist: assoc-scan>=0.0.2; extra == 'examples-fpo'
|
|
52
|
+
Requires-Dist: box2d-py; extra == 'examples-fpo'
|
|
53
|
+
Requires-Dist: einops>=0.8.0; extra == 'examples-fpo'
|
|
54
|
+
Requires-Dist: einx>=0.3.0; extra == 'examples-fpo'
|
|
55
|
+
Requires-Dist: ema-pytorch>=0.7.3; extra == 'examples-fpo'
|
|
56
|
+
Requires-Dist: fire; extra == 'examples-fpo'
|
|
57
|
+
Requires-Dist: gymnasium[box2d]>=1.0.0; extra == 'examples-fpo'
|
|
58
|
+
Requires-Dist: hl-gauss-pytorch>=0.1.15; extra == 'examples-fpo'
|
|
59
|
+
Requires-Dist: hyper-connections>=0.2.0; extra == 'examples-fpo'
|
|
60
|
+
Requires-Dist: lion-pytorch; extra == 'examples-fpo'
|
|
61
|
+
Requires-Dist: moviepy>=1.0.3; extra == 'examples-fpo'
|
|
62
|
+
Requires-Dist: numpy>=2.2.5; extra == 'examples-fpo'
|
|
63
|
+
Requires-Dist: torch>=2.4; extra == 'examples-fpo'
|
|
64
|
+
Requires-Dist: tqdm; extra == 'examples-fpo'
|
|
65
|
+
Requires-Dist: x-transformers>=2.3.21; extra == 'examples-fpo'
|
|
66
|
+
Provides-Extra: examples-ql
|
|
67
|
+
Requires-Dist: assoc-scan; extra == 'examples-ql'
|
|
68
|
+
Requires-Dist: box2d-py; extra == 'examples-ql'
|
|
69
|
+
Requires-Dist: fire; extra == 'examples-ql'
|
|
70
|
+
Requires-Dist: gymnasium[box2d]>=1.0.0; extra == 'examples-ql'
|
|
71
|
+
Requires-Dist: moviepy>=1.0.3; extra == 'examples-ql'
|
|
72
|
+
Requires-Dist: numpy>=2.2.5; extra == 'examples-ql'
|
|
73
|
+
Requires-Dist: tqdm; extra == 'examples-ql'
|
|
74
|
+
Requires-Dist: x-mlps-pytorch>=0.0.20; extra == 'examples-ql'
|
|
75
|
+
Provides-Extra: test
|
|
76
|
+
Requires-Dist: pytest; extra == 'test'
|
|
77
|
+
Description-Content-Type: text/markdown
|
|
78
|
+
|
|
79
|
+
<img src="./rf.png" width="400px"></img>
|
|
80
|
+
|
|
81
|
+
## Rectified Flow - Pytorch
|
|
82
|
+
|
|
83
|
+
Implementation of <a href="https://www.cs.utexas.edu/~lqiang/rectflow/html/intro.html">rectified flow</a> and some of its followup research / improvements in Pytorch
|
|
84
|
+
|
|
85
|
+
<a href="https://drscotthawley.github.io/blog/posts/FlowModels.html">Tutorial</a> from <a href="https://github.com/drscotthawley">Dr. Scott Hawley</a>
|
|
86
|
+
|
|
87
|
+
Youtube AI Educators - <a href="https://www.youtube.com/watch?v=7NNxK3CqaDk">Yannic</a> | <a href="https://www.youtube.com/watch?v=7cMzfkWFWhI">Outlier</a>
|
|
88
|
+
|
|
89
|
+
<img src="./images/oxford-flowers.sample.png" width="350px"></img>
|
|
90
|
+
|
|
91
|
+
*32 batch size, 11k steps oxford flowers*
|
|
92
|
+
|
|
93
|
+
## Install
|
|
94
|
+
|
|
95
|
+
```bash
|
|
96
|
+
$ pip install rectified-flow-pytorch
|
|
97
|
+
```
|
|
98
|
+
|
|
99
|
+
## Usage
|
|
100
|
+
|
|
101
|
+
```python
|
|
102
|
+
import torch
|
|
103
|
+
from rectified_flow_pytorch import RectifiedFlow, Unet
|
|
104
|
+
|
|
105
|
+
model = Unet(dim = 64)
|
|
106
|
+
|
|
107
|
+
rectified_flow = RectifiedFlow(model)
|
|
108
|
+
|
|
109
|
+
images = torch.randn(1, 3, 256, 256)
|
|
110
|
+
|
|
111
|
+
loss = rectified_flow(images)
|
|
112
|
+
loss.backward()
|
|
113
|
+
|
|
114
|
+
sampled = rectified_flow.sample()
|
|
115
|
+
assert sampled.shape[1:] == images.shape[1:]
|
|
116
|
+
```
|
|
117
|
+
|
|
118
|
+
For reflow as described in the paper
|
|
119
|
+
|
|
120
|
+
```python
|
|
121
|
+
import torch
|
|
122
|
+
from rectified_flow_pytorch import RectifiedFlow, Reflow, Unet
|
|
123
|
+
|
|
124
|
+
model = Unet(dim = 64)
|
|
125
|
+
|
|
126
|
+
rectified_flow = RectifiedFlow(model)
|
|
127
|
+
|
|
128
|
+
images = torch.randn(1, 3, 256, 256)
|
|
129
|
+
|
|
130
|
+
loss = rectified_flow(images)
|
|
131
|
+
loss.backward()
|
|
132
|
+
|
|
133
|
+
# do the above for many real images
|
|
134
|
+
|
|
135
|
+
reflow = Reflow(rectified_flow)
|
|
136
|
+
|
|
137
|
+
reflow_loss = reflow()
|
|
138
|
+
reflow_loss.backward()
|
|
139
|
+
|
|
140
|
+
# then do the above in a loop many times for reflow - you can reflow multiple times by redefining Reflow(reflow.model) and looping again
|
|
141
|
+
|
|
142
|
+
sampled = reflow.sample()
|
|
143
|
+
assert sampled.shape[1:] == images.shape[1:]
|
|
144
|
+
```
|
|
145
|
+
|
|
146
|
+
With a `Trainer` based on `accelerate`
|
|
147
|
+
|
|
148
|
+
```python
|
|
149
|
+
import torch
|
|
150
|
+
from rectified_flow_pytorch import RectifiedFlow, ImageDataset, Unet, Trainer
|
|
151
|
+
|
|
152
|
+
model = Unet(dim = 64)
|
|
153
|
+
|
|
154
|
+
rectified_flow = RectifiedFlow(model)
|
|
155
|
+
|
|
156
|
+
img_dataset = ImageDataset(
|
|
157
|
+
folder = './path/to/your/images',
|
|
158
|
+
image_size = 256
|
|
159
|
+
)
|
|
160
|
+
|
|
161
|
+
trainer = Trainer(
|
|
162
|
+
rectified_flow,
|
|
163
|
+
dataset = img_dataset,
|
|
164
|
+
num_train_steps = 70_000,
|
|
165
|
+
results_folder = './results' # samples will be saved periodically to this folder
|
|
166
|
+
)
|
|
167
|
+
|
|
168
|
+
trainer()
|
|
169
|
+
```
|
|
170
|
+
|
|
171
|
+
## Examples
|
|
172
|
+
|
|
173
|
+
Quick test on oxford flowers
|
|
174
|
+
|
|
175
|
+
```bash
|
|
176
|
+
$ pip install .[examples]
|
|
177
|
+
```
|
|
178
|
+
|
|
179
|
+
Then
|
|
180
|
+
|
|
181
|
+
```bash
|
|
182
|
+
$ python train_oxford.py
|
|
183
|
+
```
|
|
184
|
+
|
|
185
|
+
## Citations
|
|
186
|
+
|
|
187
|
+
```bibtex
|
|
188
|
+
@article{Liu2022FlowSA,
|
|
189
|
+
title = {Flow Straight and Fast: Learning to Generate and Transfer Data with Rectified Flow},
|
|
190
|
+
author = {Xingchao Liu and Chengyue Gong and Qiang Liu},
|
|
191
|
+
journal = {ArXiv},
|
|
192
|
+
year = {2022},
|
|
193
|
+
volume = {abs/2209.03003},
|
|
194
|
+
url = {https://api.semanticscholar.org/CorpusID:252111177}
|
|
195
|
+
}
|
|
196
|
+
```
|
|
197
|
+
|
|
198
|
+
```bibtex
|
|
199
|
+
@article{Lee2024ImprovingTT,
|
|
200
|
+
title = {Improving the Training of Rectified Flows},
|
|
201
|
+
author = {Sangyun Lee and Zinan Lin and Giulia Fanti},
|
|
202
|
+
journal = {ArXiv},
|
|
203
|
+
year = {2024},
|
|
204
|
+
volume = {abs/2405.20320},
|
|
205
|
+
url = {https://api.semanticscholar.org/CorpusID:270123378}
|
|
206
|
+
}
|
|
207
|
+
```
|
|
208
|
+
|
|
209
|
+
```bibtex
|
|
210
|
+
@article{Esser2024ScalingRF,
|
|
211
|
+
title = {Scaling Rectified Flow Transformers for High-Resolution Image Synthesis},
|
|
212
|
+
author = {Patrick Esser and Sumith Kulal and A. Blattmann and Rahim Entezari and Jonas Muller and Harry Saini and Yam Levi and Dominik Lorenz and Axel Sauer and Frederic Boesel and Dustin Podell and Tim Dockhorn and Zion English and Kyle Lacey and Alex Goodwin and Yannik Marek and Robin Rombach},
|
|
213
|
+
journal = {ArXiv},
|
|
214
|
+
year = {2024},
|
|
215
|
+
volume = {abs/2403.03206},
|
|
216
|
+
url = {https://api.semanticscholar.org/CorpusID:268247980}
|
|
217
|
+
}
|
|
218
|
+
```
|
|
219
|
+
|
|
220
|
+
```bibtex
|
|
221
|
+
@article{Li2024ImmiscibleDA,
|
|
222
|
+
title = {Immiscible Diffusion: Accelerating Diffusion Training with Noise Assignment},
|
|
223
|
+
author = {Yiheng Li and Heyang Jiang and Akio Kodaira and Masayoshi Tomizuka and Kurt Keutzer and Chenfeng Xu},
|
|
224
|
+
journal = {ArXiv},
|
|
225
|
+
year = {2024},
|
|
226
|
+
volume = {abs/2406.12303},
|
|
227
|
+
url = {https://api.semanticscholar.org/CorpusID:270562607}
|
|
228
|
+
}
|
|
229
|
+
```
|
|
230
|
+
|
|
231
|
+
```bibtex
|
|
232
|
+
@article{Yang2024ConsistencyFM,
|
|
233
|
+
title = {Consistency Flow Matching: Defining Straight Flows with Velocity Consistency},
|
|
234
|
+
author = {Ling Yang and Zixiang Zhang and Zhilong Zhang and Xingchao Liu and Minkai Xu and Wentao Zhang and Chenlin Meng and Stefano Ermon and Bin Cui},
|
|
235
|
+
journal = {ArXiv},
|
|
236
|
+
year = {2024},
|
|
237
|
+
volume = {abs/2407.02398},
|
|
238
|
+
url = {https://api.semanticscholar.org/CorpusID:270878436}
|
|
239
|
+
}
|
|
240
|
+
```
|
|
241
|
+
|
|
242
|
+
```bibtex
|
|
243
|
+
@article{Zhu2024HyperConnections,
|
|
244
|
+
title = {Hyper-Connections},
|
|
245
|
+
author = {Defa Zhu and Hongzhi Huang and Zihao Huang and Yutao Zeng and Yunyao Mao and Banggu Wu and Qiyang Min and Xun Zhou},
|
|
246
|
+
journal = {ArXiv},
|
|
247
|
+
year = {2024},
|
|
248
|
+
volume = {abs/2409.19606},
|
|
249
|
+
url = {https://api.semanticscholar.org/CorpusID:272987528}
|
|
250
|
+
}
|
|
251
|
+
```
|
|
252
|
+
|
|
253
|
+
```bibtex
|
|
254
|
+
@inproceedings{Sun2025F5RTTSIF,
|
|
255
|
+
title = {F5R-TTS: Improving Flow-Matching based Text-to-Speech with Group Relative Policy Optimization},
|
|
256
|
+
author = {Xiaohui Sun and Ruitong Xiao and Jianye Mo and Bowen Wu and Qun Yu and Baoxun Wang},
|
|
257
|
+
year = {2025},
|
|
258
|
+
url = {https://api.semanticscholar.org/CorpusID:277510064}
|
|
259
|
+
}
|
|
260
|
+
```
|
|
261
|
+
|
|
262
|
+
```bibtex
|
|
263
|
+
@inproceedings{Geng2025MeanFF,
|
|
264
|
+
title = {Mean Flows for One-step Generative Modeling},
|
|
265
|
+
author = {Zhengyang Geng and Mingyang Deng and Xingjian Bai and J. Zico Kolter and Kaiming He},
|
|
266
|
+
year = {2025},
|
|
267
|
+
url = {https://api.semanticscholar.org/CorpusID:278769814}
|
|
268
|
+
}
|
|
269
|
+
```
|
|
270
|
+
|
|
271
|
+
```bibtex
|
|
272
|
+
@article{Sun2025IsNC,
|
|
273
|
+
title = {Is Noise Conditioning Necessary for Denoising Generative Models?},
|
|
274
|
+
author = {Qiao Sun and Zhicheng Jiang and Hanhong Zhao and Kaiming He},
|
|
275
|
+
journal = {ArXiv},
|
|
276
|
+
year = {2025},
|
|
277
|
+
volume = {abs/2502.13129},
|
|
278
|
+
url = {https://api.semanticscholar.org/CorpusID:276421559}
|
|
279
|
+
}
|
|
280
|
+
```
|
|
281
|
+
|
|
282
|
+
```bibtex
|
|
283
|
+
@article{Park2025FlowQ,
|
|
284
|
+
title = {Flow Q-Learning},
|
|
285
|
+
author = {Seohong Park and Qiyang Li and Sergey Levine},
|
|
286
|
+
journal = {ArXiv},
|
|
287
|
+
year = {2025},
|
|
288
|
+
volume = {abs/2502.02538},
|
|
289
|
+
url = {https://api.semanticscholar.org/CorpusID:276107180}
|
|
290
|
+
}
|
|
291
|
+
```
|
|
292
|
+
|
|
293
|
+
```bibtex
|
|
294
|
+
@misc{mcallister2025flowmatchingpolicygradients,
|
|
295
|
+
title = {Flow Matching Policy Gradients},
|
|
296
|
+
author = {David McAllister and Songwei Ge and Brent Yi and Chung Min Kim and Ethan Weber and Hongsuk Choi and Haiwen Feng and Angjoo Kanazawa},
|
|
297
|
+
year = {2025},
|
|
298
|
+
eprint = {2507.21053},
|
|
299
|
+
archivePrefix = {arXiv},
|
|
300
|
+
primaryClass = {cs.LG},
|
|
301
|
+
url = {https://arxiv.org/abs/2507.21053},
|
|
302
|
+
}
|
|
303
|
+
```
|
|
304
|
+
|
|
305
|
+
```bibtex
|
|
306
|
+
@misc{li2025basicsletdenoisinggenerative,
|
|
307
|
+
title = {Back to Basics: Let Denoising Generative Models Denoise},
|
|
308
|
+
author = {Tianhong Li and Kaiming He},
|
|
309
|
+
year = {2025},
|
|
310
|
+
eprint = {2511.13720},
|
|
311
|
+
archivePrefix = {arXiv},
|
|
312
|
+
primaryClass = {cs.CV},
|
|
313
|
+
url = {https://arxiv.org/abs/2511.13720},
|
|
314
|
+
}
|
|
315
|
+
```
|
|
316
|
+
|
|
317
|
+
```bibtex
|
|
318
|
+
@misc{clavier2024bootstrappingexpectilesreinforcementlearning,
|
|
319
|
+
title = {Bootstrapping Expectiles in Reinforcement Learning},
|
|
320
|
+
author = {Pierre Clavier and Emmanuel Rachelson and Erwan Le Pennec and Matthieu Geist},
|
|
321
|
+
year = {2024},
|
|
322
|
+
eprint = {2406.04081},
|
|
323
|
+
archivePrefix = {arXiv},
|
|
324
|
+
primaryClass = {cs.LG},
|
|
325
|
+
url = {https://arxiv.org/abs/2406.04081},
|
|
326
|
+
}
|
|
327
|
+
```
|
|
328
|
+
|
|
329
|
+
```bibtex
|
|
330
|
+
@inproceedings{anonymous2025flow,
|
|
331
|
+
title = {Flow Policy Gradients for Legged Robots},
|
|
332
|
+
author = {Anonymous},
|
|
333
|
+
booktitle = {Submitted to The Fourteenth International Conference on Learning Representations},
|
|
334
|
+
year = {2025},
|
|
335
|
+
url = {https://openreview.net/forum?id=BA6n0nmagi},
|
|
336
|
+
note = {under review}
|
|
337
|
+
}
|
|
338
|
+
```
|
|
339
|
+
|
|
340
|
+
```bibtex
|
|
341
|
+
@misc{luo2025soflowsolutionflowmodels,
|
|
342
|
+
title = {SoFlow: Solution Flow Models for One-Step Generative Modeling},
|
|
343
|
+
author = {Tianze Luo and Haotian Yuan and Zhuang Liu},
|
|
344
|
+
year = {2025},
|
|
345
|
+
eprint = {2512.15657},
|
|
346
|
+
archivePrefix = {arXiv},
|
|
347
|
+
primaryClass = {cs.LG},
|
|
348
|
+
url = {https://arxiv.org/abs/2512.15657},
|
|
349
|
+
}
|
|
350
|
+
```
|