Hi,
I ran your code and it works fine.
Although there was a lot of problem with indentation. You may wannt to reformat your code using a framework or use a proper IDE/editor.
class Dataset(data.Dataset):
    def __init__(self, path_input_1, path_input_2):
        self.filenames_OI = []
        self.filenames_NI = []
        self.path_input_1 = path_input_1
        self.path_input_2 = path_input_2

        filenames_OI = glob.glob(osp.join(path_input_1, '*.jpg'))
        filenames_NI = glob.glob(osp.join(path_input_2, '*.jpg'))

        for fn_OI, fn_NI in filenames_OI, filenames_NI:
            self.filenames_OI.append(fn_OI)
            self.filenames_NI.append(fn_NI)

    def __len__(self):
        return len(self.path_input_1) 

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


train_dataset = Dataset(path_input_1 = 'path' ,path_input_2 = 'another/path')

Bests