diff --git a/keras/layers/preprocessing/index_lookup.py b/keras/layers/preprocessing/index_lookup.py index caa0188c4ceb..1bcff31bd81b 100644 --- a/keras/layers/preprocessing/index_lookup.py +++ b/keras/layers/preprocessing/index_lookup.py @@ -17,7 +17,6 @@ # pylint: disable=g-classes-have-attributes import collections -import os from keras import backend from keras.engine import base_layer_utils @@ -372,7 +371,7 @@ def set_vocabulary(self, vocabulary, idf_weights=None): "TF_IDF. output_mode is {}.".format(self.output_mode)) if isinstance(vocabulary, str): - if not os.path.exists(vocabulary): + if not tf.io.gfile.exists(vocabulary): raise ValueError( "Vocabulary file {} does not exist.".format(vocabulary)) if self.output_mode == TF_IDF: