rebeccaeexu / CIT-EC

CNN Injected Transformer for Exposure Correction
MIT License
6 stars 0 forks source link

How can i download the pretrain model #1

Open Liampour opened 2 weeks ago

Liampour commented 2 weeks ago

Is there any link that I can download the pretrained model??

rebeccaeexu commented 1 week ago

Please refer to https://github.com/rebeccaeexu/CIT-EC/blob/main/pretrained_models/Pretrained_model.md for download link.

Liampour commented 1 week ago

Thank you for fast your help and fast reply!! After downloading the file and running the provided testing command another error appeared:

Traceback (most recent call last): File "test.py", line 13, in test_pipeline(root_path) File "/home/username/.pyenv/versions/3.7.17/lib/python3.7/site-packages/basicsr/test.py", line 28, in test_pipeline test_set = build_dataset(dataset_opt) File "/home/username/.pyenv/versions/3.7.17/lib/python3.7/site-packages/basicsr/data/init.py", line 34, in build_dataset dataset = DATASET_REGISTRY.get(dataset_opt['type'])(dataset_opt) File "/home/username/CIT-EC/ec/data/multiexpo_paired_dataset.py", line 26, in init self.paths = multiframe_paired_paths_from_folders([self.lq_folder, self.gt_folder]) File "/home/username/CIT-EC/ec/data/data_util.py", line 15, in multiframe_paired_paths_from_folders lq_paths = list(scandir(lq_folder)) File "/home/username/.pyenv/versions/3.7.17/lib/python3.7/site-packages/basicsr/utils/misc.py", line 74, in _scandir for entry in os.scandir(dir_path): FileNotFoundError: [Errno 2] No such file or directory: 'datasets/MultiExposure_dataset/testing/INPUT_IMAGES_OVER/'

I have tried to provide the full path but the error still appears

/home/username/CIT-EC/datasets/MultiExposure_dataset/testing/expert_a_testing_set/

The directory contains a .jpg file

Liampour commented 1 week ago

If I remove the final / from path name e.g.

/home/username/CIT-EC/datasets/MultiExposure_dataset/testing/expert_a_testing_set

I am getting the following error

Traceback (most recent call last): File "test.py", line 13, in test_pipeline(root_path) File "/home/username/.pyenv/versions/3.7.17/lib/python3.7/site-packages/basicsr/test.py", line 40, in test_pipeline model.validation(test_loader, current_iter=opt['name'], tb_logger=None, save_img=opt['val']['save_img']) File "/home/username/.pyenv/versions/3.7.17/lib/python3.7/site-packages/basicsr/models/base_model.py", line 48, in validation self.nondist_validation(dataloader, current_iter, tb_logger, save_img) File "/home/username/CIT-EC/ec/models/multiexposurecorrection_model.py", line 62, in nondist_validation for idx, val_data in enumerate(dataloader): File "/home/username/.pyenv/versions/3.7.17/lib/python3.7/site-packages/torch/utils/data/dataloader.py", line 517, in next data = self._next_data() File "/home/username/.pyenv/versions/3.7.17/lib/python3.7/site-packages/torch/utils/data/dataloader.py", line 557, in _next_data data = self._dataset_fetcher.fetch(index) # may raise StopIteration File "/home/username/.pyenv/versions/3.7.17/lib/python3.7/site-packages/torch/utils/data/_utils/fetch.py", line 44, in fetch data = [self.dataset[idx] for idx in possibly_batched_index] File "/home/username/.pyenv/versions/3.7.17/lib/python3.7/site-packages/torch/utils/data/_utils/fetch.py", line 44, in data = [self.dataset[idx] for idx in possibly_batched_index] File "/home/username/CIT-EC/ec/data/multiexpo_paired_dataset.py", line 37, in getitem img_bytes = self.file_client.get(gt_path, 'gt') File "/home/username/.pyenv/versions/3.7.17/lib/python3.7/site-packages/basicsr/utils/file_client.py", line 164, in get return self.client.get(filepath) File "/home/username/.pyenv/versions/3.7.17/lib/python3.7/site-packages/basicsr/utils/file_client.py", line 63, in get with open(filepath, 'rb') as f: FileNotFoundError: [Errno 2] No such file or directory: '/home/username/CIT-EC/datasets/MultiExposure_dataset/testing/expert_a_testing_set/.jpg'

Is it anything wrong about my python or torch version? I am using python 3.7 torch 1.8

rebeccaeexu commented 1 week ago

Check the following lines to ensure the correct data reading https://github.com/rebeccaeexu/CIT-EC/blob/7d3af6b1358417e50d417ee914e8cbd23a9dc88a/ec/data/data_util.py#L24

Liampour commented 1 week ago

lq_folder is /home/username/CIT-EC/datasets/MultiExposure_dataset/testing/INPUT_IMAGES_OVER (that is correct) lq_name is photoTest_input.jpg (that is correct) lq_path is /home/username/CIT-EC/datasets/MultiExposure_dataset/testing/INPUT_IMAGES_OVER/photoTest_input.jpg.JPG

the .JPG is not correct

Does the inputted image need to have a name with a specific format?

rebeccaeexu commented 1 week ago

Modify https://github.com/rebeccaeexu/CIT-EC/blob/7d3af6b1358417e50d417ee914e8cbd23a9dc88a/ec/data/data_util.py#L25 lq_path = osp.join(lq_folder, lq_name + '.jpg')

Liampour commented 1 week ago

I did it and a new error appeared. it seems to have stripped the "_input" from the filename and is looking for a new file in the same folder with a different name. The file that is searching for does not exist. There is only one image in the folder (image name: photoTest_input.jpg).

Traceback (most recent call last): File "test.py", line 13, in test_pipeline(root_path) File "/home/username/.pyenv/versions/3.7.17/lib/python3.7/site-packages/basicsr/test.py", line 40, in test_pipeline model.validation(test_loader, current_iter=opt['name'], tb_logger=None, save_img=opt['val']['save_img']) File "/home/username/.pyenv/versions/3.7.17/lib/python3.7/site-packages/basicsr/models/base_model.py", line 48, in validation self.nondist_validation(dataloader, current_iter, tb_logger, save_img) File "/home/username/CIT-EC/ec/models/multiexposurecorrection_model.py", line 62, in nondist_validation for idx, val_data in enumerate(dataloader): File "/home/username/.pyenv/versions/3.7.17/lib/python3.7/site-packages/torch/utils/data/dataloader.py", line 517, in next data = self._next_data() File "/home/username/.pyenv/versions/3.7.17/lib/python3.7/site-packages/torch/utils/data/dataloader.py", line 557, in _next_data data = self._dataset_fetcher.fetch(index) # may raise StopIteration File "/home/username/.pyenv/versions/3.7.17/lib/python3.7/site-packages/torch/utils/data/_utils/fetch.py", line 44, in fetch data = [self.dataset[idx] for idx in possibly_batched_index] File "/home/username/.pyenv/versions/3.7.17/lib/python3.7/site-packages/torch/utils/data/_utils/fetch.py", line 44, in data = [self.dataset[idx] for idx in possibly_batched_index] File "/home/username/CIT-EC/ec/data/multiexpo_paired_dataset.py", line 37, in getitem img_bytes = self.file_client.get(gt_path, 'gt') File "/home/username/.pyenv/versions/3.7.17/lib/python3.7/site-packages/basicsr/utils/file_client.py", line 164, in get return self.client.get(filepath) File "/home/username/.pyenv/versions/3.7.17/lib/python3.7/site-packages/basicsr/utils/file_client.py", line 63, in get with open(filepath, 'rb') as f: FileNotFoundError: [Errno 2] No such file or directory: '/home/username/CIT-EC/datasets/MultiExposure_dataset/testing/expert_a_testing_set/photoTest.jpg'

rebeccaeexu commented 1 week ago

I don't know the format of your file name, you can modify the code mentioned above according to your image name according to your file name. (for example, remove the .rstrip('_') part)

Liampour commented 1 week ago

I used the original code without any modification but I changed the files in expert_a_testing_set and INPUT_IMAGES_OVER and the code executed without any errors. Here is the solution:

in datasets/MultiExposure_dataset/testing/expert_a_testing_set needs to be imported an .jpg file with a specific name format e.g. a2103-dgw_054.jpg in datasets/MultiExposure_dataset/testing/INPUT_IMAGES_OVER needs to be imported 5 .JPG images with a name of a specific form that relates them to each other e.g.
a2103-dgw_054_0.JPG a2103-dgw_054_N1.5.JPG a2103-dgw_054_N1.JPG a2103-dgw_054_P1.5.JPG a2103-dgw_054_P1.JPG

Note: The image names between expert_a_testing_set and INPUT_IMAGES_OVER files are strictly related.

One last question the psnr and ssim results are displayed in terminal but I can't find the path where the resulted new images are saved. Am I missing something? Any suggestions on that?

Edit Answering the Question: The path can be found CIT-EC/ec/data/data_util.py

line 97