# split and save data
def prepare_data(
        root: str,
        res_path_foler: str,
        aux_info: str,
        val_rate: float = 0.15):
    random.seed(0)  # 保证随机结果可复现
    assert os.path.exists(root), "dataset root: {} does not exist.".format(root)

    # 遍历文件夹，一个文件夹对应一个类别
    classes = [cla for cla in os.listdir(root) if os.path.isdir(os.path.join(root, cla))]
    # 排序，保证各平台顺序一致
    classes.sort()
    # 生成类别名称以及对应的数字索引
    class_indices = dict((k, v) for v, k in enumerate(classes))
    json_str = json.dumps(dict((val, key) for key, val in class_indices.items()), indent=4)
    with open('class_indices.json', 'w') as json_file:
        json_file.write(json_str)

    train_images_path = []  # 存储训练集的所有图片路径
    train_images_label = []  # 存储训练集图片对应索引信息
    val_images_path = []  # 存储验证集的所有图片路径
    val_images_label = []  # 存储验证集图片对应索引信息
    every_class_num = []  # 存储每个类别的样本总数
    supported = [".jpg", ".JPG", ".png", ".PNG"]  # 支持的文件后缀类型

    train_enhance_images_path = []
    val_enhance_images_path = []

    # 遍历每个文件夹下的文件
    for cla in classes:
        cla_path = os.path.join(root, cla)
        # 遍历获取supported支持的所有文件路径
        images = [os.path.join(root, cla, i) for i in os.listdir(cla_path)
                  if os.path.splitext(i)[-1] in supported]
        # 排序，保证各平台顺序一致
        images.sort()
        # 获取该类别对应的索引
        image_class = class_indices[cla]
        # 记录该类别的样本数量
        every_class_num.append(len(images))
        
        # val_path_prefix = os.path.join(root, f"../{aux_info}_/{val_path_name}/{cla}")  # <-
        train_path_prefix = f"{res_path_foler}/{aux_info}_/TrainData/{cla}"
        val_path_prefix = f"{res_path_foler}/{aux_info}_/ValData/{cla}"

        train_enhance_path_prefix = f"{res_path_foler}/{aux_info}_/TrainDataEnhance/{cla}"
        val_enhance_path_prefix = f"{res_path_foler}/{aux_info}_/ValDataEnhance/{cla}"

        random.shuffle(images)  # [val_data, train_data]

        data_size = len(images)
        for i in range(data_size):  
            if i < data_size * val_rate:  # <- val_data
                val_images_path.append(images[i])
                if os.path.exists(val_path_prefix) is False:
                    os.makedirs(val_path_prefix)
                shutil.copyfile(images[i], os.path.join(val_path_prefix, os.path.basename(images[i])))
            else:  # <- train_data
                train_images_path.append(images[i])
                if os.path.exists(train_path_prefix) is False:
                    os.makedirs(train_path_prefix)
                shutil.copyfile(images[i], os.path.join(train_path_prefix, os.path.basename(images[i])))
        # ------------------------------
        source = val_path_prefix
        dest = val_enhance_path_prefix
        if os.path.exists(dest) is False:  # <- 没有才增强
            batch_enhance(source, dest)
        images = [os.path.join(val_enhance_path_prefix, file) for file in os.listdir(val_enhance_path_prefix)]
        label = [image_class for _ in range(len(images))]
        images.sort()
        val_enhance_images_path.extend(images)
        val_images_label.extend(label)
        # ------------------------------
        source = train_path_prefix
        dest = train_enhance_path_prefix
        if os.path.exists(dest) is False:  # <- 没有才增强
            batch_enhance(source, dest)
        images = [os.path.join(train_enhance_path_prefix, file) for file in os.listdir(train_enhance_path_prefix)]
        label = [image_class for _ in range(len(images))]
        images.sort()
        train_enhance_images_path.extend(images)
        train_images_label.extend(label)

    print("{} images were found in the dataset.".format(sum(every_class_num)))
    print("{} images for training.".format(len(train_images_path)))
    print("{} images for validation.".format(len(val_images_path)))
    print("{} enhanced images for training.".format(len(train_enhance_images_path)))
    print("{} enhanced images for validation.".format(len(val_enhance_images_path)))
    assert len(train_images_path) > 0, "number of training images must greater than 0."
    assert len(val_images_path) > 0, "number of validation images must greater than 0."

    return train_enhance_images_path, train_images_label, val_enhance_images_path, val_images_label
上面是我修改后的代码，我把数组增强(一张图增强成5张不同图片)放到划分数据之后了
下面是修改前的，是直接对数据增强后的来划分
请帮我详细区分一下两代码的逻辑变化
def preare_test_and_read_split_data(
        root: str,
        enforce_tag: str,
        val_path_name: str,
        test_path_name: str,
        aux_info: str,
        val_rate: float = 0.15, test_rate=0.0):
    random.seed(0)  # 保证随机结果可复现
    assert os.path.exists(root), "dataset root: {} does not exist.".format(root)

    # 遍历文件夹，一个文件夹对应一个类别
    flower_class = [cla for cla in os.listdir(root) if os.path.isdir(os.path.join(root, cla))]
    # 排序，保证各平台顺序一致
    flower_class.sort()
    # 生成类别名称以及对应的数字索引
    class_indices = dict((k, v) for v, k in enumerate(flower_class))
    json_str = json.dumps(dict((val, key) for key, val in class_indices.items()), indent=4)
    with open('class_indices.json', 'w') as json_file:
        json_file.write(json_str)

    train_images_path = []  # 存储训练集的所有图片路径
    train_images_label = []  # 存储训练集图片对应索引信息
    val_images_path = []  # 存储验证集的所有图片路径
    val_images_label = []  # 存储验证集图片对应索引信息
    every_class_num = []  # 存储每个类别的样本总数
    supported = [".jpg", ".JPG", ".png", ".PNG"]  # 支持的文件后缀类型
    # 遍历每个文件夹下的文件
    for cla in flower_class:
        cla_path = os.path.join(root, cla)
        # 遍历获取supported支持的所有文件路径
        images = [os.path.join(root, cla, i) for i in os.listdir(cla_path)
                  if os.path.splitext(i)[-1] in supported]
        # 排序，保证各平台顺序一致
        images.sort()
        # 获取该类别对应的索引
        image_class = class_indices[cla]
        # 记录该类别的样本数量
        every_class_num.append(len(images))

        val_path_prefix = os.path.join(root, f"../{aux_info}_/{val_path_name}_{enforce_tag}/{cla}")  # <-
        test_path_prefix = os.path.join(root, f"../{aux_info}_/{test_path_name}_{enforce_tag}/{cla}")  # <-

        random.shuffle(images)  # [val_data, test_data, train_data]

        data_size = len(images)
        for i in range(data_size):
            if i < data_size * val_rate:  # <- val_data
                val_images_path.append(images[i])
                val_images_label.append(image_class)
                if os.path.exists(val_path_prefix) is False:
                    os.makedirs(val_path_prefix)
                shutil.copyfile(images[i], os.path.join(val_path_prefix, os.path.basename(images[i])))
            elif i < data_size * val_rate + data_size * test_rate:  # <- test_data
                if os.path.exists(test_path_prefix) is False:
                    os.makedirs(test_path_prefix)
                shutil.copyfile(images[i], os.path.join(test_path_prefix, os.path.basename(images[i])))
            else:  # <- train_data
                train_images_path.append(images[i])
                train_images_label.append(image_class)

    print("{} images were found in the dataset.".format(sum(every_class_num)))
    print("{} images for training.".format(len(train_images_path)))
    print("{} images for validation.".format(len(val_images_path)))
    assert len(train_images_path) > 0, "number of training images must greater than 0."
    assert len(val_images_path) > 0, "number of validation images must greater than 0."

    return train_images_path, train_images_label, val_images_path, val_images_label