abhishek221601-spec/FluxForge-AI

🤖 Flux.1-style text-to-image AI system from scratch — Diffusion Transformer, Flow Matching, CLIP & T5-XXL encoders

1

stars

1

commits

Python

primary language

Apr 25, 2026

updated

README

FluxForge — Text-to-Image Diffusion Transformer

A from-scratch implementation of a Flux.1 Pro–style text-to-image generation system built on Diffusion Transformers (DiT) with Flow Matching.

Architecture Overview

Text Prompt ──► CLIP + T5-XXL Encoders ──► Cross-Attention
                                              │
Noise z_t ──► DiT Blocks (24 layers) ────────┤──► Predicted v(z_t, t)
                                              │
Timestep t ──► Sinusoidal + Adaln ────────────┘
                     │
                     ▼
            VAE Decoder ──► RGB Image (512–1024px)

Features

FeatureStatus
Diffusion Transformer (DiT) core
Flow Matching (ODE-based)
CLIP + T5-XXL text encoding
VAE latent compression
Multi-resolution (512–1024+)
Classifier-Free Guidance
Negative prompts
DDIM / Euler / Euler-A samplers
Seed reproducibility
Mixed-precision training
Gradient checkpointing
LoRA fine-tuning
ControlNet conditioning
Watermarking
NSFW safety filter
Gradio UI
FastAPI endpoint

Quick Start

# Install dependencies
pip install -r requirements.txt

# Generate an image (after training or loading weights)
python generate.py --prompt "a majestic dragon flying over mountains at sunset" \
                   --steps 28 --guidance 7.5 --seed 42

# Launch Gradio UI
python serve.py --ui gradio --port 7860

# Launch FastAPI
python serve.py --ui api --port 8000

# Start training
python train.py --config config/train_default.yaml

Project Structure

flux-from-scratch/
├── config/              # Model & training configurations
├── models/              # Core neural network modules
│   ├── dit.py           # Diffusion Transformer
│   ├── vae.py           # Variational Autoencoder
│   ├── text_encoder.py  # CLIP + T5-XXL encoders
│   ├── flow_matching.py # Flow Matching scheduler
│   ├── lora.py          # LoRA adapters
│   └── controlnet.py    # ControlNet conditioning
├── training/            # Training pipeline
│   ├── trainer.py       # Main training loop
│   ├── dataset.py       # Data loading (LAION-5B)
│   └── losses.py        # Loss functions
├── inference/           # Inference pipeline
│   ├── pipeline.py      # End-to-end generation
│   ├── samplers.py      # ODE/SDE samplers
│   └── safety.py        # NSFW + watermarking
├── ui/                  # Serving interfaces
│   ├── gradio_app.py    # Gradio UI
│   └── api.py           # FastAPI REST API
├── utils/               # Shared utilities
├── train.py             # Training entry point
├── generate.py          # CLI generation
└── serve.py             # Server entry point

Hardware Requirements

TaskMinimumRecommended
Inference1× RTX 3090 (24 GB)1× A100 (80 GB)
Training8× A100 (80 GB)64× H100 (80 GB)
Fine-tuning (LoRA)1× A100 (40 GB)1× A100 (80 GB)

License

Apache 2.0

Contributors

abhishek221601-spec/FluxForge-AI

🤖 Flux.1-style text-to-image AI system from scratch — Diffusion Transformer, Flow Matching, CLIP & T5-XXL encoders

1

stars

1

commits

Python

primary language

Apr 25, 2026

updated

README

FluxForge — Text-to-Image Diffusion Transformer

A from-scratch implementation of a Flux.1 Pro–style text-to-image generation system built on Diffusion Transformers (DiT) with Flow Matching.

Architecture Overview

Text Prompt ──► CLIP + T5-XXL Encoders ──► Cross-Attention
                                              │
Noise z_t ──► DiT Blocks (24 layers) ────────┤──► Predicted v(z_t, t)
                                              │
Timestep t ──► Sinusoidal + Adaln ────────────┘
                     │
                     ▼
            VAE Decoder ──► RGB Image (512–1024px)

Features

FeatureStatus
Diffusion Transformer (DiT) core
Flow Matching (ODE-based)
CLIP + T5-XXL text encoding
VAE latent compression
Multi-resolution (512–1024+)
Classifier-Free Guidance
Negative prompts
DDIM / Euler / Euler-A samplers
Seed reproducibility
Mixed-precision training
Gradient checkpointing
LoRA fine-tuning
ControlNet conditioning
Watermarking
NSFW safety filter
Gradio UI
FastAPI endpoint

Quick Start

# Install dependencies
pip install -r requirements.txt

# Generate an image (after training or loading weights)
python generate.py --prompt "a majestic dragon flying over mountains at sunset" \
                   --steps 28 --guidance 7.5 --seed 42

# Launch Gradio UI
python serve.py --ui gradio --port 7860

# Launch FastAPI
python serve.py --ui api --port 8000

# Start training
python train.py --config config/train_default.yaml

Project Structure

flux-from-scratch/
├── config/              # Model & training configurations
├── models/              # Core neural network modules
│   ├── dit.py           # Diffusion Transformer
│   ├── vae.py           # Variational Autoencoder
│   ├── text_encoder.py  # CLIP + T5-XXL encoders
│   ├── flow_matching.py # Flow Matching scheduler
│   ├── lora.py          # LoRA adapters
│   └── controlnet.py    # ControlNet conditioning
├── training/            # Training pipeline
│   ├── trainer.py       # Main training loop
│   ├── dataset.py       # Data loading (LAION-5B)
│   └── losses.py        # Loss functions
├── inference/           # Inference pipeline
│   ├── pipeline.py      # End-to-end generation
│   ├── samplers.py      # ODE/SDE samplers
│   └── safety.py        # NSFW + watermarking
├── ui/                  # Serving interfaces
│   ├── gradio_app.py    # Gradio UI
│   └── api.py           # FastAPI REST API
├── utils/               # Shared utilities
├── train.py             # Training entry point
├── generate.py          # CLI generation
└── serve.py             # Server entry point

Hardware Requirements

TaskMinimumRecommended
Inference1× RTX 3090 (24 GB)1× A100 (80 GB)
Training8× A100 (80 GB)64× H100 (80 GB)
Fine-tuning (LoRA)1× A100 (40 GB)1× A100 (80 GB)

License

Apache 2.0

Contributors

Languages

Python

63.6%

CSS

12.3%

HTML

12.3%

JavaScript

11.7%