how to create multi images input and single output tensorflow dataset

Issue

I am trying to create a dataset something like where my model.evaluate func will be like this:-

model.evaluate([img1, img2, img3, img4], labels)

but since there was a really large amount of data I decided to use tf.dataset, but how can I create a dataset like this?

I know how to create a simple image dataset like this:-

train_ds = tf.keras.preprocessing.image_dataset_from_directory(
  data_dir,
  validation_split=0.2,
  subset="training",
  seed=123,
  image_size=(img_height, img_width),
  batch_size=batch_size)

val_ds = tf.keras.preprocessing.image_dataset_from_directory(
  data_dir,
  validation_split=0.2,
  subset="validation",
  seed=123,
  image_size=(img_height, img_width),
  batch_size=batch_size)

I am little new to TensorFlow and deep learning, so I don’t know how to do something like this, I tried to see all the available guides, but that didn’t help unfortunately, I was not able to understand them.

Solution

So for this, I ended up using tf.io.TFRecordWriter and tf.train.Example, so, if anyone looking for a solution for this, could look at these.

Answered By – Vishnu

This Answer collected from stackoverflow, is licensed under cc by-sa 2.5 , cc by-sa 3.0 and cc by-sa 4.0

Leave a Reply

(*) Required, Your email will not be published