| class loadnpy: | |
| def __init__(self, clean_image_dir, noisy_image_dir, transform=None): | |
| self.clean_image_dir = clean_image_dir | |
| self.noisy_image_dir = noisy_image_dir | |
| self.transform = transform | |
| self.clean_image_filenames = sorted(os.listdir(clean_image_dir)) | |
| self.noisy_image_filenames = sorted(os.listdir(noisy_image_dir)) | |
| def __len__(self): | |
| return len(self.clean_image_filenames) | |
| def __getitem__(self, idx): | |
| clean_image_path = os.path.join( | |
| self.clean_image_dir, self.clean_image_filenames[idx] | |
| ) | |
| noisy_image_path = os.path.join( | |
| self.noisy_image_dir, self.noisy_image_filenames[idx] | |
| ) | |
| clean_image = np.load(clean_image_path) | |
| noisy_image = np.load(noisy_image_path) | |
| if self.transform: | |
| clean_image = self.transform(clean_image) | |
| noisy_image = self.transform(noisy_image) | |
| return noisy_image, clean_image, noisy_image_path | |
| if __name__ == "__main__": | |
| gt_path = "your_path/sony_IMX678_20240111/RAW/gt/" | |
| noisy_path = "your_path/sony_IMX678_20240111/RAW/noisy/" | |
| dataset = loadnpy(gt_path, noisy_path) |