Applying Evolutionary Computing to Embeddings of Diffusion Models
Jupyter Notebook
16
141 commits
updated Oct 15, 2026
Combining Evolutionary Computing with Diffusion Models
Image results will be saved in your Google Drive in the folder evolutionary. Each generation
creates a new folder where the images will be saved in. You can change the folders in the notebook.
Sometimes Google Collab causes dependency problems which break the notebook. If you have any issues executing this in a Collab environment, please do not hesitate to create a new issue.
Using a virtual environment is recommended. Clone the repo (or download the zip), then install dependencies:
python -m venv .venv
source .venv/bin/activate
python -m pip install --upgrade pip
pip install -e ".[all]"
The dependency set is validated on Python 3.12 and 3.13. Now you are ready to go with the notebooks or custom code. CUDA and MPS are supported.
Package metadata now lives in pyproject.toml; setup.py is a compatibility entry
point. For a locked uv environment, run uv sync --locked --extra cma for the CPU
Sep-CMA example, or select --extra imaging --extra prompt_embedding --extra execution
for image notebooks. See setup and extras.
Algorithm notebooks contain GA/OSGA, island GA, NSGA and Sep-CMA. Detector evaluations, campaign recipes and offline embedding analysis are organized under pre-testing.
The reusable prompt-embedding notebook
uses disabled GA/OSGA
examples. Install .[imaging,prompt_embedding,execution] for managed Jupyter campaigns
with Python 3.11 or newer. Keep actual campaign settings and outputs under ignored
.local/ or outside the checkout.
See repository architecture, campaign configuration, Azure host preparation, scientific artifacts and offline embedding analysis. The embedding bounds study documents the measured DiffusionDB/Parti comparison and its limits.
Optimizing the aesthetics predictor as a maximization problem, the algorithm came to a max Aesthetics score of 8.67. This score is higher than the examples from the real LAION English Subset dataset have, with the red line showing the limit. A wide variety of prompts (inspired by parti prompts) was used for the initial population.
Parameters:
population_size = 100
num_generations = 200
batch_size = 1
elitism = 1
creator = SDXLPromptEmbeddingImageCreator(pipeline_factory=setup_pipeline, batch_size=batch_size, inference_steps=3)
evaluator = AestheticsImageEvaluator()
crossover = PooledArithmeticCrossover(0.5, 0.5)
mutation_arguments = UniformGaussianMutatorArguments(mutation_rate=0.1, mutation_strength=2, clamp_range=(-900, 900))
mutation_arguments_pooled = UniformGaussianMutatorArguments(mutation_rate=0.1, mutation_strength=0.3, clamp_range=(-8, 8))
mutator = PooledUniformGaussianMutator(mutation_arguments, mutation_arguments_pooled)
selector = TournamentSelector(tournament_size=3)
Performing an Island GA by creating random embeddings and mixing them with artist embeddings to get mixtures of styles and new ideas.
![]() | ![]() | ![]() | ![]() |
![]() | ![]() | ![]() | ![]() |
Starting from noisy random samples, evolving to better sounds. Using the sum of all fitness criteria Audiobox Aesthetics offers.
https://github.com/user-attachments/assets/25be32eb-188b-483a-a787-9cea4d7f5eeb
https://github.com/user-attachments/assets/17f4bef7-1f5a-47a4-8f29-e4f42519a4fe
More detailed results can be found in a separate repository dedicated to the results of the experiments: https://github.com/malthee/evolutionary-diffusion-results
Current supported creators working in the prompt embedding space:
Supporting only AudioLDM because it works simply on the CLAP embedding space (suitable for this kind of operation). Other embeddings have shown to not work well with evolutionary operations (like the T5 encoder for example)
There are multiple notebooks exploring the speed and quality of models for generation and fitness-evaluation. These notebooks also allow for simple inference so that any model can be tried out easily.
Sadly many of these models are hosted somewhere without a proper versioning and release system.
Thus we added some hardcoded hashes of the models we use in the code, so that if the auto-download is used, it will be verified against the expected hash. You can enable/disable this verification in the Evaluator usage code.
Furthermore, the Model/checkpoint auto-download uses verified TLS. If you hit CERTIFICATE_VERIFY_FAILED on macOS Python.org builds, run:
/Applications/Python\ 3.13/Install\ Certificates.command
Alternative: set SSL_CERT_FILE to a valid CA bundle path (for example from certifi).
An insecure fallback exists only via explicit opt-in for temporary troubleshooting:
export EVOLUTIONARY_DIFFUSION_ALLOW_INSECURE_SSL=1
pytest tests -q
See configuration, behavior and tracing and the reproducible OSGA notebook.
The classical image fitness evaluators provide CPU measures with explicit scoring conventions, feasibility checks and diagnostics. The SDXL range tools compare observed token and pooled embedding bounds across pinned prompt datasets. Generated measurements and private study controllers remain local. Running the range tools performs text encoding; installation does not run experiments or change packaged clamp tensors.
Applying Evolutionary Computing to Embeddings of Diffusion Models
Jupyter Notebook
16
141 commits
updated Oct 15, 2026
Combining Evolutionary Computing with Diffusion Models
Image results will be saved in your Google Drive in the folder evolutionary. Each generation
creates a new folder where the images will be saved in. You can change the folders in the notebook.
Sometimes Google Collab causes dependency problems which break the notebook. If you have any issues executing this in a Collab environment, please do not hesitate to create a new issue.
Using a virtual environment is recommended. Clone the repo (or download the zip), then install dependencies:
python -m venv .venv
source .venv/bin/activate
python -m pip install --upgrade pip
pip install -e ".[all]"
The dependency set is validated on Python 3.12 and 3.13. Now you are ready to go with the notebooks or custom code. CUDA and MPS are supported.
Package metadata now lives in pyproject.toml; setup.py is a compatibility entry
point. For a locked uv environment, run uv sync --locked --extra cma for the CPU
Sep-CMA example, or select --extra imaging --extra prompt_embedding --extra execution
for image notebooks. See setup and extras.
Algorithm notebooks contain GA/OSGA, island GA, NSGA and Sep-CMA. Detector evaluations, campaign recipes and offline embedding analysis are organized under pre-testing.
The reusable prompt-embedding notebook
uses disabled GA/OSGA
examples. Install .[imaging,prompt_embedding,execution] for managed Jupyter campaigns
with Python 3.11 or newer. Keep actual campaign settings and outputs under ignored
.local/ or outside the checkout.
See repository architecture, campaign configuration, Azure host preparation, scientific artifacts and offline embedding analysis. The embedding bounds study documents the measured DiffusionDB/Parti comparison and its limits.
Optimizing the aesthetics predictor as a maximization problem, the algorithm came to a max Aesthetics score of 8.67. This score is higher than the examples from the real LAION English Subset dataset have, with the red line showing the limit. A wide variety of prompts (inspired by parti prompts) was used for the initial population.
Parameters:
population_size = 100
num_generations = 200
batch_size = 1
elitism = 1
creator = SDXLPromptEmbeddingImageCreator(pipeline_factory=setup_pipeline, batch_size=batch_size, inference_steps=3)
evaluator = AestheticsImageEvaluator()
crossover = PooledArithmeticCrossover(0.5, 0.5)
mutation_arguments = UniformGaussianMutatorArguments(mutation_rate=0.1, mutation_strength=2, clamp_range=(-900, 900))
mutation_arguments_pooled = UniformGaussianMutatorArguments(mutation_rate=0.1, mutation_strength=0.3, clamp_range=(-8, 8))
mutator = PooledUniformGaussianMutator(mutation_arguments, mutation_arguments_pooled)
selector = TournamentSelector(tournament_size=3)
Performing an Island GA by creating random embeddings and mixing them with artist embeddings to get mixtures of styles and new ideas.
![]() | ![]() | ![]() | ![]() |
![]() | ![]() | ![]() | ![]() |
Starting from noisy random samples, evolving to better sounds. Using the sum of all fitness criteria Audiobox Aesthetics offers.
https://github.com/user-attachments/assets/25be32eb-188b-483a-a787-9cea4d7f5eeb
https://github.com/user-attachments/assets/17f4bef7-1f5a-47a4-8f29-e4f42519a4fe
More detailed results can be found in a separate repository dedicated to the results of the experiments: https://github.com/malthee/evolutionary-diffusion-results
Current supported creators working in the prompt embedding space:
Supporting only AudioLDM because it works simply on the CLAP embedding space (suitable for this kind of operation). Other embeddings have shown to not work well with evolutionary operations (like the T5 encoder for example)
There are multiple notebooks exploring the speed and quality of models for generation and fitness-evaluation. These notebooks also allow for simple inference so that any model can be tried out easily.
Sadly many of these models are hosted somewhere without a proper versioning and release system.
Thus we added some hardcoded hashes of the models we use in the code, so that if the auto-download is used, it will be verified against the expected hash. You can enable/disable this verification in the Evaluator usage code.
Furthermore, the Model/checkpoint auto-download uses verified TLS. If you hit CERTIFICATE_VERIFY_FAILED on macOS Python.org builds, run:
/Applications/Python\ 3.13/Install\ Certificates.command
Alternative: set SSL_CERT_FILE to a valid CA bundle path (for example from certifi).
An insecure fallback exists only via explicit opt-in for temporary troubleshooting:
export EVOLUTIONARY_DIFFUSION_ALLOW_INSECURE_SSL=1
pytest tests -q
See configuration, behavior and tracing and the reproducible OSGA notebook.
The classical image fitness evaluators provide CPU measures with explicit scoring conventions, feasibility checks and diagnostics. The SDXL range tools compare observed token and pooled embedding bounds across pinned prompt datasets. Generated measurements and private study controllers remain local. Running the range tools performs text encoding; installation does not run experiments or change packaged clamp tensors.