This repository contains the work for Project 12: Efficient Image Generation, developed as part of the ENSTA course: CSC_5IA21
Welcome to the Efficient Image Generation project codebase. This project tackles the hardware and VRAM bottlenecks of modern Latent Diffusion Models by providing a "frugal" end-to-end pipeline for FLUX.2, using text rendering as our primary benchmark for precision.
Dataset_creation/ — Automated text-in-image dataset generation and filtering pipeline using EasyOCR and BLIP-2.Efficient training/ — Scripts and configurations for fine-tuning the FLUX.2 Klein 4B model.Efficient inference/ — Tools for benchmarking, quantization, smart offloading, and quality evaluation of FLUX.2 variants.Dataset_creation/)
It streams images from HuggingFace's AnyWord-3M and applies a rigorous multi-step filtering and captioning process:
Key Features:
Below are examples of the dataset outputs after passing through the filtering and captioning pipeline:
Efficient training/)This directory contains the necessary project structure, dependencies, and configurations to efficiently fine-tune the FLUX.2 Klein 4B model using the datasets generated in the previous step.
LoRA architecture variants. Left (LoRA rank sweep): adapters applied to 6 modules spanning attention and feed-forward blocks. Right (CA-LoRA / QLoRA): adapters restricted to the 2 cross-attention key/value projections; the backbone is additionally quantized to 4-bit NF4 for QLoRA.
Key Features:

Please refer to the README.md inside the Efficient training/ folder for specific installation commands and training launch instructions.
Efficient inference/)

Running high-fidelity generative models often requires massive compute. This module is dedicated to benchmarking and running FLUX.2 variants under strict hardware constraints.
Key Features:





Check the README.md inside the Efficient inference/ folder for benchmarking commands and evaluation protocols.
To get started, we recommend tackling the pipeline in order:
Dataset_creation/, install the requirements, and run the pipeline to build your OCR text-in-image dataset.Efficient training/, set up your environment, point the training script to your newly generated dataset, and begin fine-tuning.Efficient inference/ to run your fine-tuned model, measure hardware metrics, and evaluate text-rendering accuracy.This pipeline is provided for research purposes. Datasets (like AnyWord-3M) and base models (BLIP-2, FLUX.2) utilized across these modules are subject to their respective licenses on HuggingFace and original creator repositories.
Python
96.5%
Shell
3.5%
This repository contains the work for Project 12: Efficient Image Generation, developed as part of the ENSTA course: CSC_5IA21
Welcome to the Efficient Image Generation project codebase. This project tackles the hardware and VRAM bottlenecks of modern Latent Diffusion Models by providing a "frugal" end-to-end pipeline for FLUX.2, using text rendering as our primary benchmark for precision.
Dataset_creation/ — Automated text-in-image dataset generation and filtering pipeline using EasyOCR and BLIP-2.Efficient training/ — Scripts and configurations for fine-tuning the FLUX.2 Klein 4B model.Efficient inference/ — Tools for benchmarking, quantization, smart offloading, and quality evaluation of FLUX.2 variants.Dataset_creation/)
It streams images from HuggingFace's AnyWord-3M and applies a rigorous multi-step filtering and captioning process:
Key Features:
Below are examples of the dataset outputs after passing through the filtering and captioning pipeline:
Efficient training/)This directory contains the necessary project structure, dependencies, and configurations to efficiently fine-tune the FLUX.2 Klein 4B model using the datasets generated in the previous step.
LoRA architecture variants. Left (LoRA rank sweep): adapters applied to 6 modules spanning attention and feed-forward blocks. Right (CA-LoRA / QLoRA): adapters restricted to the 2 cross-attention key/value projections; the backbone is additionally quantized to 4-bit NF4 for QLoRA.
Key Features:

Please refer to the README.md inside the Efficient training/ folder for specific installation commands and training launch instructions.
Efficient inference/)

Running high-fidelity generative models often requires massive compute. This module is dedicated to benchmarking and running FLUX.2 variants under strict hardware constraints.
Key Features:





Check the README.md inside the Efficient inference/ folder for benchmarking commands and evaluation protocols.
To get started, we recommend tackling the pipeline in order:
Dataset_creation/, install the requirements, and run the pipeline to build your OCR text-in-image dataset.Efficient training/, set up your environment, point the training script to your newly generated dataset, and begin fine-tuning.Efficient inference/ to run your fine-tuned model, measure hardware metrics, and evaluate text-rendering accuracy.This pipeline is provided for research purposes. Datasets (like AnyWord-3M) and base models (BLIP-2, FLUX.2) utilized across these modules are subject to their respective licenses on HuggingFace and original creator repositories.
Python
96.5%
Shell
3.5%