def split_data(dir, train_size):
    """Splits data into train and validation sets.

    Arguments:
    ----------
        dir (pathlib.Path):
            Path to images dir.
        train_size (float):
            Percentage of files in train set.

    Returns:
    --------
        train_images, val_images (tuple):
            List of images belonging to train and validation sets
            respectively.
    """
    images = sorted(list(dir.iterdir()))
    n_train = int(train_size * len(images))
    train_images, val_images = images[:n_train], images[n_train:]

    return train_images, val_images