File size: 2,270 Bytes
83034b6
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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
45
46
47
48
49
50
51
52
53
54
import os
from data.pix2pix_dataset import Pix2pixDataset


class Sunny2DiffWeathersDataset(Pix2pixDataset):

    @staticmethod
    def modify_commandline_options(parser, is_train):
        parser = Pix2pixDataset.modify_commandline_options(parser, is_train)
        parser.add_argument('--test_mode', type=str, default='all',
                            help='specify style mode to control multi-modal image synthesis (MMIS) during test phase:'
                                 'night | cloudy | rainy | snowy | all')
        parser.set_defaults(preprocess_mode='fixed')
        parser.set_defaults(load_size=512)
        parser.set_defaults(crop_size=512)
        parser.set_defaults(display_winsize=512)
        parser.set_defaults(aspect_ratio=2.0)
        opt, _ = parser.parse_known_args()
        if hasattr(opt, 'num_upsampling_layers'):
            parser.set_defaults(num_upsampling_layers='more')
        return parser


    def get_paths(self, opt):
        croot = opt.croot
        sroot = opt.sroot

        with open(os.path.join(croot, 'bdd100k_lists/sunny2diffweathers/sunny_%s.txt' % opt.phase)) as c_list:
            c_image_paths_read = c_list.read().splitlines()
            c_image_paths = [os.path.join(croot, p) for p in c_image_paths_read if p != '']

        if opt.phase == 'train' or opt.test_mode == 'all':
            mode_list = ['night', 'cloudy', 'rainy', 'snowy']
        else:
            mode_list = [opt.test_mode]
        s_image_paths = []
        for mode in mode_list:
            with open(os.path.join(sroot, 'bdd100k_lists/sunny2diffweathers/%s_%s.txt' % (mode, opt.phase))) as s_list:
                s_image_paths_read = s_list.read().splitlines()
                s_image_paths_mode = [os.path.join(sroot, p) for p in s_image_paths_read if p != '']
            s_image_paths.extend(s_image_paths_mode)

        while len(s_image_paths) < len(c_image_paths):
            s_image_paths = s_image_paths + s_image_paths

        instance_paths = []

        length = min(len(c_image_paths), len(s_image_paths))
        c_image_paths = c_image_paths[:length]
        s_image_paths = s_image_paths[:length]
        return c_image_paths, s_image_paths, instance_paths

    def paths_match(self, path1, path2):
        return True