MayankSingal / PyTorch-Image-Dehazing

PyTorch implementation of some single image dehazing networks.
MIT License
345 stars 61 forks source link

Error while training #6

Open vi1729 opened 4 years ago

vi1729 commented 4 years ago

Hi Mayank,

I created a folder "data" and placed the data and images folder from the google sites. I'm getting below error. Please guide me any corrections.

Total training examples: 24443 Total validation examples: 2813 Traceback (most recent call last): File "train.py", line 104, in train(config) File "train.py", line 43, in train for iteration, (img_orig, img_haze) in enumerate(train_loader): File "C:\Users\aruna\Anaconda3\envs\test\lib\site-packages\torch\utils\data\dataloader.py", line 336, in next return self._process_next_batch(batch) File "C:\Users\aruna\Anaconda3\envs\test\lib\site-packages\torch\utils\data\dataloader.py", line 357, in _process_next_batch raise batch.exc_type(batch.exc_msg) FileNotFoundError: Traceback (most recent call last): File "C:\Users\aruna\Anaconda3\envs\test\lib\site-packages\torch\utils\data\dataloader.py", line 106, in _worker_loop samples = collate_fn([dataset[i] for i in batch_indices]) File "C:\Users\aruna\Anaconda3\envs\test\lib\site-packages\torch\utils\data\dataloader.py", line 106, in samples = collate_fn([dataset[i] for i in batch_indices]) File "C:\Users\aruna\PycharmProjects\PyTorch-Image-Dehazing-master\dataloader.py", line 90, in getitem data_orig = Image.open(data_orig_path) File "C:\Users\aruna\Anaconda3\envs\test\lib\site-packages\PIL\Image.py", line 2766, in open fp = builtins.open(filename, "rb") FileNotFoundError: [Errno 2] No such file or directory: 'data\images\data\data\NYU2_714.jpg'

JiechaoSheng commented 4 years ago

I have received the same problem

Fakerworker commented 4 years ago

I have received the same problem

18119496488 commented 4 years ago

I have received the same problem too

gravity-123 commented 2 years ago

The cause of this error is the line "image_list_haze = glob.glob(hazy_images_path + "*.jpg")" in "dataloader.py". The path obtained by the "glob.glob" function under windows and linux systems is slightly different. The path of the same file in windows system is "data/images/data\NYU2_714.jpg", and the path in linux system is "data/images/data/NYU2_714.jpg". After the above path is sliced by the code "image = image.split("/")[-1]" on line 27, the "image" variable is "data/NYU2_714.jpg". The code can be changed to "image = image.split("\\")[-1]", after the string is sliced, the "image" variable is "NYU2_714.jpg"

phongfire commented 1 year ago

The cause of this error is the line "image_list_haze = glob.glob(hazy_images_path + "*.jpg")" in "dataloader.py". The path obtained by the "glob.glob" function under windows and linux systems is slightly different. The path of the same file in windows system is "data/images/data\NYU2_714.jpg", and the path in linux system is "data/images/data/NYU2_714.jpg". After the above path is sliced by the code "image = image.split("/")[-1]" on line 27, the "image" variable is "data/NYU2_714.jpg". The code can be changed to "image = image.split("\")[-1]", after the string is sliced, the "image" variable is "NYU2_714.jpg"

—————————————————————————————————— Hello,I have received the same problem too, but I run the code on the linux system. And I don't know how to solve this problem. Could you help me? Traceback (most recent call last): File "train.py", line 140, in main(config_args) File "train.py", line 97, in main for step, (ori_image, haze_image) in enumerate(train_loader): File "/root/miniconda3/envs/my-env/lib/python3.7/site-packages/torch/utils/data/dataloader.py", line 681, in next data = self._next_data() File "/root/miniconda3/envs/my-env/lib/python3.7/site-packages/torch/utils/data/dataloader.py", line 721, in _next_data data = self._dataset_fetcher.fetch(index) # may raise StopIteration File "/root/miniconda3/envs/my-env/lib/python3.7/site-packages/torch/utils/data/_utils/fetch.py", line 49, in fetch data = [self.dataset[idx] for idx in possibly_batched_index] File "/root/miniconda3/envs/my-env/lib/python3.7/site-packages/torch/utils/data/_utils/fetch.py", line 49, in data = [self.dataset[idx] for idx in possibly_batched_index] File "/root/autodl-tmp/AOD-Net-PyTorch/data.py", line 27, in getitem ori_image = self.transforms(Image.open(ori_image_name)) File "/root/miniconda3/envs/my-env/lib/python3.7/site-packages/PIL/Image.py", line 3068, in open fp = builtins.open(filename, "rb") FileNotFoundError: [Errno 2] No such file or directory: '/root/autodl-tmp/AOD-Net-PyTorch/data/train/haze/33_outdoor.jpg'

Jackdachun commented 4 months ago

The cause of this error is the line "image_list_haze = glob.glob(hazy_images_path + "*.jpg")" in "dataloader.py". The path obtained by the "glob.glob" function under windows and linux systems is slightly different. The path of the same file in windows system is "data/images/data\NYU2_714.jpg", and the path in linux system is "data/images/data/NYU2_714.jpg". After the above path is sliced by the code "image = image.split("/")[-1]" on line 27, the "image" variable is "data/NYU2_714.jpg". The code can be changed to "image = image.split("\")[-1]", after the string is sliced, the "image" variable is "NYU2_714.jpg"

thanks,I need to train other datasets. How should I handle datasets? And modify the dataloader??