chang810249 / CLCC-CVPR21

An official TensorFlow implementation of “CLCC: Contrastive Learning for Color Constancy” accepted at CVPR 2021.

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

CLCC: Contrastive Learning for Color Constancy (CVPR 2021)

Yi-Chen Lo*, Chia-Che Chang*, Hsuan-Chao Chiu, Yu-Hao Huang, Chia-Ping Chen, Yu-Lin Chang, Kevin Jou

MediaTek Inc., Hsinchu, Taiwan

(*) indicates equal contribution.

We preprocess each fold of dataset and stored in .pkl format for each sample. Each sample contains:

  • Raw image: Mask color checker; Subtract black level; Convert to uint16 [0, 65535] BGR numpy array with shape (H, W, 3).
  • RGB label: L2-normalized numpy vector with shape (3,).
  • Color checker: [0, 4095] BGR numpy array with shape (24, 3) for raw-to-raw mapping presented in our paper (see util/raw2raw.py and also section 4.3 in our paper). A few of them are stored in all zeros due to the failure of color checker detection. Note that we convert it into RGB format during preprocessing in dataloader.py, and our raw-to-raw mapping algorithm also manipulates it in RGB format.

Training and Evaluation

CLCC is a Python 3 & TensorFlow 1.x implementation based on FC4 codebase.

  • Dataset preparation: Download preprocessed dataset here. Please make sure your dataset folder is structured as <DATA_DIR>/<DATA_NAME>/<FOLD_ID> (e.g., data/gehler/0, just like how it is structured in download source).

  • Pretrained weights preparation: Download ImageNet-pretrained weights here. Place pretrained weight files under pretrained_models/imagenet/.

  • Training: Modify config.py (i.e., you may want to rename EXP_NAME and specify training data DATA_NAME, TRAIN_FOLDS, TEST_FOLDS) and execute train.py. Checkpoints will be saved under ckpts/EXP_NAME during training.

  • Evaluation: Once training is done, you can evaluate checkpoint with eval.py on a specific test fold. We recommend to refer to scripts/eval_squeezenet_clcc_gehler.sh for 3-fold cross-validation.

Acknowledgments

Citation

@misc{lo2021clcc,
      title={CLCC: Contrastive Learning for Color Constancy}, 
      author={Yi-Chen Lo and Chia-Che Chang and Hsuan-Chao Chiu and Yu-Hao Huang and Chia-Ping Chen and Yu-Lin Chang and Kevin Jou},
      year={2021},
      eprint={2106.04989},
      archivePrefix={arXiv},
      primaryClass={cs.CV}
}

About

An official TensorFlow implementation of “CLCC: Contrastive Learning for Color Constancy” accepted at CVPR 2021.


Languages

Language:Python 98.5%Language:Shell 1.5%