Imagedatagenerator.flow()和Imagedatagenerator.flow_from_directory()有什么区别?
datagen = ImageDataGenerator(rotation_range = 20, zoom_range = 15, width_shift_range=0.2,
height_shift_range=0.2, shear_range=0.15, horizontal_flip=True,
vertical_flip=True, fill_mode='nearest')
datagen.flow()
和datagen.flow_from_directory
之间有什么区别?
datagen = ImageDataGenerator(rotation_range = 20, zoom_range = 15, width_shift_range=0.2,
height_shift_range=0.2, shear_range=0.15, horizontal_flip=True,
vertical_flip=True, fill_mode='nearest')
What is the difference between datagen.flow()
and datagen.flow_from_directory
?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
datagen.flow():此方法期望输入数据作为numpy数组提供。当您将整个数据集加载到内存中时,通常会使用此方法。您将图像的数组及其相应的标签传递给Flow()方法,以生成增强数据的批次。
datagen.flow_from_directory():此方法旨在与在目录结构中组织的图像数据一起工作,其中每个子目录代表一个类,并包含属于该类的图像。该方法会自动从目录结构中输入类标签。您只需要指定包含图像的目录,该方法将使用适当的标签生成大量的增强数据。
datagen.flow(): This method expects the input data to be provided as Numpy arrays. You would typically use this method when you have already loaded your entire dataset into memory as Numpy arrays. You pass the Numpy arrays of images and their corresponding labels to the flow() method to generate batches of augmented data.
datagen.flow_from_directory(): This method is designed to work with image data that is organized in a directory structure, where each subdirectory represents a class and contains the images belonging to that class. The method automatically infers the class labels from the directory structure. You only need to specify the directory containing the images, and the method will generate batches of augmented data with the appropriate labels.