Synthetic Data Generation¶
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()withmethod_name='Aug'. Covers loading settings withConfigLoader, 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
PBmethod places round, Gaussian-intensity particle blobs onto an inpainted background, with configurable size, growth rate, and how much they overlap.PB_NonGaussadds wavy, non-circular shape deformation on top. Both run throughspice.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()withmethod_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 minimummin_epoch_for_image), and saving the generated image–mask pairs. The returnedSPICEDataholds the generated images as onemultiple_framesstack, 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()withmethod_name='SDiff'. Covers loading the pretrained model, writing a text prompt, theguidance_scale/strengthparameters 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 thediffuserslibrary and a matchinghuggingface_hubversion installed.