Real-Time Dehazing & Deraining using CycleGAN
Weather conditions like haze and rain degrade visibility, reducing the reliability of computer vision systems used in:
- Autonomous navigation
- Surveillance
- Remote sensing
- Image & video enhancement
This project introduces a CycleGAN-based system for high-resolution multi-weather degradation removal. Unlike conventional dehazing/deraining approaches, our model:
- Operates on native image resolution (avoiding downscaling)
- Handles both haze & rain simultaneously
- Achieves competitive state-of-the-art results on benchmark datasets
- πΉ Custom Dataset: 7,614 unpaired images (synthetic + real) from REVIDE, Rain1400, and Dense-Haze
- πΉ Architecture Modifications: CycleGAN tailored for high-fidelity restoration
- πΉ Training Optimizations: ADAM optimizer, 100 epochs, unpaired image learning
- πΉ Benchmark Testing: Evaluated on SOTS and O-HAZE datasets
- πΉ Results: Achieved PSNR ~29 dB and competitive SSIM scores
πΉ Why CycleGAN?
CycleGAN enables image-to-image translation without paired datasets, making it ideal for visibility enhancement where paired clean-weather images are hard to obtain.
πΉ Architecture
Generator: Translates hazy/rainy frames into clear frames
Discriminator: Ensures generated outputs are visually realistic
Cycle Consistency Loss: Maintains structural fidelity between degraded and restored images.

βββ canny_edge_det/ # Checks image features through canny edges
βββ checkpoints/ # Saved model checkpoints
βββ data/ # Datasets (train/test splits)
βββ datasets/ # Dataset processing scripts
βββ docs/ # Documentation and related resources
βββ imgs/ # Images for README/demo
βββ input_images/ # Input images for testing
βββ input_videos/ # Input videos for testing
βββ models/ # Stores models
βββ onnx/ # Converts model to .onnx format
βββ options/ # Configuration files and options
βββ results/ # Generated results (images/videos)
βββ results_past/ # Previous experiment results
βββ scripts/ # Utility scripts for training/inference
βββ util/ # Helper functions and utilities
β
βββ LICENSE # License file (MIT)
βββ README.md # Project documentation
βββ desktop.ini # Windows system file (can be ignored)
βββ server.py # API/Server script
βββ test.py # Testing script
βββ test_native_live.py # Live webcam inference (native resolution)
βββ test_pic.py # Single image test script
βββ test_resize.py # Test with resized inputs
βββ test_server.py # Server-based test script
βββ test_video.py # Video file inference
βββ test_video_live.py # Live video stream inference
βββ train.py # Training entry point
βββ yolov8.pt # YOLOv8 weights (for auxiliary tasks if used)
| Dataset | Train Images | Test Images | Total |
|---|---|---|---|
| REVIDE | 3310 | 194 | 3504 |
| Rain1400 | 3600 | 400 | 4000 |
| Dense Haze | 80 | 30 | 110 |
| Total | 6990 | 624 | 7614 |
Follow these steps to quickly run the Visibility Enhancement System on your machine.
git clone https://github.com/your-username/visibility-enhancement.git
cd visibility-enhancementItβs recommended to use Conda or virtualenv.
conda create -n vis-enhance python=3.9
conda activate vis-enhance
pip install -r requirements.txt
On a single image:
python test_pic.py --input input_images/sample.jpg --output results/output.jpg
On a video file:
python test_video.py --input input_videos/sample.mp4 --output results/output.mp4
Live webcam demo (native resolution):
python test_native_live.py
- PSNR (Peak Signal-to-Noise Ratio) - 28.09
- SSIM (Structural Similarity Index) - 0.78
Tested on the SOTS indoor dataset.
Python 3.9+
PyTorch
OpenCV
CUDA/cuDNN
Extending to fog, snow, and low-light scenarios
Developing a lightweight version for mobile & edge devices
ROS integration for autonomous systems
Exploring transformers and diffusion-based approaches
This work is built upon the excellent open-source implementation of CycleGAN and Pix2Pix provided by junyanz/pytorch-CycleGAN-and-pix2pix.
We sincerely thank the authors for their contributions to the research community.
