ML pipelines, model configuration and batch management
Project description
BatchFlow
BatchFlow helps you conveniently work with random or sequential batches of your data
and define data processing and machine learning workflows even for datasets that do not fit into memory.
For more details see the documentation and tutorials.
Main features:
- flexible batch generaton
- deterministic and stochastic pipelines
- datasets and pipelines joins and merges
- data processing actions
- flexible model configuration
- within batch parallelism
- batch prefetching
- ready to use ML models and proven NN architectures
- convenient layers and helper functions to build custom models
- a powerful research engine with parallel model training and extended experiment logging.
Basic usage
my_workflow = my_dataset.pipeline()
.load('/some/path')
.do_something()
.do_something_else()
.some_additional_action()
.save('/to/other/path')
The trick here is that all the processing actions are lazy. They are not executed until their results are needed, e.g. when you request a preprocessed batch:
my_workflow.run(BATCH_SIZE, shuffle=True, n_epochs=5)
or
for batch in my_workflow.gen_batch(BATCH_SIZE, shuffle=True, n_epochs=5):
# only now the actions are fired and data is being changed with the workflow defined earlier
# actions are executed one by one and here you get a fully processed batch
or
NUM_ITERS = 1000
for i in range(NUM_ITERS):
processed_batch = my_workflow.next_batch(BATCH_SIZE, shuffle=True, n_epochs=None)
# only now the actions are fired and data is changed with the workflow defined earlier
# actions are executed one by one and here you get a fully processed batch
Train a neural network
BatchFlow includes ready-to-use proven architectures like VGG, Inception, ResNet and many others.
To apply them to your data just choose a model, specify the inputs (like the number of classes or images shape)
and call train_model. Of course, you can also choose a loss function, an optimizer and many other parameters, if you want.
from batchflow.models.torch import ResNet34
my_workflow = my_dataset.pipeline()
.init_model('model', ResNet34, config={'loss': 'ce', 'classes': 10})
.load('/some/path')
.some_transform()
.another_transform()
.train_model('ResNet34', inputs=B.images, targets=B.labels)
.run(BATCH_SIZE, shuffle=True)
For more advanced cases and detailed API see the documentation.
Installation
BatchFlowmodule is in the beta stage. Your suggestions and improvements are very welcome.
BatchFlowsupports Python 3.9 or higher.
Stable python package
With uv
uv add batchflow
With poetry
poetry add batchflow
With old-fashioned pip
pip3 install batchflow
Development version
With uv
git clone --branch my_branch https://github.com/analysiscenter/batchflow
uv add --editable ./batchflow
You can skip --branch if you need master.
With poetry
poetry add --editable git+https://github.com/analysiscenter/batchflow#my_branch
With old-fashioned pip
git clone --branch my_branch https://github.com/analysiscenter/batchflow
pip install --editable ./batchflow
Extras
Some batchflow functions and classed require additional dependencies.
In order to use that functionality you might need to install batchflow with extras (e.g. batchflow[nn]):
- image - working with image datasets and plotting
- nn - for neural networks (includes torch, torchvision, ...)
- datasets - loading standard datasets (MNIST, CIFAR, ...)
- profile - performance profiling
- jupyter - utility functions for notebooks
- research - multiprocess research
- telegram - for monitoring pipelines via a telegram bot
- dev - batchflow development (ruff, pytest, ...)
You can install several extras at once, like batchflow[image,nn,research].
Projects based on BatchFlow
- SeismiQB - ML for seismic interpretation
- SeismicPro - ML for seismic processing
- PyDEns - DL Solver for ODE and PDE
- RadIO - ML for CT imaging
- CardIO - ML for heart signals
Citing BatchFlow
Please cite BatchFlow in your publications if it helps your research.
Roman Khudorozhkov et al. BatchFlow library for fast ML workflows. 2017. doi:10.5281/zenodo.1041203
@misc{roman_kh_2017_1041203,
author = {Khudorozhkov, Roman and others},
title = {BatchFlow library for fast ML workflows},
year = 2017,
doi = {10.5281/zenodo.1041203},
url = {https://doi.org/10.5281/zenodo.1041203}
}
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file batchflow-0.9.4.tar.gz.
File metadata
- Download URL: batchflow-0.9.4.tar.gz
- Upload date:
- Size: 18.3 MB
- Tags: Source
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
43dca7ec2c2eba227c7011ff927aeb02a50bb902f47c329fa251bea777e1baed
|
|
| MD5 |
b827cd11f8134b0667903f9eefbd7ecb
|
|
| BLAKE2b-256 |
5246227669293f8dd86dc4c0d9fe3babe05bda9cf1619af314c2810058593e06
|
Provenance
The following attestation bundles were made for batchflow-0.9.4.tar.gz:
Publisher:
release.yml on analysiscenter/batchflow
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
batchflow-0.9.4.tar.gz -
Subject digest:
43dca7ec2c2eba227c7011ff927aeb02a50bb902f47c329fa251bea777e1baed - Sigstore transparency entry: 628009365
- Sigstore integration time:
-
Permalink:
analysiscenter/batchflow@9dd3e997fe782d16be75bb08a59f6c339a6a2bce -
Branch / Tag:
refs/tags/v0.9.4 - Owner: https://github.com/analysiscenter
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
release.yml@9dd3e997fe782d16be75bb08a59f6c339a6a2bce -
Trigger Event:
release
-
Statement type:
File details
Details for the file batchflow-0.9.4-py3-none-any.whl.
File metadata
- Download URL: batchflow-0.9.4-py3-none-any.whl
- Upload date:
- Size: 397.4 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
ae5f1860f95d82fc9db573c5f80880088d070a1c9b73490199638f8a19fab93e
|
|
| MD5 |
97ad8f3ed8b2ee12fea0409fb559670e
|
|
| BLAKE2b-256 |
3f43fd78d4840533e41eafda7c3940025fee2132aa26cdeac0ca55dd8aec20c8
|
Provenance
The following attestation bundles were made for batchflow-0.9.4-py3-none-any.whl:
Publisher:
release.yml on analysiscenter/batchflow
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
batchflow-0.9.4-py3-none-any.whl -
Subject digest:
ae5f1860f95d82fc9db573c5f80880088d070a1c9b73490199638f8a19fab93e - Sigstore transparency entry: 628009405
- Sigstore integration time:
-
Permalink:
analysiscenter/batchflow@9dd3e997fe782d16be75bb08a59f6c339a6a2bce -
Branch / Tag:
refs/tags/v0.9.4 - Owner: https://github.com/analysiscenter
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
release.yml@9dd3e997fe782d16be75bb08a59f6c339a6a2bce -
Trigger Event:
release
-
Statement type: