wormpose.machine_learning.synthetic_data_generator

Generates synthetic data using multiprocessing

class wormpose.machine_learning.synthetic_data_generator.SyntheticDataGenerator(num_process: int, temp_dir: str, dataset: wormpose.dataset.loader.Dataset, postures_generation_fn: Callable[Generator], enable_random_augmentations: bool, writer: Type[wormpose.machine_learning.generic_file_writer.GenericFileWriter], random_seed: Optional[int])[source]

This generator makes synthetic data by distributing the work to several processes: Each process will write one file containing the synthetic data and its label We use a “GenericFileWriter” to be able to write the files in different formats (TFrecord, pickle etc…)

Parameters
  • num_process – How many processes to distribute the work: there will be one file written per process

  • temp_dir – Where to store temporary files

  • dataset – A WormPose dataset

  • postures_generation_fn – A function generating worm postures (angles)

  • enable_random_augmentations – If true, the synthetic images will have random augmentations: translation, scale, blur

  • writer – object responsible of writing the data to files

  • random_seed – Seed for reproducibility

generate(file_pattern: str, num_samples: int)[source]

Start the generation of files containing synthetic data

Parameters
  • file_pattern – Filepath of the files to generate with an “index” variable ex: “path_to/file_{index}.tfrecord”

  • num_samples – How many images (total) to generate, they will be split in several files