@@ -6,7 +6,7 @@ class DAE_dataset(Dataset):
6
6
def __init__ (self , data_dir , transform = None ):
7
7
self .data_dir = data_dir
8
8
self .transform = transform
9
- self .imgs_data = self .get_data (os .path .join (self .data_dir , 'imgs' ))
9
+ self .imgs_data = self .get_data (os .path .join (self .data_dir , 'imgs' ))
10
10
self .noisy_imgs_data = self .get_data (os .path .join (self .data_dir , 'noisy' ))
11
11
12
12
def get_data (self , data_path ):
@@ -16,22 +16,25 @@ def get_data(self, data_path):
16
16
return data
17
17
18
18
def __getitem__ (self , index ):
19
+ # read images in grayscale, then invert them
19
20
img = 255 - cv2 .imread (self .imgs_data [index ] ,0 )
20
21
noisy_img = 255 - cv2 .imread (self .noisy_imgs_data [index ] ,0 )
21
22
22
- img = np .pad (img , ((96 , 96 ), (0 ,0 )), constant_values = (0 ,0 ))
23
- noisy_img = np .pad (noisy_img , ((96 , 96 ), (0 ,0 )), constant_values = (0 ,0 ))
23
+ # padding the images
24
+ # img = np.pad(img, ((96, 96), (0,0)), constant_values=(0,0))
25
+ # noisy_img = np.pad(noisy_img, ((96, 96), (0,0)), constant_values=(0,0))
24
26
25
27
if self .transform is not None :
26
28
img = self .transform (img )
27
29
noisy_img = self .transform (noisy_img )
30
+
28
31
return img , noisy_img
29
32
30
33
def __len__ (self ):
31
34
return len (self .imgs_data )
32
35
33
36
class custom_test_dataset (Dataset ):
34
- def __init__ (self , data_dir , transform = None , out_size = (256 , 256 )):
37
+ def __init__ (self , data_dir , transform = None , out_size = (64 , 256 )):
35
38
self .data_dir = data_dir
36
39
self .transform = transform
37
40
self .out_size = out_size
@@ -44,13 +47,16 @@ def get_data(self, data_path):
44
47
return data
45
48
46
49
def __getitem__ (self , index ):
50
+ # read images in grayscale, then invert them
47
51
img = 255 - cv2 .imread (self .imgs_data [index ] ,0 )
48
52
53
+ # aspect ratio of the image required to be fed into the model (height/width)
49
54
out_ar = self .out_size [0 ]/ self .out_size [1 ]
50
55
51
- # aspect ratio is the padding criteria here
56
+ # aspect ratio of the image read
52
57
ar = img .shape [0 ]/ img .shape [1 ] # heigth/width
53
58
59
+ # aspect ratio is the padding criteria here
54
60
if ar >= out_ar :
55
61
# pad width
56
62
pad = int (img .shape [0 ]/ out_ar ) - img .shape [1 ]
@@ -68,7 +74,7 @@ def __getitem__(self, index):
68
74
69
75
if self .transform is not None :
70
76
img = self .transform (img )
71
- return img , img
77
+ return img
72
78
73
79
def __len__ (self ):
74
80
return len (self .imgs_data )
0 commit comments