Synthetic Data Generation

Synthetic data generation

← Back to Notebook Examples

All four notebooks below use the same spice.synth_generation.generate() call. A reference training image is loaded first, as the SPICEData entry point and history anchor; generate() then returns a new SPICEData (dataset_type='multiple_frames') holding the generated images, sharing that first object’s history. You only ever interact with SPICEData through this one accessor.

notebooks/synthetic_data/example_Aug.ipynb

Turns a small set of real SEM microscopy images into many more training image–mask pairs, using geometric augmentation (random rotation, scaling, and shear) — spice.synth_generation.generate() with method_name='Aug'. Covers loading settings with ConfigLoader, the augmentation parameters, viewing the generated images and masks next to the originals, and saving the result with full provenance tracking.

notebooks/synthetic_data/example_PB.ipynb

Builds synthetic images from scratch using physics-inspired shapes, on EBC1 SEM images — no manual labelling needed. The PB method places round, Gaussian-intensity particle blobs onto an inpainted background, with configurable size, growth rate, and how much they overlap. PB_NonGauss adds wavy, non-circular shape deformation on top. Both run through spice.synth_generation.generate(); the notebook shows the generated images next to their binary masks before saving.

notebooks/synthetic_data/example_DCGAN.ipynb

Trains a small neural network — a Deep Convolutional Generative Adversarial Network (DCGAN) — on SiO₂ lithiation microscopy images, via spice.synth_generation.generate() with method_name='DCGAN'. Covers setting up the network (generator and discriminator filter counts, latent dimension, learning rate), reading the training curves (generator loss, discriminator loss, discriminator accuracy) to check training is going well, stopping training early once it stops improving (early_stopping_patience, gated by a minimum min_epoch_for_image), and saving the generated image–mask pairs. The returned SPICEData holds the generated images as one multiple_frames stack, sharing the anchor image’s history.

notebooks/synthetic_data/example_SDiff.ipynb

Generates synthetic SiO₂ lithiation microscopy images with a pretrained Stable Diffusion model (image-to-image / inpainting), via spice.synth_generation.generate() with method_name='SDiff'. Covers loading the pretrained model, writing a text prompt, the guidance_scale/strength parameters that control how closely it follows the prompt versus the original image, generating several images at once, augmenting the results, and saving the final dataset. Needs the diffusers library and a matching huggingface_hub version installed.