FLX-20 / Data-Science-Toolkits-and-Architectures-group-1

This is our group repository for the subject Data Science Toolkits and Architectures at the University of Lucerne, where we share the results of our latest milestone.
0 stars 0 forks source link

Tenosrflow Documentation: Load and preprocess images #18

Open FLX-20 opened 2 weeks ago

FLX-20 commented 2 weeks ago

Why does the copied code from the tensorflow documentation result in 0? According to the documentation, the number of images in the directory should be returned.

import pathlib
import tensorflow as tf
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('')

image_count = len(list(data_dir.glob('*/*.jpg')))
print(image_count)
Tjerk8389 commented 1 week ago

There is probably something from with this code:

data_dir = pathlib.Path(archive).with_suffix('')

You need to correctly set data_dir to the folder where it is extracted, which contains the image files.