This repository implements a Generative Adversarial Network (GAN) using PyTorch.
It allows training and using a generator model to produce realistic images of Cat🐈 from random noise vectors.
The project is designed to be modular, so you can train your own GAN on a custom dataset or load pre-trained models to generate images quickly.
For me, I used a dataset of cat pictures to train it ! 😺
- 🎨 Train a GAN on your own dataset of images.
- 💾 Save and reload both generator and discriminator models.
- 🎲 Generate batches of fake images directly from random noise.
- 📊 Visualization of generated samples during training.
🔍 Preliminary Results:
Some generated images show recognizable cat features ✅, but results still need improvement.
Longer training (~13h GPU 💻🔥) would be required for sharper, more realistic outputs.
-
🎨 Generator (GNet) Transforms a random noise vector (latent space: 📏
100) → synthetic images (🖼️3x64x64). -
🔍 Discriminator (DNet) Receives real or generated images → outputs a probability of being "real" (✅ or ❌).
-
🔄 Training Loop
- Discriminator: Learns to distinguish real 📸 vs. fake 🤖 images.
- Generator: Learns to fool 🎭 the discriminator.
- Optimizer: Adam (📈
lr=0.0002).
-
💾 Save & Reuse Models are saved as
.pthfiles for later inference or fine-tuning.
Here is the GAN architecture :

/file
├── Dataset_image/
│ ├── image_folder/chats # Folder containing training images / Here, it's cat 😺 !
│ ├── model/ # Saved models (generator & discriminator)
│ ├── result_image/ # Generated results
├── Img/ # Subfolder with the example image for the README.md
├── LICENSE
├── README.md
├── main.pyClone the repository and install dependencies:
git clone https://github.com/Thibault-GAREL/Image_generator_GAN.git
cd Image_generator_GAN
pip install numpy torch torchvision matplotlib
# install with Cuda:
# pip install torch torchvision torchaudio --index-url https://download.pytorch.org/whl/cu118Train the GAN (adjust number of epochs 🔁 in the script):
python main.pyTo generate and display images using the last models:
python main.py #Put num_epochs = 0 l.40- 🎥 I follow the learning video : GAN from NeoCode
Code created by me 😎, Thibault GAREL - Github




