当前位置: 首页>>代码示例>>Python>>正文


Python image.ImageDataGenerator方法代码示例

本文整理汇总了Python中tensorflow.keras.preprocessing.image.ImageDataGenerator方法的典型用法代码示例。如果您正苦于以下问题:Python image.ImageDataGenerator方法的具体用法?Python image.ImageDataGenerator怎么用?Python image.ImageDataGenerator使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在tensorflow.keras.preprocessing.image的用法示例。


在下文中一共展示了image.ImageDataGenerator方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: cocohpe_val_transform

# 需要导入模块: from tensorflow.keras.preprocessing import image [as 别名]
# 或者: from tensorflow.keras.preprocessing.image import ImageDataGenerator [as 别名]
def cocohpe_val_transform(ds_metainfo,
                          data_format="channels_last"):
    """
    Create image transform sequence for validation subset.

    Parameters:
    ----------
    ds_metainfo : DatasetMetaInfo
        Pascal VOC2012 dataset metainfo.
    data_format : str, default 'channels_last'
        The ordering of the dimensions in tensors.

    Returns
    -------
    ImageDataGenerator
        Image transform sequence.
    """
    data_generator = CocoHpeImageDataGenerator(
        preprocessing_function=(lambda img: ds_metainfo.val_transform2(ds_metainfo=ds_metainfo)(img)),
        data_format=data_format)
    return data_generator 
开发者ID:osmr,项目名称:imgclsmob,代码行数:23,代码来源:coco_hpe2_dataset.py

示例2: cifar10_val_transform

# 需要导入模块: from tensorflow.keras.preprocessing import image [as 别名]
# 或者: from tensorflow.keras.preprocessing.image import ImageDataGenerator [as 别名]
def cifar10_val_transform(ds_metainfo,
                          data_format="channels_last"):
    """
    Create image transform sequence for validation subset.

    Parameters:
    ----------
    ds_metainfo : DatasetMetaInfo
        ImageNet-1K dataset metainfo.
    data_format : str, default 'channels_last'
        The ordering of the dimensions in tensors.

    Returns
    -------
    ImageDataGenerator
        Image transform sequence.
    """
    data_generator = ImageDataGenerator(
        preprocessing_function=(lambda img: img_normalization(
            img=img,
            mean_rgb=ds_metainfo.mean_rgb,
            std_rgb=ds_metainfo.std_rgb)),
        data_format=data_format)
    return data_generator 
开发者ID:osmr,项目名称:imgclsmob,代码行数:26,代码来源:cifar10_cls_dataset.py

示例3: imagenet_val_transform

# 需要导入模块: from tensorflow.keras.preprocessing import image [as 别名]
# 或者: from tensorflow.keras.preprocessing.image import ImageDataGenerator [as 别名]
def imagenet_val_transform(ds_metainfo,
                           data_format="channels_last"):
    """
    Create image transform sequence for validation subset.

    Parameters:
    ----------
    ds_metainfo : DatasetMetaInfo
        ImageNet-1K dataset metainfo.
    data_format : str, default 'channels_last'
        The ordering of the dimensions in tensors.

    Returns
    -------
    ImageDataGenerator
        Image transform sequence.
    """
    data_generator = ImageDataGenerator(
        preprocessing_function=(lambda img: img_normalization(
            img=img,
            mean_rgb=ds_metainfo.mean_rgb,
            std_rgb=ds_metainfo.std_rgb)),
        data_format=data_format)
    return data_generator 
开发者ID:osmr,项目名称:imgclsmob,代码行数:26,代码来源:imagenet1k_cls_dataset.py

示例4: cub200_val_transform

# 需要导入模块: from tensorflow.keras.preprocessing import image [as 别名]
# 或者: from tensorflow.keras.preprocessing.image import ImageDataGenerator [as 别名]
def cub200_val_transform(ds_metainfo,
                         data_format="channels_last"):
    """
    Create image transform sequence for validation subset.

    Parameters:
    ----------
    ds_metainfo : DatasetMetaInfo
        CUB-200-2011 dataset metainfo.
    data_format : str, default 'channels_last'
        The ordering of the dimensions in tensors.

    Returns
    -------
    ImageDataGenerator
        Image transform sequence.
    """
    data_generator = CubImageDataGenerator(
        preprocessing_function=(lambda img: img_normalization(
            img=img,
            mean_rgb=ds_metainfo.mean_rgb,
            std_rgb=ds_metainfo.std_rgb)),
        data_format=data_format)
    return data_generator 
开发者ID:osmr,项目名称:imgclsmob,代码行数:26,代码来源:cub200_2011_cls_dataset.py

示例5: __init__

# 需要导入模块: from tensorflow.keras.preprocessing import image [as 别名]
# 或者: from tensorflow.keras.preprocessing.image import ImageDataGenerator [as 别名]
def __init__(self,
                 dims,
                 n_clusters=10,
                 alpha=1.0):

        super(FcDEC, self).__init__()

        self.dims = dims
        self.input_dim = dims[0]
        self.n_stacks = len(self.dims) - 1

        self.n_clusters = n_clusters
        self.alpha = alpha
        self.pretrained = False
        self.datagen = ImageDataGenerator(width_shift_range=0.1, height_shift_range=0.1, rotation_range=10)
        self.autoencoder, self.encoder = autoencoder(self.dims)

        # prepare FcDEC model
        clustering_layer = ClusteringLayer(self.n_clusters, name='clustering')(self.encoder.output)
        self.model = Model(inputs=self.encoder.input, outputs=clustering_layer) 
开发者ID:XifengGuo,项目名称:DEC-DA,代码行数:22,代码来源:FcDEC.py

示例6: cocohpe_val_generator

# 需要导入模块: from tensorflow.keras.preprocessing import image [as 别名]
# 或者: from tensorflow.keras.preprocessing.image import ImageDataGenerator [as 别名]
def cocohpe_val_generator(data_generator,
                          ds_metainfo,
                          batch_size):
    """
    Create image generator for validation subset.

    Parameters:
    ----------
    data_generator : ImageDataGenerator
        Image transform sequence.
    ds_metainfo : DatasetMetaInfo
        Pascal VOC2012 dataset metainfo.
    batch_size : int
        Batch size.

    Returns
    -------
    Sequential
        Image transform sequence.
    """
    split = "val"
    root = ds_metainfo.root_dir_path
    root = os.path.join(root, split)
    generator = data_generator.flow_from_directory(
        directory=root,
        target_size=ds_metainfo.input_image_size,
        class_mode="binary",
        batch_size=batch_size,
        shuffle=False,
        interpolation="bilinear",
        dataset=ds_metainfo.dataset_class(
            root=ds_metainfo.root_dir_path,
            mode="val",
            transform=ds_metainfo.val_transform2(
                ds_metainfo=ds_metainfo)))
    return generator 
开发者ID:osmr,项目名称:imgclsmob,代码行数:38,代码来源:coco_hpe2_dataset.py

示例7: cocohpe_test_generator

# 需要导入模块: from tensorflow.keras.preprocessing import image [as 别名]
# 或者: from tensorflow.keras.preprocessing.image import ImageDataGenerator [as 别名]
def cocohpe_test_generator(data_generator,
                           ds_metainfo,
                           batch_size):
    """
    Create image generator for testing subset.

    Parameters:
    ----------
    data_generator : ImageDataGenerator
        Image transform sequence.
    ds_metainfo : DatasetMetaInfo
        Pascal VOC2012 dataset metainfo.
    batch_size : int
        Batch size.

    Returns
    -------
    Sequential
        Image transform sequence.
    """
    split = "val"
    root = ds_metainfo.root_dir_path
    root = os.path.join(root, split)
    generator = data_generator.flow_from_directory(
        directory=root,
        target_size=ds_metainfo.input_image_size,
        class_mode="binary",
        batch_size=batch_size,
        shuffle=False,
        interpolation="bilinear",
        dataset=ds_metainfo.dataset_class(
            root=ds_metainfo.root_dir_path,
            mode="test",
            transform=ds_metainfo.test_transform2(
                ds_metainfo=ds_metainfo)))
    return generator 
开发者ID:osmr,项目名称:imgclsmob,代码行数:38,代码来源:coco_hpe2_dataset.py

示例8: cifar10_train_transform

# 需要导入模块: from tensorflow.keras.preprocessing import image [as 别名]
# 或者: from tensorflow.keras.preprocessing.image import ImageDataGenerator [as 别名]
def cifar10_train_transform(ds_metainfo,
                            data_format="channels_last"):
    """
    Create image transform sequence for training subset.

    Parameters:
    ----------
    ds_metainfo : DatasetMetaInfo
        ImageNet-1K dataset metainfo.
    data_format : str, default 'channels_last'
        The ordering of the dimensions in tensors.

    Returns
    -------
    ImageDataGenerator
        Image transform sequence.
    """
    data_generator = ImageDataGenerator(
        preprocessing_function=(lambda img: img_normalization(
            img=img,
            mean_rgb=ds_metainfo.mean_rgb,
            std_rgb=ds_metainfo.std_rgb)),
        shear_range=0.2,
        zoom_range=0.2,
        horizontal_flip=True,
        data_format=data_format)
    return data_generator 
开发者ID:osmr,项目名称:imgclsmob,代码行数:29,代码来源:cifar10_cls_dataset.py

示例9: cifar10_val_generator

# 需要导入模块: from tensorflow.keras.preprocessing import image [as 别名]
# 或者: from tensorflow.keras.preprocessing.image import ImageDataGenerator [as 别名]
def cifar10_val_generator(data_generator,
                          ds_metainfo,
                          batch_size):
    """
    Create image generator for validation subset.

    Parameters:
    ----------
    data_generator : ImageDataGenerator
        Image transform sequence.
    ds_metainfo : DatasetMetaInfo
        ImageNet-1K dataset metainfo.
    batch_size : int
        Batch size.

    Returns
    -------
    Sequential
        Image transform sequence.
    """
    assert(ds_metainfo is not None)
    _, (x_test, y_test) = cifar10.load_data()
    generator = data_generator.flow(
        x=x_test,
        y=y_test,
        batch_size=batch_size,
        shuffle=False)
    return generator 
开发者ID:osmr,项目名称:imgclsmob,代码行数:30,代码来源:cifar10_cls_dataset.py

示例10: imagenet_train_transform

# 需要导入模块: from tensorflow.keras.preprocessing import image [as 别名]
# 或者: from tensorflow.keras.preprocessing.image import ImageDataGenerator [as 别名]
def imagenet_train_transform(ds_metainfo,
                             data_format="channels_last"):
    """
    Create image transform sequence for training subset.

    Parameters:
    ----------
    ds_metainfo : DatasetMetaInfo
        ImageNet-1K dataset metainfo.
    data_format : str, default 'channels_last'
        The ordering of the dimensions in tensors.

    Returns
    -------
    ImageDataGenerator
        Image transform sequence.
    """
    data_generator = ImageDataGenerator(
        preprocessing_function=(lambda img: img_normalization(
            img=img,
            mean_rgb=ds_metainfo.mean_rgb,
            std_rgb=ds_metainfo.std_rgb)),
        shear_range=0.2,
        zoom_range=0.2,
        horizontal_flip=True,
        data_format=data_format)
    return data_generator 
开发者ID:osmr,项目名称:imgclsmob,代码行数:29,代码来源:imagenet1k_cls_dataset.py

示例11: imagenet_train_generator

# 需要导入模块: from tensorflow.keras.preprocessing import image [as 别名]
# 或者: from tensorflow.keras.preprocessing.image import ImageDataGenerator [as 别名]
def imagenet_train_generator(data_generator,
                             ds_metainfo,
                             batch_size):
    """
    Create image generator for training subset.

    Parameters:
    ----------
    data_generator : ImageDataGenerator
        Image transform sequence.
    ds_metainfo : DatasetMetaInfo
        ImageNet-1K dataset metainfo.
    batch_size : int
        Batch size.

    Returns
    -------
    Sequential
        Image transform sequence.
    """
    split = "train"
    root = ds_metainfo.root_dir_path
    root = os.path.join(root, split)
    generator = data_generator.flow_from_directory(
        directory=root,
        target_size=ds_metainfo.input_image_size,
        class_mode="binary",
        batch_size=batch_size,
        shuffle=False,
        interpolation=ds_metainfo.interpolation_msg)
    return generator 
开发者ID:osmr,项目名称:imgclsmob,代码行数:33,代码来源:imagenet1k_cls_dataset.py

示例12: imagenet_val_generator

# 需要导入模块: from tensorflow.keras.preprocessing import image [as 别名]
# 或者: from tensorflow.keras.preprocessing.image import ImageDataGenerator [as 别名]
def imagenet_val_generator(data_generator,
                           ds_metainfo,
                           batch_size):
    """
    Create image generator for validation subset.

    Parameters:
    ----------
    data_generator : ImageDataGenerator
        Image transform sequence.
    ds_metainfo : DatasetMetaInfo
        ImageNet-1K dataset metainfo.
    batch_size : int
        Batch size.

    Returns
    -------
    Sequential
        Image transform sequence.
    """
    split = "val"
    root = ds_metainfo.root_dir_path
    root = os.path.join(root, split)
    generator = data_generator.flow_from_directory(
        directory=root,
        target_size=ds_metainfo.input_image_size,
        class_mode="binary",
        batch_size=batch_size,
        shuffle=False,
        interpolation=ds_metainfo.interpolation_msg)
    return generator 
开发者ID:osmr,项目名称:imgclsmob,代码行数:33,代码来源:imagenet1k_cls_dataset.py

示例13: cub200_train_generator

# 需要导入模块: from tensorflow.keras.preprocessing import image [as 别名]
# 或者: from tensorflow.keras.preprocessing.image import ImageDataGenerator [as 别名]
def cub200_train_generator(data_generator,
                           ds_metainfo,
                           batch_size):
    """
    Create image generator for training subset.

    Parameters:
    ----------
    data_generator : ImageDataGenerator
        Image transform sequence.
    ds_metainfo : DatasetMetaInfo
        ImageNet-1K dataset metainfo.
    batch_size : int
        Batch size.

    Returns
    -------
    Sequential
        Image transform sequence.
    """
    root = ds_metainfo.root_dir_path
    generator = data_generator.flow_from_directory(
        directory=root,
        target_size=ds_metainfo.input_image_size,
        class_mode="binary",
        batch_size=batch_size,
        shuffle=False,
        interpolation=ds_metainfo.interpolation_msg,
        mode="val")
    return generator 
开发者ID:osmr,项目名称:imgclsmob,代码行数:32,代码来源:cub200_2011_cls_dataset.py

示例14: cub200_val_generator

# 需要导入模块: from tensorflow.keras.preprocessing import image [as 别名]
# 或者: from tensorflow.keras.preprocessing.image import ImageDataGenerator [as 别名]
def cub200_val_generator(data_generator,
                         ds_metainfo,
                         batch_size):
    """
    Create image generator for validation subset.

    Parameters:
    ----------
    data_generator : ImageDataGenerator
        Image transform sequence.
    ds_metainfo : DatasetMetaInfo
        ImageNet-1K dataset metainfo.
    batch_size : int
        Batch size.

    Returns
    -------
    Sequential
        Image transform sequence.
    """
    root = ds_metainfo.root_dir_path
    generator = data_generator.flow_from_directory(
        directory=root,
        target_size=ds_metainfo.input_image_size,
        class_mode="binary",
        batch_size=batch_size,
        shuffle=False,
        interpolation=ds_metainfo.interpolation_msg,
        mode="val")
    return generator 
开发者ID:osmr,项目名称:imgclsmob,代码行数:32,代码来源:cub200_2011_cls_dataset.py

示例15: __init__

# 需要导入模块: from tensorflow.keras.preprocessing import image [as 别名]
# 或者: from tensorflow.keras.preprocessing.image import ImageDataGenerator [as 别名]
def __init__(self,
                 input_shape,
                 filters=[32, 64, 128, 10],
                 n_clusters=10):

        self.n_clusters = n_clusters
        self.input_shape = input_shape
        self.datagen = ImageDataGenerator(width_shift_range=0.1, height_shift_range=0.1, rotation_range=10)
        self.datagenx = ImageDataGenerator()
        self.autoencoder, self.encoder = CAE(input_shape, filters)

        # Define ConvIDEC model
        clustering_layer = ClusteringLayer(self.n_clusters, name='clustering')(self.encoder.output)
        self.model = Model(inputs=self.autoencoder.input,
                           outputs=clustering_layer) 
开发者ID:XifengGuo,项目名称:DEC-DA,代码行数:17,代码来源:ConvDEC.py


注:本文中的tensorflow.keras.preprocessing.image.ImageDataGenerator方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。