def generate_synthetic_dataset(path, num_samples: int, im_size=(256, 256), max_shapes: int=10, overlap: bool=False, p_rotate: float=0):
    path = Path(path)
    img_path = (path / 'images')
    label_path = (path / 'labels')
    os.makedirs(img_path, exist_ok=True)
    os.makedirs(label_path, exist_ok=True)
    for i in range(num_samples):
        rotation = bool((np.random.rand(1) < p_rotate))
        (img, labels) = gen_shape_image(im_size, max_shapes, overlap, rotation)
        img_name = f'{i}.png'
        imsave((img_path / img_name), img)
        imsave((label_path / img_name), labels)
def generate_synthetic_dataset(path, num_samples: int, im_size=(256, 256), max_shapes: int=10, overlap: bool=False, p_rotate: float=0):
    path = Path(path)
    img_path = (path / 'images')
    label_path = (path / 'labels')
    os.makedirs(img_path, exist_ok=True)
    os.makedirs(label_path, exist_ok=True)
    for i in range(num_samples):
        rotation = bool((np.random.rand(1) < p_rotate))
        (img, labels) = gen_shape_image(im_size, max_shapes, overlap, rotation)
        img_name = f'{i}.png'
        imsave((img_path / img_name), img)
        imsave((label_path / img_name), labels)