keras如何批量读取图片_在图像分割任务中Keras读取大量数据的方法

最近经常使用keras进行图像分割,小数据量时很方便,直接准备好image和mask,然后

model.fit(x_train, y_train, batch_size=32, epochs=10)

比较简单,但是这只是在小数据量的情况下使用。遇到大数据量,一次存入所有图像和mask会内存不够。在keras中文文档中写到了利用图片生成器ImageDataGenerator的方法,但是第一个例子和第二个例子是关于图像分类的,在最后一个例子和图像分割有关,放上代码:

# we create two instances with the same arguments

data_gen_args = dict(featurewise_center=True,

featurewise_std_normalization=True,

rotation_range=90.,

width_shift_range=0.1,

height_shift_range=0.1,

zoom_range=0.2)

image_datagen = ImageDataGenerator(**data_gen_args)

mask_datagen = ImageDataGenerator(**data_gen_args)

# Provide the same seed and keyword arguments to the fit and flow methods

seed = 1

image_datagen.fit(images, augment=True, seed=seed)

mask_datagen.fit(masks, a

  • 1
    点赞
  • 3
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值