Training tools and scripts for FluxFlow text-to-image generation
Project description
FluxFlow Training
Training tools and scripts for FluxFlow text-to-image generation models.
Installation
Production Install
pip install fluxflow-training
What gets installed:
fluxflow-training- Training scripts and configuration toolsfluxflowcore package (automatically installed as dependency)- CLI commands:
fluxflow-train,fluxflow-generate
Development Install
git clone https://github.com/danny-mio/fluxflow-training.git
cd fluxflow-training
pip install -e ".[dev]"
🚧 Training Status
Models Currently In Training: FluxFlow is actively training models following a systematic validation plan.
Progress (as of February 2026):
- Bezier VAE: training in progress
- ReLU baseline VAE: pending
- Flow models: pending VAE completion
When Available: Trained checkpoints and empirical performance metrics will be published to MODEL_ZOO.md upon validation completion.
Note: All performance claims in documentation are theoretical targets pending empirical validation.
Hardware Requirements for Training
Tested on NVIDIA A6000 (48GB VRAM); A100 (40GB/80GB) also supported.
Alternative Options:
- Local: 1× RTX 4090 (24GB) or 2× RTX 3090 (24GB each)
- Cloud: AWS p3.2xlarge (V100 16GB), GCP A100 (40GB)
Memory Requirements by Training Mode (empirical measurements, Dec 2025):
- VAE Training (batch_size=4, vae_dim=128, img_size=1024):
- Without GAN: ~18-22GB VRAM
- With GAN + LPIPS: ~28-35GB VRAM
- With GAN + LPIPS + SPADE: ~35-42GB VRAM
- Peak observed: 47.4GB on A6000 48GB (pre-v0.2.1; now optimized to ~42GB stable)
- Flow Training (batch_size=1, feature_maps_dim=128):
- ~24-30GB VRAM
- Minimum viable (reduced dimensions, smaller images):
- 16GB VRAM for VAE (batch_size=2, vae_dim=64, img_size=512)
- 24GB VRAM for Flow (batch_size=1, feature_maps_dim=64)
OOM Prevention (if you hit 47GB+ on 48GB GPU):
- Reduce batch size:
batch_size: 2or1 - Disable LPIPS:
use_lpips: false(saves ~6-8GB) - Reduce image size:
img_size: 512(saves ~10-15GB) - Use FP16 (if supported):
use_fp16: true(saves ~20-30%) - See TRAINING_GUIDE.md "Limited VRAM Strategy"
Pre-download LPIPS Weights (Optional)
The training uses LPIPS for perceptual loss, which requires VGG16 weights (~528MB). To pre-download:
python -c "import lpips; lpips.LPIPS(net='vgg')"
Weights will be cached in ~/.cache/torch/hub/checkpoints/. If not pre-downloaded, they'll download automatically on first training run.
Features
Core Training Capabilities
-
Pipeline Training Mode (v0.2.0+)
- Multi-step sequential training with independent configs per step
- Per-step freeze/unfreeze of model components
- Loss-threshold transitions with early stopping
- Full checkpoint resume from any step/epoch/batch
- Multi-dataset support: Train different steps on different datasets (local/webdataset)
- Auto-create missing models: Automatic model initialization when transitioning between steps
- 1609 lines in
pipeline_orchestrator.py - See PIPELINE_ARCHITECTURE.md and MULTI_DATASET_TRAINING.md
-
GAN-Only Training Mode (v0.2.0+)
- Train encoder/decoder with adversarial loss only (no reconstruction)
- Spatial conditioning (SPADE) without pixel-perfect reconstruction
- Faster training with focused gradient flow
- Example config: see PIPELINE_ARCHITECTURE.md "GAN-Only Mode" section
-
VAE Training
- Variational autoencoders with GAN losses
- LPIPS perceptual loss support (adds ~6-8GB VRAM)
- SPADE spatial conditioning
- KL divergence with beta warmup and free bits
-
Flow Training
- Flow-based diffusion transformers
- Text-to-image generation with classifier-free guidance (CFG)
- Industry-standard training approach (same as Stable Diffusion, Flux.1)
-
Classifier-Free Guidance (CFG) (v0.3.0+)
- Train models to generate with or without text conditioning
- Single model learns both conditional p(x|text) and unconditional p(x)
- Inference-time guidance scale control (1.0-15.0, recommended: 3.0-7.0)
- Enables quality/diversity trade-off without retraining
- Proven approach: Stable Diffusion, DALL-E 2, Imagen, Flux.1
- See config.cfg.example.yaml for setup
Training Infrastructure
- Data Loading: Efficient dataset handling with WebDataset support for large-scale training
- Checkpointing: Robust checkpoint management with automatic resume from interruptions
- Training Visualization: Automatic diagram generation for loss curves and metrics
- Optimizers: Multiple optimizer support (AdamW, Adam, SGD, RMSprop)
- Schedulers: Various learning rate schedulers (CosineAnnealing, StepLR, ExponentialLR, ReduceLROnPlateau)
- Mixed Precision: Accelerate training with automatic mixed precision (fp16)
Monitoring & Logging
-
Enhanced Console Output (v0.2.0)
- Real-time batch timing (seconds/batch)
- Comprehensive loss display (VAE, KL, G, D, LPIPS)
- Step/epoch/batch progress tracking
-
Step-Specific Metrics (Pipeline Mode)
- Separate JSONL files per training step
- Automatic graph generation per step
- Full training history preservation
-
Mid-Epoch Sample Generation (v0.2.0)
- Samples generated at configurable intervals
- Structured naming with step/epoch/batch numbers
- Prevents overwrites with unique identifiers
Quick Start
Basic Training
# Create a config file (see config.example.yaml)
fluxflow-train --config config.yaml
# With automatic diagram generation
fluxflow-train --config config.yaml --generate_diagrams
Pipeline Training (NEW in v0.2.0)
Multi-step training for hypothesis testing and staged optimization:
training:
pipeline:
steps:
# Step 1: VAE warmup
- name: "vae_warmup"
n_epochs: 10
train_vae: true
gan_training: false
freeze:
- flow_processor
- text_encoder
# Step 2: Add GAN
- name: "vae_gan"
n_epochs: 20
train_vae: true
gan_training: true
use_lpips: true
# Step 3: Flow training
- name: "flow"
n_epochs: 30
train_vae: false # Freeze VAE
train_diff: true # Train flow
Run:
fluxflow-train --config pipeline_config.yaml
Validate config before training:
fluxflow-train --config pipeline_config.yaml --validate-pipeline
See PIPELINE_ARCHITECTURE.md for complete documentation.
GAN-Only Training (NEW in v0.2.0)
Train with adversarial loss only (no pixel-level reconstruction):
training:
pipeline:
steps:
- name: "gan_only"
n_epochs: 20
train_vae: false # Skip reconstruction loss
gan_training: true # Train GAN discriminator
train_spade: true # With spatial conditioning
use_lpips: false
Use cases:
- Spatial structure learning without pixel constraints
- Faster training (no reconstruction computation)
- SPADE conditioning experiments
- Saves ~8-12GB VRAM by skipping reconstruction loss computation
Classifier-Free Guidance Training (NEW in v0.3.0)
Train text-to-image models with CFG for superior prompt adherence:
training:
pipeline:
steps:
# Stage 1-2: VAE training (see config.cfg.example.yaml)
# Stage 3: Flow with CFG ✨
- name: "flow_cfg"
n_epochs: 100
train_diff: true
cfg_dropout_prob: 0.10 # 10% null conditioning (common setting)
use_ema: true
freeze:
- compressor # Freeze VAE
- expander
Generate with CFG:
fluxflow-generate \
--model_checkpoint outputs/flux_cfg/final.safetensors \
--text_prompts_path prompts/ \
--output_path outputs/ \
--use_cfg \
--guidance_scale 5.0 # Range: 1.0-15.0, recommended: 3.0-7.0
Guidance scale examples (tune for your model):
1.0: Standard conditional (no guidance)3.0-7.0: Moderate guidance (RECOMMENDED - balanced quality/creativity)7.0-15.0: Strong guidance (may oversaturate or lose diversity)
See config.cfg.example.yaml for complete CFG training example.
Generating Images
# Create a directory with .txt files containing prompts
mkdir prompts
echo "a beautiful sunset over mountains" > prompts/sunset.txt
# Generate images (standard)
fluxflow-generate \
--model_checkpoint path/to/checkpoint.safetensors \
--text_prompts_path prompts/ \
--output_path outputs/
# Generate with CFG (if model trained with cfg_dropout_prob > 0)
fluxflow-generate \
--model_checkpoint path/to/checkpoint.safetensors \
--text_prompts_path prompts/ \
--output_path outputs/ \
--use_cfg \
--guidance_scale 5.0
Visualizing Training Progress
# Training metrics are automatically logged to outputs/graph/training_metrics.jsonl
# In pipeline mode: outputs/graph/training_metrics_{stepname}.jsonl
# Generate diagrams from logged metrics (run from project root with fluxflow-training installed)
python src/fluxflow_training/scripts/generate_training_graphs.py outputs/
# Diagrams are saved to outputs/graph/:
# - training_losses.png (VAE, Flow, Discriminator, Generator, LPIPS)
# - kl_loss.png (KL divergence with beta warmup)
# - learning_rates.png (LR schedules)
# - batch_times.png (training speed)
# - training_overview.png (combined overview)
# - training_summary.txt (statistics)
Console Output Examples
Pipeline Training Mode
PIPELINE STEP 1/3: vae_warmup
Description: Warmup VAE without GAN
Duration: 10 epochs
================================================================================
[00:15:23] Step vae_warmup (1/3) | Epoch 5/10 | Batch 127/500 | VAE: 0.0234 | KL: 12.45 | 3.2s/batch
GAN Training Mode
[00:15:23] Step vae_gan (2/3) | Epoch 5/20 | Batch 127/500 | VAE: 0.0234 | KL: 12.45 | G: 0.156 | D: 0.089 | LPIPS: 0.0812 | 3.2s/batch
Metrics Shown:
VAE- Reconstruction loss (L1 + MSE)KL- KL divergenceG- GAN generator loss (whengan_training: true)D- GAN discriminator loss (whengan_training: true)LPIPS- Perceptual loss (whenuse_lpips: true)Xs/batch- Average batch processing time
Sample Naming Convention
Pipeline Mode (v0.2.0)
Mid-epoch samples:
vae_warmup_001_005_00127_abc123-original.webp
{stepname}_{step}_{epoch}_{batch}_{hash}-{suffix}.webp
End-of-epoch samples:
vae_warmup_001_005_abc123-original.webp
{stepname}_{step}_{epoch}_{hash}-{suffix}.webp
Suffixes:
-originalor_ns_i- Input image-nr_o- VAE reconstruction (no random sampling)_ns_o- VAE reconstruction (with sampling)-ctx- Context vector visualization-nc- Non-context visualization
Package Contents
-
fluxflow_training.training- Training logic and trainerspipeline_orchestrator.py- Multi-step pipeline execution (1609 lines)pipeline_config.py- Pipeline configuration and validationvae_trainer.py- VAE/GAN training logicflow_trainer.py- Flow model trainingcheckpoint_manager.py- Checkpoint save/resume
-
fluxflow_training.data- Dataset implementations and transformsdatasets.py- Image/caption datasets with WebDataset supporttransforms.py- Data augmentation pipelines
-
fluxflow_training.scripts- CLI scripts for training and generationtrain.py- Main training script (legacy + pipeline mode)generate_training_graphs.py- Visualization generation
Configuration
Training is configured via YAML files. See docs/TRAINING_GUIDE.md for detailed configuration options.
Basic Configuration Example
model:
vae_dim: 128
feature_maps_dim: 128
text_embedding_dim: 1024
data:
data_path: "/path/to/images"
captions_file: "/path/to/captions.txt" # image_name<tab>caption
fixed_prompt_prefix: null # Optional: e.g., "style anime" to prepend to all prompts
img_size: 1024
reduced_min_sizes: null # Optional: [128, 256, 512]
training:
n_epochs: 100
batch_size: 1
lr: 0.00001
train_vae: true
gan_training: true
use_lpips: true
use_fp16: false
output:
output_path: "outputs/flux"
log_interval: 10
checkpoint_save_interval: 50
samples_per_checkpoint: 1 # Generate samples at each checkpoint
sample_sizes: # Optional: generate samples at various sizes
- 512
- [768, 512] # landscape
- 1024
Pipeline Configuration Example
See test_pipeline_minimal.yaml or config.example.yaml for complete examples.
Key difference: Pipeline configs use training.pipeline.steps instead of flat training config.
training:
batch_size: 4
workers: 8
pipeline:
steps:
- name: "step1"
n_epochs: 10
train_vae: true
# ... step-specific config
Documentation
Comprehensive Guides
-
PIPELINE_ARCHITECTURE.md - Pipeline training mode documentation
- Configuration reference
- Checkpoint format
- Sample naming conventions
- Troubleshooting
- Implementation:
pipeline_orchestrator.py(1609 lines)
-
TRAINING_GUIDE.md - Complete training guide
- Detailed configuration options
- Dataset preparation
- Training strategies
- Memory optimization strategies
- Best practices
-
CONTRIBUTING.md - Development guide
- Setting up development environment
- Running tests
- Code style guidelines
- Pipeline config testing
Example Configurations
config.example.yaml- Complete configuration template with all optionstest_pipeline_minimal.yaml- Minimal working pipeline exampleconfig.example.sh- Environment setup script
See CHANGELOG.md for complete version history.
Links
License
MIT License - see LICENSE file for details.
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 fluxflow_training-0.8.1.tar.gz.
File metadata
- Download URL: fluxflow_training-0.8.1.tar.gz
- Upload date:
- Size: 147.2 kB
- Tags: Source
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
0c8d0524552da940de15afd880a4b88b607a4610b4025b65c655ce808e5af539
|
|
| MD5 |
9d8f3dddb24438c71400c21c0da185f4
|
|
| BLAKE2b-256 |
3f31f2dbd0e724d456dbd7af3f0a4237015f5db0d9762bd5544c8269a012878c
|
Provenance
The following attestation bundles were made for fluxflow_training-0.8.1.tar.gz:
Publisher:
ci.yml on danny-mio/fluxflow-training
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
fluxflow_training-0.8.1.tar.gz -
Subject digest:
0c8d0524552da940de15afd880a4b88b607a4610b4025b65c655ce808e5af539 - Sigstore transparency entry: 1229109625
- Sigstore integration time:
-
Permalink:
danny-mio/fluxflow-training@0c715c4461ea084c499378b8a3cf5ae36d7af8b1 -
Branch / Tag:
refs/tags/v0.8.1 - Owner: https://github.com/danny-mio
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
ci.yml@0c715c4461ea084c499378b8a3cf5ae36d7af8b1 -
Trigger Event:
push
-
Statement type:
File details
Details for the file fluxflow_training-0.8.1-py3-none-any.whl.
File metadata
- Download URL: fluxflow_training-0.8.1-py3-none-any.whl
- Upload date:
- Size: 109.5 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 |
e7c529c4524dd924455ebd01f4cd74e4ea32925676b179b3407f785489b43dee
|
|
| MD5 |
e4d8a1e7e85615078e61b1274bfa2a96
|
|
| BLAKE2b-256 |
895fd680f59a56629c18242a4c0c435eaff43497bd0b9a5407a985f71e3b8189
|
Provenance
The following attestation bundles were made for fluxflow_training-0.8.1-py3-none-any.whl:
Publisher:
ci.yml on danny-mio/fluxflow-training
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
fluxflow_training-0.8.1-py3-none-any.whl -
Subject digest:
e7c529c4524dd924455ebd01f4cd74e4ea32925676b179b3407f785489b43dee - Sigstore transparency entry: 1229109981
- Sigstore integration time:
-
Permalink:
danny-mio/fluxflow-training@0c715c4461ea084c499378b8a3cf5ae36d7af8b1 -
Branch / Tag:
refs/tags/v0.8.1 - Owner: https://github.com/danny-mio
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
ci.yml@0c715c4461ea084c499378b8a3cf5ae36d7af8b1 -
Trigger Event:
push
-
Statement type: