Skip to content

sumitmodanwal962/Cynaptics

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

11 Commits
 
 
 
 
 
 

Repository files navigation

README: Face Image Generation using GAN

1. Dataset Preparation

This section covers the steps required to download and prepare the dataset for training the GAN model.

Steps:

  1. Install Kaggle Library: The Kaggle library is installed using pip install kaggle.
  2. Upload Kaggle API Key: The user is prompted to upload the kaggle.json file.
  3. Move Kaggle API Key: The API key is moved to ~/.kaggle/ and permissions are set.
  4. Download Dataset: The dataset pretty-face is downloaded from Kaggle.
  5. Extract Dataset: The downloaded ZIP file is extracted to a folder.
  6. Verify Dataset: The extracted files are listed to confirm successful extraction.

2. Image Processing

This section involves loading and processing images into a format suitable for training.

Steps:

  1. Load Image using OpenCV: A sample image is loaded and displayed using cv2_imshow.
  2. Resize Image: The image is resized to (256,256) using OpenCV.
  3. Convert Images to NumPy Array:
    • Images from the dataset folder are loaded using Pillow (PIL).
    • Images are converted to RGB and resized to (64,64).
    • Images are stored as a NumPy array for efficient processing.
  4. Check Array Shape: The final dataset shape is printed for verification.

3. GAN Model Training

This section covers defining, compiling, and training the Generative Adversarial Network (GAN).

Steps:

  1. Define Generator Model: A deep learning model is created to generate 64x64x3 images from random noise.
  2. Define Discriminator Model: A convolutional neural network (CNN) is built to classify images as real or fake.
  3. Define GAN Model: The Generator and Discriminator are combined into a GAN model.
  4. Compile Models:
    • The Discriminator is compiled using binary_crossentropy loss.
    • The GAN is compiled using an Adam optimizer.
  5. Normalize Dataset: The images are normalized to the range [-1,1] for better training.
  6. Train the GAN:
    • The Discriminator is trained on real and fake images.
    • The Generator is trained to improve image quality.
    • Training progress is displayed every few epochs.
  7. Save and Display Generated Images: Every few epochs, sample images generated by the GAN are saved and displayed.
  8. Run Training: The GAN training process is executed for 500 epochs.

Expected Outcome:

  • The model will generate face-like images based on the dataset.
  • Over time, the generated images should become more realistic.

Notes:

  • The training process may take around an hour on a T4 GPU.
  • Adjusting hyperparameters (learning rate, batch size, etc.) can improve results.
  • Ensure the dataset is properly downloaded before running the GAN training.

IMAGE

Author: [Sumit Modanwal]
Date: [17 January 2025]

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages