🚀 Paper | 🏠 Project Page | 🎬 Video | 🤗 Demo
- [2025/09/12]: Released interactive demo on Hugging Face Spaces.
- [2025/07/02]: Released pre-trained model checkpoints for GCC trained on NUS-8 and Gehler datasets.
- [2025/07/02]: Released pre-processed NUS-8 and Gehler datasets.
- [2025/06/09]: Released training, inference, and evaluation code.
- [2025/03/10]: Our paper has been accepted to CVPR 2025!
Reference: This installation setup is adapted from DiffusionLight.
To setup the Python environment, you need to run the following commands in both Conda and pip:
conda env create -f environment.yml
conda activate diffusionlight
pip install -r requirements.txtWe provide pre-processed datasets ready for immediate use, or you can process raw datasets yourself using our preprocessing pipeline.
Pre-processed datasets are available on Hugging Face:
- NUS-8 Dataset: 🤗 StevenChangWei/nus8-dataset
- Gehler Dataset: 🤗 StevenChangWei/gehler-dataset
huggingface-cli download StevenChangWei/{gehler-dataset,nus8-dataset} \
--repo-type dataset \
--local-dir ./data \
--resume-download \
--max-workers 32If you prefer to process raw datasets yourself, see our detailed preprocessing guide: Data Preprocessing Guide
Fine-tunes Stable Diffusion 2 inpainting model for color constancy tasks.
export MODEL_NAME="stabilityai/stable-diffusion-2-inpainting"
# Cross-dataset setting: train on NUS8 dataset (for later testing on Gehler)
accelerate launch --gpu_ids 0 train.py \
--pretrained_model_name_or_path=$MODEL_NAME \
--resolution=512 \
--train_batch_size=8 \
--gradient_accumulation_steps=2 \
--max_train_steps=20000 \
--learning_rate=5e-05 \
--output_dir="/path/to/output" \
--train_data_dir="/path/to/processed_nus8" \
--cache_dir="/path/to/cache" \
--val_image_folder="/path/to/validation"
--dataset="nus8" \ # Dataset type: "nus8" or "gehler"
--fold='all' \ # Use all available data
# Leave-one-camera-out: train excluding SonyA57, test on SonyA57
accelerate launch --gpu_ids 0 train.py \
[base arguments...] \
--camera_name='SonyA57' \ # Specific camera to exclude
--fold='exclude' # Exclude the specified camera
# 3-fold cross validation: train on Canon1D folds 1,2, test on fold 0
accelerate launch --gpu_ids 0 train.py \
[base arguments...] \
--camera_name='Canon1D' \ # Specific camera for CV
--fold=0 # Test fold (train on folds 1,2)You can directly use the training scripts provided in the scripts/ folder (modify the paths before running):
bash scripts/train_all_dataset.sh
bash scripts/train_leave_one_out.shEvaluates trained models on preprocessed datasets and calculates angular error statistics.
Pre-trained model checkpoints are available for download:
- GCC trained on NUS-8: 🤗 StevenChangWei/gcc_train_on_nus8
- GCC trained on Gehler: 🤗 StevenChangWei/gcc_train_on_gehler
# Cross-dataset: evaluate NUS8 using model trained on Gehler
python inference.py \
--dataset_type nus8 \ # Target dataset for evaluation
--camera_name all \ # Cross-dataset evaluation
--fold all \ # Use all target dataset
--dataset_dir /path/to/processed_nus8 \
--metadata_path /path/to/processed_nus8/all_cameras_meta.json \
--model_path /path/to/gehler_trained_model \
--color_checker_path /path/to/color_checker.png \
--cache_dir /path/to/cache \
--output_dir /path/to/results \
--batch_size 20
# → Output: eval_nus8_from_gehler.json
# Leave-one-camera-out: evaluate SonyA57 using model trained excluding SonyA57
python inference.py \
--dataset_type nus8 \
--camera_name SonyA57 \ # Camera to evaluate (was excluded in training)
--fold exclude \ # Matches leave-one-camera-out training
--dataset_dir /path/to/processed_nus8 \
--metadata_path /path/to/processed_nus8/all_cameras_meta.json \
--model_path /path/to/nus8_exclude_SonyA57_model \
--color_checker_path /path/to/color_checker.png \
--cache_dir /path/to/cache \
--output_dir /path/to/results \
--batch_size 20
# → Output: nus8_train_exclude_SonyA57_test_SonyA57.json
# 3-fold cross validation: evaluate Canon1D fold 0 using model trained on folds 1,2
python inference.py \
--dataset_type nus8 \ # Dataset to evaluate on
--camera_name SonyA57 \ # Specific camera to evaluate
--fold 0 \ # Test fold (matches training setup)
--dataset_dir /path/to/processed_nus8 \
--metadata_path /path/to/processed_nus8/all_cameras_meta.json \
--model_path /path/to/trained_model \
--color_checker_path /path/to/color_checker.png \
--cache_dir /path/to/cache \
--output_dir /path/to/results \
--batch_size 20
# → Output: nus8_train_fold12_test_fold0_SonyA57.jsonYou can directly use the inference scripts provided in the scripts/ folder (modify the paths before running):
bash scripts/inference_all_dataset.sh
bash scripts/inference_leave_one_out.shCombines results from multiple experiments and calculates comprehensive angular error statistics. Can be used for leave-one-camera-out evaluation, three-fold cross-validation, or analyzing single experiment results.
# Analyze result files in a directory (supports single or multiple JSON files)
python combine.py \
--folder_path /path/to/resultsOutput:
Found 8 JSON files
Successfully processed 1736 images
Mean: 2.15
Median: 1.78
Tri-mean: 1.92
Best 25% (mean): 0.84
Worst 25% (mean): 4.67
@InProceedings{Chang_2025_CVPR,
author = {Chang, Chen-Wei and Fan, Cheng-De and Chang, Chia-Che and Lo, Yi-Chen and Tseng, Yu-Chee and Huang, Jiun-Long and Liu, Yu-Lun},
title = {GCC: Generative Color Constancy via Diffusing a Color Checker},
booktitle = {Proceedings of the Computer Vision and Pattern Recognition Conference (CVPR)},
month = {June},
year = {2025},
pages = {10868-10878}
}