Help needed with Data loading

I’m currently working on Image denoising task.
I have two folders with me- one folder contains clean images and the other folder contains noisy images.
NOTE: the images in both the folders are in sequence. i.e. If clean folder has an image 1.png then 1.png is the noisy image corresponding to that clean image.

I’ve selected MSE loss as my loss class
Now the problem I’m facing is that when I’m writing a loop to train my CNN, I have to feed both the output of the model ( output = model(noisy) ) and the clean image

loss=criterion(output,clean)

I don’t know how to load both the images simultaneously in the training loop.

Can anyone help me out with it.
Thanks in advance!

If, you need to define your own custom dataset, you can load both images in __getitem__ method by using CustomDataset. Here is post for such a situation: Custom Dataset with some preprocessing

Also, dataloading tutorial has complete info about problems with customized data.

Bests

Thank you so much!
I understood what I need to do in order to load both the images simultaneously.
Can’t wait to implement this!

P.S according to @Nikronic’s suggestion I further watched a video on youtube which explains how to make this type of CustomDataset.
Link to the video here!

1 Like