File size: 1,337 Bytes
2514fb4
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
import torch.utils.data as data
import utils.utils_image as util


class DatasetL(data.Dataset):
    '''
    # -----------------------------------------
    # Get L in testing.
    # Only "dataroot_L" is needed.
    # -----------------------------------------
    # -----------------------------------------
    '''

    def __init__(self, opt):
        super(DatasetL, self).__init__()
        print('Read L in testing. Only "dataroot_L" is needed.')
        self.opt = opt
        self.n_channels = opt['n_channels'] if opt['n_channels'] else 3

        # ------------------------------------
        # get the path of L
        # ------------------------------------
        self.paths_L = util.get_image_paths(opt['dataroot_L'])
        assert self.paths_L, 'Error: L paths are empty.'

    def __getitem__(self, index):
        L_path = None

        # ------------------------------------
        # get L image
        # ------------------------------------
        L_path = self.paths_L[index]
        img_L = util.imread_uint(L_path, self.n_channels)

        # ------------------------------------
        # HWC to CHW, numpy to tensor
        # ------------------------------------
        img_L = util.uint2tensor3(img_L)

        return {'L': img_L, 'L_path': L_path}

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