This Content is from Stack Overflow. Question asked by Me Bottle O Scrumpy
I am trying to implement a simple classification model, but there seems to be a problem with the “Dataset” object.
import matplotlib.pyplot as plt import numpy as np import PIL import tensorflow as tf
The code to generate training dataset is:
train_ds = tf.keras.utils.image_dataset_from_directory( TRAIN_DIR, validation_split = 0.25, seed = 3, image_size = (224, 224), batch_size = batch_size, subset = 'training', shuffle = True, labels = 'inferred', label_mode = 'categorical' )
and for validation it is:
validation_data = tf.keras.utils.image_dataset_from_directory( TRAIN_DIR, validation_split = 0.25, seed = 3, image_size = (224, 224), batch_size = batch_size, subset = 'validation', shuffle = True, labels = 'inferred', label_mode = 'categorical' )
i dont think there is anything special about the code but when i execute the following code:
class_names = train_ds.class_names plt.figure(figsize=(10, 10)) for images, labels in train_ds.take(1): for i in range(9): ax = plt.subplot(3, 3, i + 1) plt.imshow(images[i].numpy().astype("uint8")) plt.title(class_names[np.argmax(labels[i])]) plt.axis("off")
it shows “Cleanup called…” in several lines.
same thing happens when i try to fit the model using
I am using a simple
Kaggle notebook and
tensorflow version is
i tried several solutions found in the site, such as downgrading to a lower version of
tensorflow, but in that case
tf.keras.utils.image_dataset_from_directory does not seem to work at all.
i tried to hide error messages by:
os.environ['TF_CPP_MIN_LOG_LEVEL'] = '3'
and this didn’t work either.
i tried rest of the solutions in here, but they didn’t.
I checked other codes for the same dataset, they were using the deprecated ImageDataGenerator.
So my question is, is there a work around or a simple solution to disable these “Cleanup Called…” messages and still using
PS: Most of the code is copied from Image Classification, when implementing this dataset there seems to be no problem, but when implementing other datasets, that are added to the
output of a kernel, this problem occures.
You can disable all debugging logs using
import os os.environ['TF_CPP_MIN_LOG_LEVEL'] = '3' import tensorflow as tf
Tested on tf 0.12 and 1.0
0 = all messages are logged (default behavior) 1 = INFO messages are not printed 2 = INFO and WARNING messages are not printed 3 = INFO, WARNING, and ERROR messages are not printed
This Question was asked in StackOverflow by Ghilas BELHADJ and Answered by mwweb It is licensed under the terms of CC BY-SA 2.5. - CC BY-SA 3.0. - CC BY-SA 4.0.