![](/img/trans.png)
[英]Keras: how to disable resizing of images when using an ImageDataGenerator with flow_from_dataframe / flow_from_directory?
[英]How to use augmentations with ImageDataGenerator().flow_from_dataframe?
似乎沒有 map 方法:
aug_ds = train_ds.map(
lambda x, y: (resize_and_rescale(x, training=True), y))
AttributeError: 'DataFrameIterator' object has no attribute 'map'
當然,我可以使用 model 中的預處理層,但我需要自定義函數來進行擴充。
您可以使用ImageDataGenerator
的preprocessing_function
參數來添加額外的增強。 function 將在圖像調整大小和增強后運行。 但是,請注意文檔中的警告:
警告:不建議將 tf.keras.preprocessing.image.ImageDataGenerator 用於新代碼。 更喜歡使用 tf.keras.utils.image_dataset_from_directory 加載圖像並使用預處理層轉換 output tf.data.Dataset。 有關詳細信息,請參閱加載圖像和增強圖像的教程以及預處理層指南。
因此,也許只使用tf.keras.utils.image_dataset_from_directory
。
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.