文件夹结构Keras ImageDataGen

2024-04-25 19:17:17 发布

您现在位置:Python中文网/ 问答频道 /正文

文件夹结构Keras ImageDataGenerator

我有一组乳腺癌的图像,结构如下:

cancer_images/
    begnin/
        adenosis/
            * lots of png images *
        tubular_adenoma/
            * lots of png images *
        fibroadenoma/
            * lots of png images *
        phyllodes_tumor/
            * lots of png images *
    malignant/
        mucinous_carcinoma/
            * lots of png images *
        papillary_carcinoma/
            * lots of png images *
        ductal_carcinoma/
            * lots of png images *
        lobular_carcinoma/
            * lots of png images *

我在用Keras ImageDataGenerator

data_generator = ImageDataGenerator(rotation_range=10., width_shift_range=0.1, height_shift_range=0.1, shear_range=0., zoom_range=1., horizontal_flip=True, vertical_flip=True)

train_batches = data_generator.flow_from_directory("breast_cancer", save_to_dir="breast_cancer", target_size=(224, 224), batch_size=32)

i = 0
for batch in train_batches:
    i += 1
    if i > 5429:
        break

我需要在扩充数据时保留文件夹结构

扩充图像时,如何保留原始目录结构?你知道吗


Tags: of图像文件夹datashiftpngrangegenerator