Tensorflow images guide not working in Google Colab
10:19 29 Oct 2025

I'm trying to run the first guide from Tensorflow in Google Colab.

I import the dataset with

import pathlib

dataset_url = "https://storage.googleapis.com/download.tensorflow.org/example_images/flower_photos.tgz"
archive = tf.keras.utils.get_file(origin=dataset_url, extract=True)
data_dir = pathlib.Path(archive).with_suffix('')

However, when I run the following I get 0 images found

image_count = len(list(data_dir.glob('*/*.jpg')))
print(image_count)

When analyzing the routes and stuff I do this:

import os

print(data_dir)
print(archive)
os.listdir()

data dir says: /root/.keras/datasets/flower_photos

os.listdir(), on the other hand, says that I'm in the "content" folder. Which is in the same level as "root" folder.

Why aren't my images loading? Link to the notebook is here: https://colab.research.google.com/github/tensorflow/docs/blob/master/site/en/tutorials/load_data/images.ipynb

python tensorflow google-colaboratory