Open jkylearmstrong opened 1 year ago
The data is on already available on Kaggle. The fix is pretty much in line with the other Kaggle examples in the book https://www.kaggle.com/datasets/jessicali9530/celeba-dataset
from tensorflow import keras
from tensorflow.keras import layers
from tensorflow import keras
from tensorflow.keras import layers
from google.colab import files
files.upload()
!pip install -U -q kaggle
!mkdir ~/.kaggle # make directory
!cp kaggle.json ~/.kaggle/ # copy the file
!chmod 600 ~/.kaggle/kaggle.json # change permissions on API key file make it only readable to yourself
!kaggle datasets download jessicali9530/celeba-dataset
!unzip -qq celeba-dataset.zip
import os
# Get the list of all files and directories
path = "img_align_celeba/img_align_celeba"
dir_list = os.listdir(path)
print("Files and directories in '", path, "' :")
# prints all files
print(dir_list)
from tensorflow import keras
dataset = keras.utils.image_dataset_from_directory(
"img_align_celeba/img_align_celeba",
label_mode=None,
image_size=(64, 64),
batch_size=32,
smart_resize=True)
The rest of the code appears to work as expected. However, there is a warning for this block:
dataset = dataset.map(lambda x: x / 255.)
WARNING:tensorflow:From /usr/local/lib/python3.8/dist-packages/tensorflow/python/autograph/pyct/static_analysis/liveness.py:83: Analyzer.lamba_check (from tensorflow.python.autograph.pyct.static_analysis.liveness) is deprecated and will be removed after 2023-09-23.
Instructions for updating:
Lambda fuctions will be no more assumed to be used in the statement where they are used, or at least in the same block. https://github.com/tensorflow/tensorflow/issues/56089