BobShih1008 commited on
Commit
f489417
·
1 Parent(s): 9923841

Create dataloader_raw.py

Browse files
Files changed (1) hide show
  1. dataloader_raw.py +36 -0
dataloader_raw.py ADDED
@@ -0,0 +1,36 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ class loadnpy:
2
+ def __init__(self, clean_image_dir, noisy_image_dir, transform=None):
3
+ self.clean_image_dir = clean_image_dir
4
+ self.noisy_image_dir = noisy_image_dir
5
+ self.transform = transform
6
+
7
+ self.clean_image_filenames = sorted(os.listdir(clean_image_dir))
8
+ self.noisy_image_filenames = sorted(os.listdir(noisy_image_dir))
9
+
10
+ def __len__(self):
11
+ return len(self.clean_image_filenames)
12
+
13
+ def __getitem__(self, idx):
14
+ clean_image_path = os.path.join(
15
+ self.clean_image_dir, self.clean_image_filenames[idx]
16
+ )
17
+ noisy_image_path = os.path.join(
18
+ self.noisy_image_dir, self.noisy_image_filenames[idx]
19
+ )
20
+ if "400frames" in noisy_image_path:
21
+ clean_image_path = clean_image_path.replace(
22
+ "_" + str(clean_image_path).split("_")[-1], ".npy"
23
+ ).replace("noisy", "gt")
24
+ clean_image = np.load(clean_image_path)
25
+ noisy_image = np.load(noisy_image_path)
26
+ if self.transform:
27
+ clean_image = self.transform(clean_image)
28
+ noisy_image = self.transform(noisy_image)
29
+
30
+ return noisy_image, clean_image, noisy_image_path
31
+
32
+
33
+ if __name__ == "__main__":
34
+ gt_path = "your_path/ambaraw_20240111/RAW/gt/"
35
+ noisy_path = "your_path/ambaraw_20240111/RAW/noisy/"
36
+ dataset = loadnpy(gt_path, noisy_path)