A PyTorch implementation of a Conditional Generative Adversarial Network (cGAN) for adjusting image lighting conditions. This model can convert normal-light images to either low-light or bright-light conditions using controllable conditioning.
Feature | Description |
---|---|
🔄 Bidirectional Adjustment | Convert normal → bright or normal → low-light |
🎚️ Conditional Control | Parameter range (-1.0 to 1.0) for light intensity |
📊 Training Data | LOL-v2 dataset (Real and Synthetic) |
🚀 Versatile | Supports both training and inference modes |
The project uses the LOL-v2 dataset with the following structure:
dataset/LOL-v2/
Real_captured/
Train/
Normal/
Low/
Bright/
Test/
Normal/
Low/
Bright/
Synthetic/
Train/
Normal/
Low/
Bright/
Test/
Normal/
Low/
Bright/
To get the bright images run the
generate_bright.py
python3 generate_bright.py
Then modify the image names by running
remove_prefix.py
python3 remove_prefix.py
1. PyTorch (with CUDA)
pip install torch torchvision --index-url https://download.pytorch.org/whl/cu124
2. All other dependencies
pip install -r requirements.txt
To train the model from scratch:
python3 train_cgan.py
Convert single image with specific condition
# Convert to bright image
python3 test_cgan.py --input path/to/normal/image.jpg --output output/bright_image.jpg --condition 1.0
# Convert to low-light image
python3 test_cgan.py --input path/to/normal/image.jpg --output output/low_image.jpg --condition -1.0
Convert to both conditions at once
python3 single_image_convert.py --input sample/lion.jpeg --output-dir output --model checkpoints/best_model.pth
- Encoder-decoder architecture with skip connections
- Input: Normal-light image + condition value
- Output: Generated image with adjusted lighting
- Convolutional neural network
- Input: Image + condition value
- Output: Real/Fake prediction
The model saves two types of checkpoints in the checkpoints
directory:
latest_checkpoint.pth
: Latest training statebest_model.pth
: Best performing model based on generator loss