C2PNet Project Introduction
Overview
C2PNet, which stands for "Curricular Contrastive Regularization for Physics-aware Single Image Dehazing," is an innovative approach developed by researchers Yu Zheng, Jiahui Zhan, Shengfeng He, Junyu Dong, and Yong Du. This method focuses on enhancing the quality of images by effectively removing haze. The project was presented at the IEEE/CVF Conference on Computer Vision and Pattern Recognition in 2023.
Network Architecture
The C2PNet architecture is designed to tackle the problem of haze in single images through a sophisticated network that incorporates physics-aware principles. The model is built upon PyTorch and leverages CUDA to boost its performance, ensuring that the dehazing process is both efficient and effective.
Installation
To get started with C2PNet, the user should have PyTorch version 1.10.1 and CUDA version 11.4. The installation process involves creating a new conda environment and installing necessary dependencies, ensuring that the system is prepared to run the dehazing tasks:
- Create a conda environment for C2PNet.
conda create -n c2pnet python=3.7.11
conda activate c2pnet
- Install required packages through pip.
pip install torch==1.10.0+cu111 torchvision==0.11.0+cu111 torchaudio==0.10.0 -f https://download.pytorch.org/whl/torch_stable.html
pip install -r requirements.txt
Datasets and Pre-trained Models
Users can access pre-trained models and datasets that are available for download from Google Drive. The directory structure for organizing these resources is specified to ensure seamless integration with the C2PNet framework.
Directory Structure
- Pre-trained models will be in the
trained_models
directory. - Dataset will be in the
data
directory containing subfolders for both indoor and outdoor hazy and clear images.
Preparing Datasets
The training datasets contain a large number of negative samples, a factor that increases their size considerably. While only the ITS
dataset is readily available for download on BaiduNetdisk, users interested in expanding their dataset can utilize the create_lmdb.py
script to generate additional samples. This customization allows for setting the number of negative samples and the inclusion of existing dehazing models.
Data Arrangement
Ensure that the datasets are arranged as follows:
- Train datasets like
ITS.lmdb
should reside underdata/ITS
.
Training and Evaluation
C2PNet allows for detailed training on both ITS
and OTS
datasets, employing various parameters such as crop size, block and GPS count, and learning rate. The users can choose to train the model on different configurations to achieve optimal dehazing results.
Training Commands
-
For the
ITS
dataset:python main.py --crop --crop_size=240 --blocks=19 --gps=3 --bs=2 --lr=0.0001 --trainset='its_train' --testset='its_test' --steps=1000000 --eval_step=5000 --clcrloss --clip
-
For the
OTS
dataset:python main.py --crop --crop_size=240 --blocks=19 --gps=3 --bs=2 --lr=0.0001 --trainset='ots_train' --testset='ots_test' --steps=1500000 --eval_step=5000 --clcrloss --clip
Evaluation
After training, C2PNet can be evaluated using the SOTS-indoor
and SOTS-outdoor
datasets to test its performance. This is done by executing the dehaze.py
script with appropriate arguments:
python dehaze.py -d indoor
python dehaze.py -d outdoor
The project also supports a variety of optional arguments for further customizability, accessible via python dehaze.py -h
.
Conclusion
C2PNet represents a significant advancement in image dehazing, leveraging physics-aware methodologies to improve clarity in both indoor and outdoor environments. By following the detailed setup instructions and utilizing the provided datasets and models, users can effectively implement this cutting-edge technology to achieve superior image quality.