Hello, everyone I want to thank the tensorflow community for creating such an amazing neural network framework.
I am a newbie to tensorflow and machine learning. So, I have a question to ask in regarding to create an input pipeline for Image regression. ( For example - predicting house price form images )
I am aware of tf.keras.utils.image_dataset_from_directory
function but it is for classification right ? So I cannot map my continuous numerical values(in a numpy array) with the images(in my directory) using the above function for regression. In some old blogs, it was done by loading the image paths and corresponding numeric labels in a pandas dataframe and then using the .flow_from_dataframe()
funciton. But since the tf.keras.preprocessing.image.ImageDataGenerator
is depreciated, I don’t want to use it. So, I created my own input pipeline manually by using tf.data.Dataset.list_files()
to load my image paths form the disk and then using map()
function to create “tf dataset” and load it directly form the disk in batches.
So, does there exist any better method ? Or is there such a fuction which I am not of ?
1 Like
Hi @Alpha_bravo, I think you can also use tf.data.Dataset.from_tensor_slices()
for creating the dataset for this use case like
#assume this are image pixel values
image1=tf.random.normal([128,128,1])
image2=tf.random.normal([128,128,1])
#house price
price=[10,20]
#you can create a dataset using
image_values=[image1,image2]
dataset = tf.data.Dataset.from_tensor_slices((image_values, price))
Thank You.
1 Like