Просмотр исходного кода

Merge: [Efficientnet/TF2] fix keras imports

Krzysztof Kudrynski 2 лет назад
Родитель
Сommit
96bdb5b35f
1 измененных файлов с 5 добавлено и 1 удалено
  1. 5 1
      TensorFlow2/Classification/ConvNets/dataloader/augment.py

+ 5 - 1
TensorFlow2/Classification/ConvNets/dataloader/augment.py

@@ -26,7 +26,11 @@ import math
 import tensorflow as tf
 from typing import Any, Dict, List, Optional, Text, Tuple
 
-from keras.layers.preprocessing import image_preprocessing as image_ops
+try:
+    from keras.layers.preprocessing import image_preprocessing as image_ops
+except (ImportError, ModuleNotFoundError):
+    import keras.src.layers.preprocessing.image_preprocessing as image_ops
+
 
 # This signifies the max integer that the controller RNN could predict for the
 # augmentation scheme.