InvalidArgumentError: Expected 'tf.Tensor(False, shape=(), dtype=bool)' to be true. Summarized data: b'No files matched pattern:

Viewed 1779

When I am running the following code on Google colab,

tf.data.Dataset.list_files('/content/gdrive/MyDrive/Experiment/train/*.jpg')

I am getting the following error:

InvalidArgumentError                      Traceback (most recent call last)
<ipython-input-4-8d9cebdfe01f> in <module>()
----> 1 tf.data.Dataset.list_files('/content/gdrive/MyDrive/Experiment/train/*.jpg')

3 frames
/usr/local/lib/python3.7/dist-packages/tensorflow/python/ops/control_flow_ops.py in Assert(condition, data, summarize, name)
    162           op=None,
    163           message="Expected '%s' to be true. Summarized data: %s" %
--> 164           (condition, "\n".join(data_str)))
    165     return
    166 

InvalidArgumentError: Expected 'tf.Tensor(False, shape=(), dtype=bool)' to be true. Summarized data: b'No files matched pattern: /content/gdrive/MyDrive/Experiment/train/*.jpg'

I am stuck with this problem for the last two weeks, please help me out. Also, I have mounted the Google drive successfully before running the above lines of code.

1 Answers

enter image description here

This is the example I am working with.

from google.colab import drive
drive.mount('/content/drive')

def load_image(filepath):
    raw_img = tf.io.read_file(filepath) 
    img_tensor_int = tf.image.decode_jpeg(raw_img, channels=3)
    img_tensor_flt = tf.image.convert_image_dtype(img_tensor_int, tf.float32)
    return img_tensor_flt, img_tensor_flt

def load_dataset(split):
    print('/content/drive/MyDrive/CelebAsubset/'+split+'/*.jpg')
    train_list_ds = tf.data.Dataset.list_files('/content/drive/MyDrive/CelebAsubset/'+split+'/*.jpg', shuffle=False)
    train_ds = train_list_ds.map(load_image)
    return train_ds

train_ds = load_dataset('train')
val_ds = load_dataset('val')

test_ds = load_dataset('test')
Related