admin管理员组文章数量:1024592
Im trying to use the celeba dataset for a vgg16 model, however when I try to run this code
import tensorflow as tf
from tensorflow.keras.preprocessing.image import ImageDataGenerator
from tensorflow.keras.applications.vgg16 import VGG16, preprocess_input
from tf_explain.core.grad_cam import GradCAM
import matplotlib.pyplot as plt
import numpy as np
import os
# Set path for validation datasets (update these paths accordingly)
val_dir = '/content/drive/MyDrive/Datasets/img_align_celeba'
# Define the image size VGG16 expects
target_size = (224, 224)
# Define ImageDataGenerator for validation data
val_datagen = ImageDataGenerator(
rescale=1./255, # Normalize pixel values to [0, 1]
preprocessing_function=preprocess_input # VGG16 preprocessing
)
# Create the validation generator
val_generator = val_datagen.flow_from_directory(
val_dir,
target_size=target_size,
batch_size=32, # You can adjust batch size
class_mode='categorical', # Assuming categorical labels (one-hot encoded)
shuffle=False # We don't shuffle in the validation set
)
# Fetch a batch of validation images
X_val, y_val = next(val_generator)
I get the error
Found 0 images belonging to 0 classes.
there are no subdirectories the img_align_celeba folder, just images. link to dataset:
I have extracted the zip and just uploaded a folder containing the images? Need some guidance on how to work with this dataset.
Im trying to use the celeba dataset for a vgg16 model, however when I try to run this code
import tensorflow as tf
from tensorflow.keras.preprocessing.image import ImageDataGenerator
from tensorflow.keras.applications.vgg16 import VGG16, preprocess_input
from tf_explain.core.grad_cam import GradCAM
import matplotlib.pyplot as plt
import numpy as np
import os
# Set path for validation datasets (update these paths accordingly)
val_dir = '/content/drive/MyDrive/Datasets/img_align_celeba'
# Define the image size VGG16 expects
target_size = (224, 224)
# Define ImageDataGenerator for validation data
val_datagen = ImageDataGenerator(
rescale=1./255, # Normalize pixel values to [0, 1]
preprocessing_function=preprocess_input # VGG16 preprocessing
)
# Create the validation generator
val_generator = val_datagen.flow_from_directory(
val_dir,
target_size=target_size,
batch_size=32, # You can adjust batch size
class_mode='categorical', # Assuming categorical labels (one-hot encoded)
shuffle=False # We don't shuffle in the validation set
)
# Fetch a batch of validation images
X_val, y_val = next(val_generator)
I get the error
Found 0 images belonging to 0 classes.
there are no subdirectories the img_align_celeba folder, just images. link to dataset:
https://www.kaggle/datasets/jessicali9530/celeba-dataset
I have extracted the zip and just uploaded a folder containing the images? Need some guidance on how to work with this dataset.
Share Improve this question asked Nov 18, 2024 at 16:19 Jasmine Jasmine 12 bronze badges1 Answer
Reset to default 0actual size of those images 178x218, not 224x224. Replace this target_size = (224, 224)
by target_size = (178, 218)
Im trying to use the celeba dataset for a vgg16 model, however when I try to run this code
import tensorflow as tf
from tensorflow.keras.preprocessing.image import ImageDataGenerator
from tensorflow.keras.applications.vgg16 import VGG16, preprocess_input
from tf_explain.core.grad_cam import GradCAM
import matplotlib.pyplot as plt
import numpy as np
import os
# Set path for validation datasets (update these paths accordingly)
val_dir = '/content/drive/MyDrive/Datasets/img_align_celeba'
# Define the image size VGG16 expects
target_size = (224, 224)
# Define ImageDataGenerator for validation data
val_datagen = ImageDataGenerator(
rescale=1./255, # Normalize pixel values to [0, 1]
preprocessing_function=preprocess_input # VGG16 preprocessing
)
# Create the validation generator
val_generator = val_datagen.flow_from_directory(
val_dir,
target_size=target_size,
batch_size=32, # You can adjust batch size
class_mode='categorical', # Assuming categorical labels (one-hot encoded)
shuffle=False # We don't shuffle in the validation set
)
# Fetch a batch of validation images
X_val, y_val = next(val_generator)
I get the error
Found 0 images belonging to 0 classes.
there are no subdirectories the img_align_celeba folder, just images. link to dataset:
I have extracted the zip and just uploaded a folder containing the images? Need some guidance on how to work with this dataset.
Im trying to use the celeba dataset for a vgg16 model, however when I try to run this code
import tensorflow as tf
from tensorflow.keras.preprocessing.image import ImageDataGenerator
from tensorflow.keras.applications.vgg16 import VGG16, preprocess_input
from tf_explain.core.grad_cam import GradCAM
import matplotlib.pyplot as plt
import numpy as np
import os
# Set path for validation datasets (update these paths accordingly)
val_dir = '/content/drive/MyDrive/Datasets/img_align_celeba'
# Define the image size VGG16 expects
target_size = (224, 224)
# Define ImageDataGenerator for validation data
val_datagen = ImageDataGenerator(
rescale=1./255, # Normalize pixel values to [0, 1]
preprocessing_function=preprocess_input # VGG16 preprocessing
)
# Create the validation generator
val_generator = val_datagen.flow_from_directory(
val_dir,
target_size=target_size,
batch_size=32, # You can adjust batch size
class_mode='categorical', # Assuming categorical labels (one-hot encoded)
shuffle=False # We don't shuffle in the validation set
)
# Fetch a batch of validation images
X_val, y_val = next(val_generator)
I get the error
Found 0 images belonging to 0 classes.
there are no subdirectories the img_align_celeba folder, just images. link to dataset:
https://www.kaggle/datasets/jessicali9530/celeba-dataset
I have extracted the zip and just uploaded a folder containing the images? Need some guidance on how to work with this dataset.
Share Improve this question asked Nov 18, 2024 at 16:19 Jasmine Jasmine 12 bronze badges1 Answer
Reset to default 0actual size of those images 178x218, not 224x224. Replace this target_size = (224, 224)
by target_size = (178, 218)
本文标签: pythonTrouble loading the celebA dataset for vgg16 modelStack Overflow
版权声明:本文标题:python - Trouble loading the celebA dataset for vgg16 model - Stack Overflow 内容由热心网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://it.en369.cn/questions/1745608250a2158851.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论