Coder Social home page Coder Social logo

caiyuanhao1998 / retinexformer Goto Github PK

View Code? Open in Web Editor NEW
665.0 5.0 58.0 16.34 MB

"Retinexformer: One-stage Retinex-based Transformer for Low-light Image Enhancement" (ICCV 2023) & (NTIRE 2024 Challenge)

Home Page: https://arxiv.org/abs/2303.06705

License: MIT License

Python 99.76% Shell 0.24%
low-light-image-enhancement low-light-vision object-detection nighttime-enhancement image-restoration transformer detection ntire basicsr iccv2023

retinexformer's Introduction

 

arXiv NTIRE zhihu

PWC PWC

PWC PWC

PWC PWC

PWC PWC

PWC

PWC

PWC

PWC

PWC

PWC

Introduction

This is a baseline and toolbox for wide-range low-light image enhancement. This repo supports over 15 benchmarks and extremely high-resolution (up to 4000x6000) low-light enhancement. Our method Retinexformer won the second place in the NTIRE 2024 Challenge on Low Light Enhancement. If you find this repo useful, please give it a star ⭐ and consider citing our paper in your research. Thank you.

Awards

News

  • 2024.07.03 : We share more results of compared baseline methods to help your research. Feel free to download them from Google Drive or Baidu Disk 😄
  • 2024.07.01 : An enhanced version of Retinexformer has been accepted by ECCV 2024. Code will be released. Stay tuned. 🚀
  • 2024.05.12 : RetinexMamba based on our Retinexformer framework and this repo has been released. The first Mamba work on low-light enhancement. Thanks to the efforts of the authors.
  • 2024.03.22 : We release distributed data parallel (DDP) and mix-precision training strategies to help you train larger models. We release self-ensemble testing strategy to help you derive better results. In addition, we also release an adaptive split-and-test testing strategy for high-resolution up to 4000x6000 low-light image enhancement. Feel free to use them. 🚀
  • 2024.03.21 : Our methods Retinexformer and MST++ (NTIRE 2022 Spectral Reconstruction Challenge Winner) ranked top-2 in the NTIRE 2024 Challenge on Low Light Enhancement. Code, pre-trained weights, training logs, and enhancement results have been released in this repo. Feel free to use them! 🚀
  • 2024.02.15 : NTIRE 2024 Challenge on Low Light Enhancement begins. Welcome to use our Retinexformer or MST++ (NTIRE 2022 Spectral Reconstruction Challenge Winner) to participate in this challenge! 🏆
  • 2023.11.03 : The test setting of KinD, LLFlow, and recent diffusion models and the corresponding results on LOL are provided. Please note that we do not suggest this test setting because it uses the mean of the ground truth to obtain better results. But, if you want to follow KinD, LLFlow, and recent diffusion-based works for fair comparison, it is your choice to use this test setting. Please refer to the Testing part for details.
  • 2023.11.02 : Retinexformer is added to the Awesome-Transformer-Attention collection. 💫
  • 2023.10.20 : Params and FLOPS evaluating function is provided. Feel free to check and use it.
  • 2023.10.12 : Retinexformer is added to the ICCV-2023-paper collection. 🚀
  • 2023.10.10 : Retinexformer is added to the low-level-vision-paper-record collection. ⭐
  • 2023.10.06 : Retinexformer is added to the awesome-low-light-image-enhancement collection. 🎉
  • 2023.09.20 : Some results on ExDark nighttime object detection are released.
  • 2023.09.20 : Code, models, results, and training logs have been released. Feel free to use them. ⭐
  • 2023.07.14 : Our paper has been accepted by ICCV 2023. Code and Models will be released. 🚀

Results

  • Results on LOL-v1, LOL-v2-real, LOL-v2-synthetic, SID, SMID, SDSD-in, SDSD-out, and MIT Adobe FiveK datasets can be downloaded from Baidu Disk (code: cyh2) or Google Drive

  • Results on LOL-v1, LOL-v2-real, and LOL-v2-synthetic datasets with the same test setting as KinD, LLFlow, and recent diffusion models can be downloaded from Baidu Disk (code: cyh2) or Google Drive.

  • Results on the NTIRE 2024 low-light enhancement dataset can be downloaded from Baidu Disk (code: cyh2) or Google Drive

  • Results on LIME, NPE, MEF, DICM, and VV datasets can be downloaded from Baidu Disk (code: cyh2) or Google Drive

  • Results on ExDark nighttime object detection can be downloaded from Baidu Disk (code: cyh2) or Google Drive. Please use this repo to run experiments on the ExDark dataset

  • Results of some compared baseline methods are shared on Google Drive and Baidu Disk

Performance on LOL-v1, LOL-v2-real, LOL-v2-synthetic, SID, SMID, SDSD-in, and SDSD-out:

results1

Performance on LOL with the same test setting as KinD, LLFlow, and diffusion models:
Metric LOL-v1 LOL-v2-real LOL-v2-synthetic
PSNR 27.18 27.71 29.04
SSIM 0.850 0.856 0.939

Please note that we do not suggest this test setting because it uses the mean of the ground truth to obtain better results. But, if you want to follow KinD, LLFlow, and recent diffusion-based works, it is your choice to use this test setting. Please refer to the Testing part for details.

Performance on NTIRE 2024 test-challenge:
Method Retinexformer MST++ Ensemble
PSNR 24.61 24.59 25.30
SSIM 0.85 0.85 0.85

Feel free to check the Codalab leaderboard. Our method ranks second.

results_ntire

Performance on MIT Adobe FiveK:

results2

Performance on LIME, NPE, MEF, DICM, and VV:

results3

Performance on ExDark Nighttime object detection:

results4

Gallery

NTIRE - dev - 2000x3000 NTIRE - challenge - 4000x6000

 

1. Create Environment

We suggest you use pytorch 1.11 to re-implement the results in our ICCV 2023 paper and pytorch 2 to re-implement the results in NTIRE 2024 Challenge because pytorch 2 can save more memory in mix-precision training.

1.1 Install the environment with Pytorch 1.11

  • Make Conda Environment
conda create -n Retinexformer python=3.7
conda activate Retinexformer
  • Install Dependencies
conda install pytorch=1.11 torchvision cudatoolkit=11.3 -c pytorch

pip install matplotlib scikit-learn scikit-image opencv-python yacs joblib natsort h5py tqdm tensorboard

pip install einops gdown addict future lmdb numpy pyyaml requests scipy yapf lpips
  • Install BasicSR
python setup.py develop --no_cuda_ext

1.2 Install the environment with Pytorch 2

  • Make Conda Environment
conda create -n torch2 python=3.9 -y
conda activate torch2
  • Install Dependencies
conda install pytorch torchvision torchaudio pytorch-cuda=11.8 -c pytorch -c nvidia

pip install matplotlib scikit-learn scikit-image opencv-python yacs joblib natsort h5py tqdm tensorboard

pip install einops gdown addict future lmdb numpy pyyaml requests scipy yapf lpips thop timm
  • Install BasicSR
python setup.py develop --no_cuda_ext

 

2. Prepare Dataset

Download the following datasets:

LOL-v1 Baidu Disk (code: cyh2), Google Drive

LOL-v2 Baidu Disk (code: cyh2), Google Drive

SID Baidu Disk (code: gplv), Google Drive

SMID Baidu Disk (code: btux), Google Drive

SDSD-indoor Baidu Disk (code: jo1v), Google Drive

SDSD-outdoor Baidu Disk (code: uibk), Google Drive

MIT-Adobe FiveK Baidu Disk (code:cyh2), Google Drive, Official

NTIRE 2024 Baidu Disk (code:cyh2), Google Drive links for training input, training GT, and mini-val set.

Note:

(1) Please use bandizip to jointly unzip the .zip and .z01 files of SMID, SDSD-indoor, and SDSD-outdoor

(2) Please process the raw images of the MIT Adobe FiveK dataset following the sRGB output mode or directly download and use the sRGB image pairs processed by us in the Baidu Disk (code:cyh2) and Google Drive

(3) Please download the text_list.txt from Google Drive or Baidu Disk (code: ggbh) and then put it into the folder data/SMID/SMID_Long_np/

Then organize these datasets as follows:
    |--data   
    |    |--LOLv1
    |    |    |--Train
    |    |    |    |--input
    |    |    |    |    |--100.png
    |    |    |    |    |--101.png
    |    |    |    |     ...
    |    |    |    |--target
    |    |    |    |    |--100.png
    |    |    |    |    |--101.png
    |    |    |    |     ...
    |    |    |--Test
    |    |    |    |--input
    |    |    |    |    |--111.png
    |    |    |    |    |--146.png
    |    |    |    |     ...
    |    |    |    |--target
    |    |    |    |    |--111.png
    |    |    |    |    |--146.png
    |    |    |    |     ...
    |    |--LOLv2
    |    |    |--Real_captured
    |    |    |    |--Train
    |    |    |    |    |--Low
    |    |    |    |    |    |--00001.png
    |    |    |    |    |    |--00002.png
    |    |    |    |    |     ...
    |    |    |    |    |--Normal
    |    |    |    |    |    |--00001.png
    |    |    |    |    |    |--00002.png
    |    |    |    |    |     ...
    |    |    |    |--Test
    |    |    |    |    |--Low
    |    |    |    |    |    |--00690.png
    |    |    |    |    |    |--00691.png
    |    |    |    |    |     ...
    |    |    |    |    |--Normal
    |    |    |    |    |    |--00690.png
    |    |    |    |    |    |--00691.png
    |    |    |    |    |     ...
    |    |    |--Synthetic
    |    |    |    |--Train
    |    |    |    |    |--Low
    |    |    |    |    |   |--r000da54ft.png
    |    |    |    |    |   |--r02e1abe2t.png
    |    |    |    |    |    ...
    |    |    |    |    |--Normal
    |    |    |    |    |   |--r000da54ft.png
    |    |    |    |    |   |--r02e1abe2t.png
    |    |    |    |    |    ...
    |    |    |    |--Test
    |    |    |    |    |--Low
    |    |    |    |    |   |--r00816405t.png
    |    |    |    |    |   |--r02189767t.png
    |    |    |    |    |    ...
    |    |    |    |    |--Normal
    |    |    |    |    |   |--r00816405t.png
    |    |    |    |    |   |--r02189767t.png
    |    |    |    |    |    ...
    |    |--SDSD
    |    |    |--indoor_static_np
    |    |    |    |--input
    |    |    |    |    |--pair1
    |    |    |    |    |   |--0001.npy
    |    |    |    |    |   |--0002.npy
    |    |    |    |    |    ...
    |    |    |    |    |--pair2
    |    |    |    |    |   |--0001.npy
    |    |    |    |    |   |--0002.npy
    |    |    |    |    |    ...
    |    |    |    |     ...
    |    |    |    |--GT
    |    |    |    |    |--pair1
    |    |    |    |    |   |--0001.npy
    |    |    |    |    |   |--0002.npy
    |    |    |    |    |    ...
    |    |    |    |    |--pair2
    |    |    |    |    |   |--0001.npy
    |    |    |    |    |   |--0002.npy
    |    |    |    |    |    ...
    |    |    |    |     ...
    |    |    |--outdoor_static_np
    |    |    |    |--input
    |    |    |    |    |--MVI_0898
    |    |    |    |    |   |--0001.npy
    |    |    |    |    |   |--0002.npy
    |    |    |    |    |    ...
    |    |    |    |    |--MVI_0918
    |    |    |    |    |   |--0001.npy
    |    |    |    |    |   |--0002.npy
    |    |    |    |    |    ...
    |    |    |    |     ...
    |    |    |    |--GT
    |    |    |    |    |--MVI_0898
    |    |    |    |    |   |--0001.npy
    |    |    |    |    |   |--0002.npy
    |    |    |    |    |    ...
    |    |    |    |    |--MVI_0918
    |    |    |    |    |   |--0001.npy
    |    |    |    |    |   |--0002.npy
    |    |    |    |    |    ...
    |    |    |    |     ...
    |    |--SID
    |    |    |--short_sid2
    |    |    |    |--00001
    |    |    |    |    |--00001_00_0.04s.npy
    |    |    |    |    |--00001_00_0.1s.npy
    |    |    |    |    |--00001_01_0.04s.npy
    |    |    |    |    |--00001_01_0.1s.npy
    |    |    |    |     ...
    |    |    |    |--00002
    |    |    |    |    |--00002_00_0.04s.npy
    |    |    |    |    |--00002_00_0.1s.npy
    |    |    |    |    |--00002_01_0.04s.npy
    |    |    |    |    |--00002_01_0.1s.npy
    |    |    |    |     ...
    |    |    |     ...
    |    |    |--long_sid2
    |    |    |    |--00001
    |    |    |    |    |--00001_00_0.04s.npy
    |    |    |    |    |--00001_00_0.1s.npy
    |    |    |    |    |--00001_01_0.04s.npy
    |    |    |    |    |--00001_01_0.1s.npy
    |    |    |    |     ...
    |    |    |    |--00002
    |    |    |    |    |--00002_00_0.04s.npy
    |    |    |    |    |--00002_00_0.1s.npy
    |    |    |    |    |--00002_01_0.04s.npy
    |    |    |    |    |--00002_01_0.1s.npy
    |    |    |    |     ...
    |    |    |     ...
    |    |--SMID
    |    |    |--SMID_LQ_np
    |    |    |    |--0001
    |    |    |    |    |--0001.npy
    |    |    |    |    |--0002.npy
    |    |    |    |     ...
    |    |    |    |--0002
    |    |    |    |    |--0001.npy
    |    |    |    |    |--0002.npy
    |    |    |    |     ...
    |    |    |     ...
    |    |    |--SMID_Long_np
    |    |    |    |--text_list.txt
    |    |    |    |--0001
    |    |    |    |    |--0001.npy
    |    |    |    |    |--0002.npy
    |    |    |    |     ...
    |    |    |    |--0002
    |    |    |    |    |--0001.npy
    |    |    |    |    |--0002.npy
    |    |    |    |     ...
    |    |    |     ...
    |    |--FiveK
    |    |    |--train
    |    |    |    |--input
    |    |    |    |    |--a0099-kme_264.jpg
    |    |    |    |    |--a0101-kme_610.jpg
    |    |    |    |     ...
    |    |    |    |--target
    |    |    |    |    |--a0099-kme_264.jpg
    |    |    |    |    |--a0101-kme_610.jpg
    |    |    |    |     ...
    |    |    |--test
    |    |    |    |--input
    |    |    |    |    |--a4574-DSC_0038.jpg
    |    |    |    |    |--a4576-DSC_0217.jpg
    |    |    |    |     ...
    |    |    |    |--target
    |    |    |    |    |--a4574-DSC_0038.jpg
    |    |    |    |    |--a4576-DSC_0217.jpg
    |    |    |    |     ...
    |    |--NTIRE
    |    |    |--train
    |    |    |    |--input
    |    |    |    |    |--1.png
    |    |    |    |    |--3.png
    |    |    |    |     ...
    |    |    |    |--target
    |    |    |    |    |--1.png
    |    |    |    |    |--3.png
    |    |    |    |     ...
    |    |    |--minival
    |    |    |    |--input
    |    |    |    |    |--1.png
    |    |    |    |    |--31.png
    |    |    |    |     ...
    |    |    |    |--target
    |    |    |    |    |--1.png
    |    |    |    |    |--31.png
    |    |    |    |     ...

We also provide download links for LIME, NPE, MEF, DICM, and VV datasets that have no ground truth:

Baidu Disk (code: cyh2) or Google Drive

 

3. Testing

Download our models from Baidu Disk (code: cyh2) or Google Drive. Put them in folder pretrained_weights

# activate the environment
conda activate Retinexformer

# LOL-v1
python3 Enhancement/test_from_dataset.py --opt Options/RetinexFormer_LOL_v1.yml --weights pretrained_weights/LOL_v1.pth --dataset LOL_v1

# LOL-v2-real
python3 Enhancement/test_from_dataset.py --opt Options/RetinexFormer_LOL_v2_real.yml --weights pretrained_weights/LOL_v2_real.pth --dataset LOL_v2_real

# LOL-v2-synthetic
python3 Enhancement/test_from_dataset.py --opt Options/RetinexFormer_LOL_v2_synthetic.yml --weights pretrained_weights/LOL_v2_synthetic.pth --dataset LOL_v2_synthetic

# SID
python3 Enhancement/test_from_dataset.py --opt Options/RetinexFormer_SID.yml --weights pretrained_weights/SID.pth --dataset SID

# SMID
python3 Enhancement/test_from_dataset.py --opt Options/RetinexFormer_SMID.yml --weights pretrained_weights/SMID.pth --dataset SMID

# SDSD-indoor
python3 Enhancement/test_from_dataset.py --opt Options/RetinexFormer_SDSD_indoor.yml --weights pretrained_weights/SDSD_indoor.pth --dataset SDSD_indoor

# SDSD-outdoor
python3 Enhancement/test_from_dataset.py --opt Options/RetinexFormer_SDSD_outdoor.yml --weights pretrained_weights/SDSD_outdoor.pth --dataset SDSD_outdoor

# FiveK
python3 Enhancement/test_from_dataset.py --opt Options/RetinexFormer_FiveK.yml --weights pretrained_weights/FiveK.pth --dataset FiveK

# NTIRE
python3 Enhancement/test_from_dataset.py --opt Options/RetinexFormer_NTIRE.yml --weights pretrained_weights/NTIRE.pth --dataset NTIRE --self_ensemble

# MST_Plus_Plus trained with 4 GPUs on NTIRE 
python3 Enhancement/test_from_dataset.py --opt Options/MST_Plus_Plus_NTIRE_4x1800.yml --weights pretrained_weights/MST_Plus_Plus_4x1800.pth --dataset NTIRE --self_ensemble

# MST_Plus_Plus trained with 8 GPUs on NTIRE 
python3 Enhancement/test_from_dataset.py --opt Options/MST_Plus_Plus_NTIRE_8x1150.yml --weights pretrained_weights/MST_Plus_Plus_8x1150.pth --dataset NTIRE --self_ensemble
  • Self-ensemble testing strategy

We add the self-ensemble strategy in the testing code to derive better results. Just add a --self_ensemble action at the end of the above test command to use it.

  • The same test setting as LLFlow, KinD, and recent diffusion models

We provide the same test setting as LLFlow, KinD, and recent diffusion models. Please note that we do not suggest this test setting because it uses the mean of ground truth to enhance the output of the model. But if you want to follow this test setting, just add a --GT_mean action at the end of the above test command as

# LOL-v1
python3 Enhancement/test_from_dataset.py --opt Options/RetinexFormer_LOL_v1.yml --weights pretrained_weights/LOL_v1.pth --dataset LOL_v1 --GT_mean

# LOL-v2-real
python3 Enhancement/test_from_dataset.py --opt Options/RetinexFormer_LOL_v2_real.yml --weights pretrained_weights/LOL_v2_real.pth --dataset LOL_v2_real --GT_mean

# LOL-v2-synthetic
python3 Enhancement/test_from_dataset.py --opt Options/RetinexFormer_LOL_v2_synthetic.yml --weights pretrained_weights/LOL_v2_synthetic.pth --dataset LOL_v2_synthetic --GT_mean
  • Evaluating the Params and FLOPS of models

We have provided a function my_summary() in Enhancement/utils.py, please use this function to evaluate the parameters and computational complexity of the models, especially the Transformers as

from utils import my_summary
my_summary(RetinexFormer(), 256, 256, 3, 1)

 

4. Training

Feel free to check our training logs from Baidu Disk (code: cyh2) or Google Drive

We suggest you use the environment with pytorch 2 to train our model on the NTIRE 2024 dataset and the environment with pytorch 1.11 to train our model on other datasets.

# activate the enviroment
conda activate Retinexformer

# LOL-v1
python3 basicsr/train.py --opt Options/RetinexFormer_LOL_v1.yml

# LOL-v2-real
python3 basicsr/train.py --opt Options/RetinexFormer_LOL_v2_real.yml

# LOL-v2-synthetic
python3 basicsr/train.py --opt Options/RetinexFormer_LOL_v2_synthetic.yml

# SID
python3 basicsr/train.py --opt Options/RetinexFormer_SID.yml

# SMID
python3 basicsr/train.py --opt Options/RetinexFormer_SMID.yml

# SDSD-indoor
python3 basicsr/train.py --opt Options/RetinexFormer_SDSD_indoor.yml

# SDSD-outdoor
python3 basicsr/train.py --opt Options/RetinexFormer_SDSD_outdoor.yml

# FiveK
python3 basicsr/train.py --opt Options/RetinexFormer_FiveK.yml

Train our Retinexformer and MST++ with the distributed data parallel (DDP) strategy of pytorch on the NTIRE 2024 Low-Light Enhancement dataset. Please note that we use the mix-precision strategy in the training process, which is controlled by the bool hyperparameter use_amp in the config file.

# activate the enviroment
conda activate torch2

# Train Retinexformer with 8 GPUs on NTIRE
bash train_multigpu.sh Options/RetinexFormer_NTIRE_8x2000.yml 0,1,2,3,4,5,6,7 4321

# Train MST++ with 4 GPUs on NTIRE
bash train_multigpu.sh Options/RetinexFormer_NTIRE_4x1800.yml 0,1,2,3,4,5,6,7 4329

# Train MST++ with 8 GPUs on NTIRE
bash train_multigpu.sh Options/MST_Plus_Plus_NTIRE_8x1150.yml 0,1,2,3,4,5,6,7 4343

 

5. Citation

@InProceedings{Cai_2023_ICCV,
    author    = {Cai, Yuanhao and Bian, Hao and Lin, Jing and Wang, Haoqian and Timofte, Radu and Zhang, Yulun},
    title     = {Retinexformer: One-stage Retinex-based Transformer for Low-light Image Enhancement},
    booktitle = {Proceedings of the IEEE/CVF International Conference on Computer Vision (ICCV)},
    month     = {October},
    year      = {2023},
    pages     = {12504-12513}
}

@inproceedings{retinexformer,
  title={Retinexformer: One-stage Retinex-based Transformer for Low-light Image Enhancement},
  author={Yuanhao Cai and Hao Bian and Jing Lin and Haoqian Wang and Radu Timofte and Yulun Zhang},
  booktitle={ICCV},
  year={2023}
}


# MST++
@inproceedings{mst,
  title={Mask-guided Spectral-wise Transformer for Efficient Hyperspectral Image Reconstruction},
  author={Yuanhao Cai and Jing Lin and Xiaowan Hu and Haoqian Wang and Xin Yuan and Yulun Zhang and Radu Timofte and Luc Van Gool},
  booktitle={CVPR},
  year={2022}
}

retinexformer's People

Contributors

bianhao123 avatar caiyuanhao1998 avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar

retinexformer's Issues

he results I trained are much lower than the actual results in the paper.

Hello, I have two questions. The first is: the results I trained are much lower than the actual results in the paper. Would the author please share a pre-trained model that has been well trained? What is your training equipment and environment, and what is the software version?The second is: in the paper, you said iterations were 250,000, but why is total_iter: 150,000 in the code?

the test_list.txt for SDSD dataset

Thank u for your work. I am very interested in it. I want to know how u choose the test dataset. Can I get the test_list.txt for SDSD dataset? Thank u very much.

How to generate images of experimental results?

Hi! I recently read your article and think it is an excellent work! I trained the model with your code and measured SSIM using test_from_dataset.py, but I don't know how to generate images of experimental results?Thank you~

About kernel_size in Illumination_Estimator module.

As mentioned in your paper, sec3.1, "a depth-wise separable conv 9x9 is adopted to model the interactions of regions with different lighting conditions to generate the light-up feature F_{lu}". However, in "basicsr/model/archs/RetinexFormer_arch.py", class Illumination_Estimator, the kernel_size of "self.depth_conv" is set to 5.

I am curious about this difference.

Thank you !

about ssim

Dear author:
In train.py, I see that psnr is used when verifying the dataset and the best psnr model is saved, but when judging whether it is the optimal model, I do not see the ssim. Is it the best psnr model saved and the ssim tested with the best psnr model.
I would appreciate a reply from the author.

Related code:
if best_metric['psnr'] < current_metric:
best_metric['psnr'] = current_metric
best_metric['iter'] = current_iter
model.save_best(best_metric)

code about illumination estimator

In the illumination estimator, the paper mentions that 1×1 convolution is followed by 9×9 convolution, but the convolution kernel of the next convolution after 1×1 convolution is set to 5×5 in the code. May I ask what the correct convolution kernel is set to

object detection

Thank for your open source.How to train Retinexformer based detector in your paper.

关于SID数据集使用问题

尊敬的作者:
您好,我看到代码RetinexFormer_SID.yml 中datasets 目录格式是这样子 dataroot_gt: data/SID/long_sid2,但是给出的SID数据集网盘都是一个文件夹一个文件夹(10003、10006),请问数据集应该怎么使用呢?

visual results of other methods

Thanks for your great work!

Could please share the visual results of other methods (such as Restormer, MIRNet, KinD) trained on corresponding datasets? A lot of methods did not provide pretrain weights on various datasets (such as lolv2real, lolv2synthetic, MIT Adobe FiveK). So it is time-comsuming to train their models from the scratch. It would be great if you are willing to share these visual results or pretrained weights.

Thanks anyway.

数据集问题

请问对没有gt的exdark数据集进行增强时,.yml文件路径应该如何更改呢?
QQ图片20231129112508

Far below scores recorded in the paper

Hi!

Thanks for sharing the code.
I used the following command to train LoLv1 dataset according to the readme file:
python3 basicsr/train.py --opt Options/RetinexFormer_LOL_v1.yml

After 7-hour training, the best psnr was 22.41, which is not as good as the score recorded in the paper (around 25)

Is there anything I should do to preprocess the dataset or something else?
Or could you please use the repo to retrain the LoL dataset to verify this problem?
Thanks a lot.

the number of the IGAB blocks used in upsampling branch

Hi! I recently read the article and really appreciate your work.
But I noticed that in your article Figure2(a), there are two IGAB blocks in the last step of upsampling branch when you get the F_0', but in your code, you only have one IGAB block. Can you please clarify this for me? Is there some mistake in the Figure2(a)?

Question for training the model

Hello! First of all, I really appreciate your codes for your works.
However I encountered hardness in reproducing performances of the model by training it. Can you help me what I missed?? I trained your model with LOLv1 but could get psnr 23.9 and ssim 0.829.

复现问题

# create model
model = create_model(opt)

for test_loader in test_loaders:
    test_set_name = test_loader.dataset.opt['name']
    logger.info(f'Testing {test_set_name}...')
    rgb2bgr = opt['val'].get('rgb2bgr', True)
    # wheather use uint8 image to compute metrics
    use_image = opt['val'].get('use_image', True)
    model.validation(
        test_loader,
        current_iter=opt['name'],
        tb_logger=None,
        save_img=opt['val']['save_img'],
        rgb2bgr=rgb2bgr, use_image=use_

你好作者,麻烦您告诉一下想知道model = create_model(opt)是从那条路径来的,我们如何通过这句话找到训练好的模型进行测试

模型

您好!麻烦问下您,在训练的时候,选用的模型是basicsr.models.archs.RetinexFormer_arch当中的RetinexFormer
还是别的模型

你好,我这有一些小问题想询问下

首先非常感谢您的工作和开源代码,我目前已经复现了LOL_v1和LOL_v2两个,但是我目前有些疑问,我现在想将它使用到自定义数据集当中,但是我没有常规和阴暗两分类的数据,只有一份常规图像。我能否直接使用测试来对自定义数据集的图像进行亮度增强,我自己尝试了一些方法但是没成功,希望大佬帮帮忙,谢谢!

Ask about dataset about sid

I would like to ask about the data set SID, gtsize is defined as 256, but the read Dataset is [512,960] and gt_sizes is 256. Is the input gt_sizes defined in this way invalid? The size of the input network is 512,960. This is for a single block. Is the GPU taxing too much? Or the picture has been scaled somewhere in the code, and I hope the author will point it out. Thanks~

关于SDSD数据集如何测试

嗨!感谢您工作的分享。我在使用sdsd数据集测试时候遇到了一些问题:在使用sdsd_indoor.yml训练得到模型后,我放置了sdsd_indoor.yml中dataroot_gt和dataroot_lq使用的两个路径在test_from_dataset.py中用于测试,但得到了报错“AssertionError: Different number of images in LQ and GT folders”。所以想请问一下您,在test_from_dataset.py中使用SDSD数据集测试时候,如何放置input_dir和result_dir的路径对模型进行测试呢?谢谢~

咨询下训练问题

您好,按照您的步骤配置的环境和代码train后达不到您的效果,是不是还应该进行调试其他一些参数?您方便跟我说下吗?谢谢。我train的psnr只能达到22.89

检测

1
请问如何得到这样的检测结果?我按照IAT的代码进行检测后图片还是低光照未增强的。
图片2

The implementation of IG-MSA is different from the diagram in the paper.

In the released code, this module is implemented as spatial self-attention, but in fact as we can see from the diagram, this is actually channel self-attention.

illu_attn = illu_fea_trans # illu_fea: b,c,h,w -> b,h,w,c
q, k, v, illu_attn = map(lambda t: rearrange(t, 'b n (h d) -> b h n d', h=self.num_heads),
(q_inp, k_inp, v_inp, illu_attn.flatten(1, 2)))
v = v * illu_attn
# q: b,heads,hw,c
q = q.transpose(-2, -1)
k = k.transpose(-2, -1)
v = v.transpose(-2, -1)
q = F.normalize(q, dim=-1, p=2)
k = F.normalize(k, dim=-1, p=2)
attn = (k @ q.transpose(-2, -1)) # A = K^T*Q
attn = attn * self.rescale
attn = attn.softmax(dim=-1)
x = attn @ v # b,heads,d,hw

image

测试问题

(chao) root@csim:~/home/lichaoyue/Retinexformer-master/basicsr# /root/anaconda3/envs/chao/bin/python /root/home/lichaoyue/Retinexformer-master/Enhancement/test_from_dataset.py
export CUDA_VISIBLE_DEVICES=0
dataset LOL_v1
Traceback (most recent call last):
File "/root/home/lichaoyue/Retinexformer-master/Enhancement/test_from_dataset.py", line 78, in
model_restoration.load_state_dict(checkpoint['params'])
File "/root/anaconda3/envs/chao/lib/python3.7/site-packages/torch/nn/modules/module.py", line 1672, in load_state_dict
self.class.name, "\n\t".join(error_msgs)))
RuntimeError: Error(s) in loading state_dict for RetinexFormer:
Missing key(s) in state_dict: "body.0.estimator.channel_attention1.fc.0.weight", "body.0.estimator.channel_attention1.fc.0.bias", "body.0.estimator.channel_attention1.fc.2.weight", "body.0.estimator.channel_attention1.fc.2.bias", "body.0.estimator.channel_attention2.fc.0.weight", "body.0.estimator.channel_attention2.fc.0.bias", "body.0.estimator.channel_attention2.fc.2.weight", "body.0.estimator.channel_attention2.fc.2.bias".

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
File "/root/home/lichaoyue/Retinexformer-master/Enhancement/test_from_dataset.py", line 83, in
model_restoration.load_state_dict(new_checkpoint)
File "/root/anaconda3/envs/chao/lib/python3.7/site-packages/torch/nn/modules/module.py", line 1672, in load_state_dict
self.class.name, "\n\t".join(error_msgs)))
RuntimeError: Error(s) in loading state_dict for RetinexFormer:
Missing key(s) in state_dict: "body.0.estimator.conv1.weight", "body.0.estimator.conv1.bias",
作者您好 很感谢您提供的代码 但我在测试中出现了这种原因 不知道怎么修改 也不清楚哪里出现错误了

关于EXDARK图像增强

你好作者,能否开源一下关于exdark图像增强的配置代码及训练模型。我这边对比实验需要exdark增强后的结果,如果可以的话后期会在我们的工作里面对你们的进行引用。

SID从raw图到npy的处理

您好!想请教下SID文件从raw图到npy文件这个过程您做了哪些处理呢?我看您公开的代码里似乎没有这部分,想学习一下这个转换。

无GT数据的测试问题

您好,首先非常感谢您有意义的工作!我有几个问题想请教一下:

  1. 请问LIME, NPE, MEF, DICM, 和VV这几个没有GT数据集的增强结果是使用哪个预训练参数预测得到的?
  2. repo中是否有提供在自定义数据上直接进行测试的代码?
  3. 如果在自己的数据上进行直接增强,推荐使用哪个预训练参数?
  4. 按照您提供的tutorial,在ExDark上的训练需要使用IAT-Yolo的repo,我看了下貌似没有将Retinexformer集成进去,需要自定义添加对吗?
    期待您的回复,非常感谢!

exdark检测

感谢您的共工作,请问如何将该网络作为预处理模块加入yolov3进行低光照检测,是否能提供代码?

RuntimeWarning: Mean of empty slice.

export CUDA_VISIBLE_DEVICES=0
dataset LOL_v1
===>Testing using weights: /home/cy/Retinexformer/Retinexformer-master/pretrained_weights/pretrain_model/LOL_v1.pth
data/LOLv1/Test/input
data/LOLv1/Test/target
0it [00:00, ?it/s]
/home/cy/anaconda3/envs/Retinexformer/lib/python3.7/site-packages/numpy/core/fromnumeric.py:3441: RuntimeWarning: Mean of empty slice.
out=out, **kwargs)
/home/cy/anaconda3/envs/Retinexformer/lib/python3.7/site-packages/numpy/core/_methods.py:189: RuntimeWarning: invalid value encountered in double_scalars
ret = ret.dtype.type(ret / rcount)
PSNR: nan
SSIM: nan

So,what should i do?thank you

about use 'SMID.pth'

Thank you very much for your work. I am very interested in it,When I'm trying to use pretrained models about 'SMID.pth',I always can't get the SMID/test_list.txt,How should I get such a file,So I would like to request your help!Thank you!

LR Schedule

Hello,

thanks for this nice work!

I have a question regarding the LR schedule. I've noticed differences between the descriptions outlined in the paper and the settings in the actual configuration file (specifically for RetinexFormer on the LoLv2-real dataset). You are also using larger crops than for the other datasets. Could you kindly provide some insight into the reasoning behind these differences?

Best,
Eduard

端到端训练

请问我能将Retinexformer放到yolo的第一层进行一个端到端的训练吗

关于消融实验

您好,想请问请问一下消融实验部分表4(a)中的Baseline-1具体成分是啥呢?希望被关注到这个问题,请回复一下,谢谢您!

关于SDSD-indoor数据集划分的问题

首先,非常感谢您的工作与分享。

我通过您的代码,尝试对SDSD-indoor数据集进行划分,得到训练集图片:测试集图片=1655:308,我看您在论文中提到是62:6。

我的划分方法是将pair1、pair4、pair9、pair11、pair19、pair21以及他们的_2文件夹共12个文件夹划分测试集。

我想了解的是,我对SDSD数据集读取代码的理解是否存在问题?

非常感谢与期待您的回复。

256\times256 about sid datasets

Thank you for your reply. I have already stared your amazing work. But I checked all the codes and didn't find that it was cropped to 256*256 during the training phase. Can you tell me which module this operation occurs in?

Missing key(s) in state_dict: "body.0.estimator.conv1.weight",

when test ,it occur that Missing key(s) in state_dict: "body.0.estimator.conv1.weight",
RuntimeError: Error(s) in loading state_dict for RetinexFormer:
Missing key(s) in state_dict: "body.0.estimator.conv1.weight", "body.0.estimator.conv1.bias", "body.0.estimator.depth_conv.weight", "body.0.estimator.depth_conv.bias", "body.0.estimator.conv2.weight", "body.0.estimator.conv2.bias", "body.0.denoiser.embedding.weight", "body.0.denoiser.encoder_layers.0.0.blocks.0.0.rescale", "body.0.denoiser.encoder_layers.0.0.blocks.0.0.to_q.weight", "body.0.denoiser.encoder_layers.0.0.blocks.0.0.to_k.weight", "body.0.denoiser.encoder_layers.0.0.blocks.0.0.to_v.weight", "body.0.denoiser.encoder_layers.0.0.blocks.0.0.proj.weight", "body.0.denoiser.encoder_layers.0.0.blocks.0.0.proj.bias", "body.0.denoiser.encoder_layers.0.0.blocks.0.0.pos_emb.0.weight", "body.0.denoiser.encoder_layers.0.0.blocks.0.0.pos_emb.2.weight", "body.0.denoiser.encoder_layers.0.0.blocks.0.1.fn.net.0.weight", "body.0.denoiser.encoder_layers.0.0.blocks.0.1.fn.net.2.weight", "body.0.denoiser.encoder_layers.0.0.blocks.0.1.fn.net.4.weight", "body.0.denoiser.encoder_layers.0.0.blocks.0.1.norm.weight", "body.0.denoiser.encoder_layers.0.0.blocks.0.1.norm.bias", "body.0.denoiser.encoder_layers.0.1.weight", "body.0.denoiser.encoder_layers.0.2.weight", "body.0.denoiser.encoder_layers.1.0.blocks.0.0.rescale", "body.0.denoiser.encoder_layers.1.0.blocks.0.0.to_q.weight", "body.0.denoiser.encoder_layers.1.0.blocks.0.0.to_k.weight", "body.0.denoiser.encoder_layers.1.0.blocks.0.0.to_v.weight", "body.0.denoiser.encoder_layers.1.0.blocks.0.0.proj.weight", "body.0.denoiser.encoder_layers.1.0.blocks.0.0.proj.bias", "body.0.denoiser.encoder_layers.1.0.blocks.0.0

我想向您了解一下use GT mean具体代表什么吗

2023.11.03 : The test setting of KinD, LLFlow, and recent diffusion models and the corresponding results on LOL are provided. Please note that we do not suggest this test setting because it uses the mean of the ground truth to obtain better results. But, if you want to follow KinD, LLFlow, and recent diffusion-based works for fair comparison, it is your choice to use this test setting. Please refer to the Testing part for details.
这里提到了使用相同的测试方式,我想问下这个具体的测试方式是指什么,有些不太理解

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.