NVIDIA / tensorflow

An Open Source Machine Learning Framework for Everyone
https://developer.nvidia.com/deep-learning-frameworks
Apache License 2.0
990 stars 152 forks source link

module 'tensorflow.python.keras.api._v1.keras.preprocessing' has no attribute 'image_dataset_from_directory' #33

Open AmirthaRajan opened 3 years ago

AmirthaRajan commented 3 years ago

System information

When i tried using the tf.keras.preprocessing.image_dataset_from_directory in TF 2.5.0 it works fine but on trying the same in nvidia-tensorflow package it is says image_dataset doesn't exist.

Code to reproduce the issue ` import pathlib import tensorflow as tf from tensorflow import keras

data_dir_train = pathlib.Path("/images_train")

train_ds = tf.keras.preprocessing.image_dataset_from_directory( data_dir_train, validation_split=0.2, subset="training", seed=123, image_size=(180, 180), batch_size=32)`

Other info / logs

AttributeError Traceback (most recent call last)

in 2 ## Note use seed=123 while creating your dataset using tf.keras.preprocessing.image_dataset_from_directory 3 ## Note, make sure your resize your images to the size img_height*img_width, while writting the dataset ----> 4 train_ds = tf.keras.preprocessing.image_dataset_from_directory( 5 data_dir_train, 6 validation_split=0.2, ~/.local/lib/python3.8/site-packages/tensorflow_core/python/util/module_wrapper.py in __getattr__(self, name) 191 def __getattr__(self, name): 192 try: --> 193 attr = getattr(self._tfmw_wrapped_module, name) 194 except AttributeError: 195 if not self._tfmw_public_apis: AttributeError: module 'tensorflow.python.keras.api._v1.keras.preprocessing' has no attribute 'image_dataset_from_directory' > I tried comparing the packages and found it is missing in nvidia-tensorflow > https://github.com/tensorflow/tensorflow/tree/master/tensorflow/python/keras/preprocessing > https://github.com/NVIDIA/tensorflow/tree/r1.15.5%2Bnv21.05/tensorflow/python/keras/preprocessing **Is this a known bug or am i missing something ?**
DEKHTIARJonathan commented 3 years ago

You answered your own question:

When i tried using the tf.keras.preprocessing.image_dataset_from_directory in TF 2.5.0 it works fine but on trying the same in nvidia-tensorflow package it is says image_dataset doesn't exist.

This codebase is TF 1.15.X not TF 2.5. TF 1.15 is 2 years old so I can guarantee many APIs will be missing.

AmirthaRajan commented 3 years ago

You answered your own question:

When i tried using the tf.keras.preprocessing.image_dataset_from_directory in TF 2.5.0 it works fine but on trying the same in nvidia-tensorflow package it is says image_dataset doesn't exist.

This codebase is TF 1.15.X not TF 2.5. TF 1.15 is 2 years old so I can guarantee many APIs will be missing.

Sorry for the confusion when I mentioned version TF 2.5 I was talking about Official TensorFlow (google) package and here nvidia-tensorflow package doesn't have version above 1.15.x

https://github.com/tensorflow/tensorflow/tree/master/tensorflow/python/keras/preprocessing https://github.com/NVIDIA/tensorflow/tree/r1.15.5%2Bnv21.05/tensorflow/python/keras/preprocessing

I compared this module in both Official TF and Nvidia-TF from above links. So was concerned on its date of release in upcoming builds...