PytorchLearning:

    def __getitem__(self, index):
          x = Image.open(self.filenames_OI[index])
          y = Image.open(self.filenames_NI[index])
         return X, y



Jus replace the Image.open by any other like
    def __getitem__(self, index):
          x = imageio.imread(self.filenames_OI[index])
          y = imageio.imread(self.filenames_NI[index])
         return X, y

There are many libraries to open images.