juspice.synth_data_module¶
Synthetic training images for microscopy segmentation.
New image/mask pairs are created from a small set of real training images with one of these methods:
'PB': Gaussian particles drawn on the real background;'PB_NonGauss': moving particles with wavy outlines;'Aug': random flips, scaling, rotation and shear;'DCGAN': a generative adversarial network (juspice.dcgan);'SDiff': Stable Diffusion (juspice.stable_diff).
Most outputs are also augmented with juspice.utils.standard_augmentations().
Settings come from a YAML file read by ConfigLoader.
The main entry point is SynthGenerationAccessor, available as
spice.synth_generation. PreparationManager and
SynthDataGenerator do the underlying work.
Examples
With the accessor:
from juspice.io import load_data
from juspice.synth_data_module import ConfigLoader
config = ConfigLoader('notebooks/notebooks_parameters.yaml')
spice = load_data('path/to/reference_image.png')
synth = spice.synth_generation.generate(
config=config, input_dataset='EBC1', method_name='PB',
repo_root=repo_root, N_images=5, device='cpu',
)
# synth.dataset_type == 'multiple_frames'
With the classes directly:
from juspice.synth_data_module import (
ConfigLoader, PreparationManager, SynthDataGenerator,
)
config = ConfigLoader('notebooks/notebooks_parameters.yaml')
manager = PreparationManager(config, 'EBC1', 'PB', repo_root=repo_root)
gen = SynthDataGenerator(repo_root, config, manager, 'PB', N_images=5)
spice = gen.generate()