How to integrate KeraCV MixUp & CuMix Augmentation into Image Data Generator?

I have the following lines of code that reads a csv file and prepares a data set to be fed into a tensorflow model using the Image Data Generator Class. How can I integrate KeraCV’s CutMix and MixUp here?

    import pandas as pd
    from collections import defaultdict
    import os
    
    
    def find_duplicate_filenames(root_dir):
        files_dict = defaultdict(list)
        for subdir, dirs, files in os.walk(root_dir):
            for file in files:
                file_path = os.path.join(subdir, file)
                files_dict[file].append(file_path)
        duplicates = {file: paths for file, paths in files_dict.items() if len(paths) > 1}
        return duplicates
    
    # Path to the directory with training images
    root_directory = 'train_images/'
    
    # Identifying duplicates
    duplicates_by_name = find_duplicate_filenames(root_directory)
    
    # Create a set of paths to exclude
    exclude_paths = {path for paths in duplicates_by_name.values() for path in paths}
    
    # Collect all valid image paths and their labels
    valid_files = []
    labels = []
    for subdir, dirs, files in os.walk(root_directory):
        for file in files:
            file_path = os.path.join(subdir, file)
            if file_path not in exclude_paths:
                valid_files.append(file_path)
                labels.append(subdir.split('/')[-1])  # assuming folder names are class labels
    
    # Create DataFrame for the image paths and labels
    data = pd.DataFrame({'filename': valid_files, 'class': labels})
    
    
    data = data[data['class']!='']
    
    print(len(data['class'].unique()))

from tensorflow.keras.preprocessing.image import ImageDataGenerator
import numpy as np

def custom_preprocessing(image):
    # Example of custom preprocessing logic
    # Adjust the image as required, this is just a placeholder
    image = np.clip(image, a_min=0, a_max=1)  # Ensuring the image is within the range [0, 1]
    return image

# ImageDataGenerator with custom preprocessing
train_datagen = ImageDataGenerator(
    preprocessing_function=custom_preprocessing,  # Using the custom preprocessing function
    width_shift_range=0.5,                         # Randomly shifts images horizontally
    horizontal_flip=False,                         # Randomly flips images horizontally
    vertical_flip=False                            # Randomly flips images vertically
)

# Continue with your model training setup


# Setup train and validation generators
train_generator = train_datagen.flow_from_dataframe(
    dataframe=train_data,
    x_col='filename',
    y_col='class',
    target_size=(224, 224),
    batch_size=64,
    class_mode='categorical',    
    color_mode='rgb'
)

validation_generator = train_datagen.flow_from_dataframe(
    dataframe=valid_data,
    x_col='filename',
    y_col='class',
    target_size=(224, 224),
    batch_size=64,
    class_mode='categorical',
    color_mode='rgb'
)

How can I add the KerasCV CutMix and MixUp layers here to add to the augmentation? I tried adding keras_cv.layers.CutMix() and keras_cv.layers.MixUp()into the model but it did not work. Thanks in advance!

Trang chủ Giới thiệu Sinh nhật bé trai Sinh nhật bé gái Tổ chức sự kiện Biểu diễn giải trí Dịch vụ khác Trang trí tiệc cưới Tổ chức khai trương Tư vấn dịch vụ Thư viện ảnh Tin tức - sự kiện Liên hệ Chú hề sinh nhật Trang trí YEAR END PARTY công ty Trang trí tất niên cuối năm Trang trí tất niên xu hướng mới nhất Trang trí sinh nhật bé trai Hải Đăng Trang trí sinh nhật bé Khánh Vân Trang trí sinh nhật Bích Ngân Trang trí sinh nhật bé Thanh Trang Thuê ông già Noel phát quà Biểu diễn xiếc khỉ Xiếc quay đĩa Dịch vụ tổ chức sự kiện 5 sao Thông tin về chúng tôi Dịch vụ sinh nhật bé trai Dịch vụ sinh nhật bé gái Sự kiện trọn gói Các tiết mục giải trí Dịch vụ bổ trợ Tiệc cưới sang trọng Dịch vụ khai trương Tư vấn tổ chức sự kiện Hình ảnh sự kiện Cập nhật tin tức Liên hệ ngay Thuê chú hề chuyên nghiệp Tiệc tất niên cho công ty Trang trí tiệc cuối năm Tiệc tất niên độc đáo Sinh nhật bé Hải Đăng Sinh nhật đáng yêu bé Khánh Vân Sinh nhật sang trọng Bích Ngân Tiệc sinh nhật bé Thanh Trang Dịch vụ ông già Noel Xiếc thú vui nhộn Biểu diễn xiếc quay đĩa Dịch vụ tổ chức tiệc uy tín Khám phá dịch vụ của chúng tôi Tiệc sinh nhật cho bé trai Trang trí tiệc cho bé gái Gói sự kiện chuyên nghiệp Chương trình giải trí hấp dẫn Dịch vụ hỗ trợ sự kiện Trang trí tiệc cưới đẹp Khởi đầu thành công với khai trương Chuyên gia tư vấn sự kiện Xem ảnh các sự kiện đẹp Tin mới về sự kiện Kết nối với đội ngũ chuyên gia Chú hề vui nhộn cho tiệc sinh nhật Ý tưởng tiệc cuối năm Tất niên độc đáo Trang trí tiệc hiện đại Tổ chức sinh nhật cho Hải Đăng Sinh nhật độc quyền Khánh Vân Phong cách tiệc Bích Ngân Trang trí tiệc bé Thanh Trang Thuê dịch vụ ông già Noel chuyên nghiệp Xem xiếc khỉ đặc sắc Xiếc quay đĩa thú vị
Trang chủ Giới thiệu Sinh nhật bé trai Sinh nhật bé gái Tổ chức sự kiện Biểu diễn giải trí Dịch vụ khác Trang trí tiệc cưới Tổ chức khai trương Tư vấn dịch vụ Thư viện ảnh Tin tức - sự kiện Liên hệ Chú hề sinh nhật Trang trí YEAR END PARTY công ty Trang trí tất niên cuối năm Trang trí tất niên xu hướng mới nhất Trang trí sinh nhật bé trai Hải Đăng Trang trí sinh nhật bé Khánh Vân Trang trí sinh nhật Bích Ngân Trang trí sinh nhật bé Thanh Trang Thuê ông già Noel phát quà Biểu diễn xiếc khỉ Xiếc quay đĩa
Thiết kế website Thiết kế website Thiết kế website Cách kháng tài khoản quảng cáo Mua bán Fanpage Facebook Dịch vụ SEO Tổ chức sinh nhật