This project is an implementation of Deep Convolutional Generative Adversarial Networks (DCGANs) using PyTorch, structured with Object-Oriented Programming (OOP) principles.
- Operating System: Windows 11
- GPU: Nvidia GTX 1050 Ti
- CPU: Intel Core i7-8750H
- RAM: 16 GB
- CUDA Version: 11.8 (installed via PyTorch using pip command)
- Anaconda: Python 3.11+
Before running the project, ensure that Nvidia CUDA is installed on your PC.
- CHANNELS_IMG:
- Automatically uncommented: Assumes the dataset is RGB images with 3 channels.
- Uncomment manually: If using MNIST dataset or any dataset with monocolor (1 channel).
- Z_DIM: Noise dimension (set to 100).
- NUM_EPOCHS: Number of training epochs (set to 50).
To use the MNIST dataset:
- Uncomment line 25 in
Training.py
. - Comment line 24.
Note: The MNIST dataset is available to download via a Python script. Other datasets must be downloaded manually and placed in their respective folders (/MRI/, /celeb_dataset/, etc.).
- For 3 channels: Uncomment line 19 and comment line 20 in
Training.py
. - For 1 channel: Uncomment line 20 and comment line 19 in
Training.py
.
transform = transforms.Compose([
transforms.Resize((IMAGE_SIZE, IMAGE_SIZE)),
transforms.ToTensor(),
transforms.Normalize((0.5, 0.5, 0.5), (0.5, 0.5, 0.5))
])
transform = transforms.Compose([
transforms.Resize((IMAGE_SIZE, IMAGE_SIZE)),
transforms.ToTensor(),
# transforms.Normalize((0.5, 0.5, 0.5), (0.5, 0.5, 0.5))
transforms.Normalize((0.5,), (0.5,))
])
Here are two examples of generated images after training:
You can test the project by running the Test.py
file with the following command:
python Test.py
or
python main.py
To run the script:
python Training.py