Views
No views yet
┌────────────────────────────────┐
Image [128×128] → │ TAESD VAE │ → Latent [16×16×4]
│ (< 1M params) │
└────────────────────────────────┘
↓
┌────────────────────────────────┐
│ LiquidFlow Backbone │
│ │
│ ┌──────────────────────────┐ │
│ │ LiquidMamba Block (×N) │ │
│ │ │ │
│ │ Input → CfC Gate │ │
│ │ ↓ │ │
│ │ Mamba-2 SSD │ │
│ │ (multi-dir scan) │ │
│ │ ↓ │ │
│ │ CfC Gate → Output │ │
│ └──────────────────────────┘ │
│ │
│ + Physics-Informed Loss │
│ (TV + Spectral + Gradient) │
└────────────────────────────────┘
↓
Predicted Noiseh(t) = σ(-f(x,I)·t) ⊙ g(x,I) + (1-σ(-f(x,I)·t)) ⊙ h(x,I)h_t = A_t·h_{t-1} + B_t·x_t, y_t = C_t^T·h_t| Variant | Parameters | Hidden Dim | Stages | Blocks/Stage | T4 VRAM |
|---|---|---|---|---|---|
| Tiny | ~2M | 128 | 2 | 2 | < 2 GB |
| Small | ~8M | 256 | 4 | 4 | ~4 GB |
| Base | ~30M | 384 | 6 | 6 | ~8 GB |
1# Clone
2git clone https://huggingface.co/krystv/LiquidFlow-Gen
3cd LiquidFlow-Gen
4
5# Install
6pip install torch torchvision diffusers tqdm pillow numpy
7
8# Train (small model, 128px, CIFAR-10)
9python train.py \
10 --dataset cifar10 \
11 --image_size 128 \
12 --variant small \
13 --batch_size 32 \
14 --epochs 100 \
15 --lr 2e-4
16
17# Train (base model, 512px)
18python train.py \
19 --dataset cifar10 \
20 --image_size 512 \
21 --variant base \
22 --batch_size 8 \
23 --epochs 200 \
24 --lr 1e-41from liquid_flow.generator import create_liquidflow
2from liquid_flow.vae_wrapper import TAESDWrapper
3
4# Load model
5model = create_liquidflow(variant='small', image_size=128)
6model.load_state_dict(torch.load('best_model.pt'))
7model = model.cuda().eval()
8
9# Load VAE
10vae = TAESDWrapper.load('cuda')
11
12# Generate
13latents = model.sample(batch_size=16, steps=50, ddim=True)
14images = TAESDWrapper.decode(vae, latents)1# Export to ONNX
2torch.onnx.export(model, (x, t), 'liquidflow.onnx',
3 input_names=['noisy_latent', 'timestep'],
4 output_names=['predicted_noise'],
5 opset_version=14)
6
7# Convert to CoreML (iOS)
8# coremltools.converters.onnx.convert(model='liquidflow.onnx')
9
10# Convert to TFLite (Android)
11# onnx-tf convert -i liquidflow.onnx -o liquidflow.pbLiquidFlow-Gen/
├── liquid_flow/
│ ├── __init__.py # Package init
│ ├── cfc_cell.py # CfC Liquid NN implementation
│ ├── mamba2_ssd.py # Mamba-2 SSD implementation
│ ├── liquid_flow_block.py # Hybrid CfC+Mamba block
│ ├── generator.py # Full diffusion generator
│ ├── vae_wrapper.py # VAE interfaces
│ ├── physics_loss.py # Physics regularizers
│ └── trainer.py # Training utilities
├── train.py # CLI training script
├── LiquidFlow_Colab.ipynb # Colab notebook
└── README.md # This file1@article{hasani2022cfc,
2 title={Closed-form continuous-time neural networks},
3 author={Hasani, Ramin and Lechner, Mathias and Amini, Alexander and others},
4 journal={Nature Machine Intelligence},
5 year={2022}
6}
7
8@article{dao2024mamba2,
9 title={Transformers are SSMs: Generalized Models and Efficient Algorithms Through Structured State Space Duality},
10 author={Dao, Tri and Gu, Albert},
11 journal={arXiv:2405.21060},
12 year={2024}
13}
14
15@inproceedings{bastek2025physics,
16 title={Physics-Informed Diffusion Models},
17 author={Bastek, Jan-Hendrik and Sun, WaiChing},
18 booktitle={ICLR},
19 year={2025}
20}
21
22@article{pham2024dimsum,
23 title={DiMSUM: Diffusion Mamba -- A Scalable and Unified Spatial-Frequency Method for Image Generation},
24 author={Pham, Hao and others},
25 journal={NeurIPS},
26 year={2024}
27}