Skip to content

Instantly share code, notes, and snippets.

@pythonlessons
Created May 30, 2023 08:45
Show Gist options
  • Select an option

  • Save pythonlessons/d48f165daa37d0d0bfef2723ddd1cb34 to your computer and use it in GitHub Desktop.

Select an option

Save pythonlessons/d48f165daa37d0d0bfef2723ddd1cb34 to your computer and use it in GitHub Desktop.
wgan_gp
# celebA dataset path
dataset_path = "Dataset/img_align_celeba"
# Set the input shape and size for the generator and discriminator
batch_size = 128
img_shape = (64, 64, 3) # The shape of the input image, input to the discriminator
noise_dim = 128 # The dimension of the noise vector, input to the generator
model_path = 'Models/02_WGANGP_faces'
os.makedirs(model_path, exist_ok=True)
# Define your data generator
datagen = ImageDataGenerator(
preprocessing_function=lambda x: (x / 127.5) - 1.0, # Normalize image pixel values to [-1, 1]
horizontal_flip=True # Data augmentation
)
# Create a generator that yields batches of images
train_generator = datagen.flow_from_directory(
directory=dataset_path, # Path to directory containing images
target_size=img_shape[:2], # Size of images (height, width)
batch_size=batch_size,
class_mode=None, # Do not use labels
shuffle=True, # Shuffle the data
)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment