File size: 5,581 Bytes
e54948d
630c0df
e54948d
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
16ab311
 
 
 
e54948d
 
16ab311
 
 
 
e54948d
 
 
 
 
 
 
 
 
 
 
bdabc8d
e54948d
 
 
 
 
 
 
 
 
 
 
 
 
16ab311
e54948d
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
bdabc8d
e54948d
 
 
 
16ab311
 
5b4fab1
 
083d4cc
1561be2
 
 
 
083d4cc
5b4fab1
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
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
import datasets
import cv2


_DESCRIPTION = ''

_PROJECTS_GAME_ENGINE = [
    'GameEngine_ActionRPG',
    'GameEngine_ArchVizInterior',
    'GameEngine_ASCTeuthisan',
    'GameEngine_BroadcastSample',
    'GameEngine_CitySample',
    'GameEngine_ElectricDreamsEnv',
    'GameEngine_ElementalDemo',
    'GameEngine_HillsideSample',
    'GameEngine_Matinee',
    'GameEngine_MeerkatDemo',
    'GameEngine_MLDeformerSample',
    'GameEngine_ParticleEffects',
    'GameEngine_RealisticRendering',
    'GameEngine_SlayAnimationSample',
    'GameEngine_StylizedRendering',
    'GameEngine_SubwaySequencer',
    'GameEngine_SunTemple'
]

_PROJECTS_DOWNSCALE = [
    'Downscale_Dota2'
]

# _PROJECTS = _PROJECTS_GAME_ENGINE + _PROJECTS_DOWNSCALE
_PROJECTS = _PROJECTS_DOWNSCALE

_DESCRIPTION_DATA_GAME_ENGINE = {
    'GameEngine_ActionRPG': '',
    'GameEngine_ArchVizInterior': '',
    'GameEngine_ASCTeuthisan': '',
    'GameEngine_BroadcastSample': '',
    'GameEngine_CitySample': '',
    'GameEngine_ElectricDreamsEnv': '',
    'GameEngine_ElementalDemo': '',
    'GameEngine_HillsideSample': '',
    'GameEngine_Matinee': '',
    'GameEngine_MeerkatDemo': '',
    'GameEngine_MLDeformerSample': '',
    'GameEngine_ParticleEffects': '',
    'GameEngine_RealisticRendering': '',
    'GameEngine_SlayAnimationSample': '',
    'GameEngine_StylizedRendering': '',
    'GameEngine_SubwaySequencer': '',
    'GameEngine_SunTemple': ''
}

_DESCRIPTION_DATA_DOWNSCALE = {
    'Downscale_Dota2': ''
}

_DESCRIPTION_DATA = _DESCRIPTION_DATA_DOWNSCALE

# _DESCRIPTION_DATA = {
#     **_DESCRIPTION_DATA_GAME_ENGINE,
#     **_DESCRIPTION_DATA_DOWNSCALE
# }

_DATA_FILES_GAME_ENGINE = {
    'GameEngine_ActionRPG': '',
    'GameEngine_ArchVizInterior': '',
    'GameEngine_ASCTeuthisan': '',
    'GameEngine_BroadcastSample': '',
    'GameEngine_CitySample': '',
    'GameEngine_ElectricDreamsEnv': '',
    'GameEngine_ElementalDemo': '',
    'GameEngine_HillsideSample': '',
    'GameEngine_Matinee': '',
    'GameEngine_MeerkatDemo': '',
    'GameEngine_MLDeformerSample': '',
    'GameEngine_ParticleEffects': '',
    'GameEngine_RealisticRendering': '',
    'GameEngine_SlayAnimationSample': '',
    'GameEngine_StylizedRendering': '',
    'GameEngine_SubwaySequencer': '',
    'GameEngine_SunTemple': ''
}

_DATA_FILES_DOWNSCALE = {
    'Downscale_Dota2': {
        'train': {
            'r270p': 'data/DownscaleData/Dota2/train-270p.tar.gz',
            'r360p': 'data/DownscaleData/Dota2/train-360p.tar.gz',
            'r540p': 'data/DownscaleData/Dota2/train-540p.tar.gz',
            'r1080p': 'data/DownscaleData/Dota2/train-1080p.tar.gz'
        },
        'val': {
            'r270p': 'data/DownscaleData/Dota2/val-270p.tar.gz',
            'r360p': 'data/DownscaleData/Dota2/val-360p.tar.gz',
            'r540p': 'data/DownscaleData/Dota2/val-540p.tar.gz',
            'r1080p': 'data/DownscaleData/Dota2/val-1080p.tar.gz'
        }
    }
}

# _DATA_FILES = {
#     **_DATA_FILES_GAME_ENGINE,
#     **_DATA_FILES_DOWNSCALE
# }

_DATA_FILES = _DATA_FILES_DOWNSCALE


class SuperResolutionGamesConfig(datasets.BuilderConfig):
    def __init__(self, data_files, features, **kwargs):
        super().__init__(version=datasets.Version('0.0.0'), **kwargs)
        self.data_files = data_files
        self.features = features


class SuperResolutionGames(datasets.GeneratorBasedBuilder):
    BUILDER_CONFIGS = [
        SuperResolutionGamesConfig(
            name=name,
            description=_DESCRIPTION_DATA[name],
            data_files=_DATA_FILES[name],
            features=['r270p', 'r360p', 'r540p', 'r1080p']
        ) for name in _PROJECTS
    ]

    def _info(self):
        features = {f: datasets.Image() for f in self.config.features}
        return datasets.DatasetInfo(
            description=_DESCRIPTION,
            features=datasets.Features(features),
            supervised_keys=None,
        )

    def _split_generators(self, dl_manager):
        data_files = self.config.data_files
        train_archives, val_archives = data_files['train'], data_files['val']

        train_archives_downloaded = {
            k: dl_manager.download(train_archives[k]) \
                for k in train_archives.keys()
        }

        val_archives_downloaded = {
            k: dl_manager.download(val_archives[k]) \
                for k in val_archives.keys()
        }

        splits = [
            datasets.SplitGenerator(
                name=datasets.Split.TRAIN,
                gen_kwargs={
                    k: dl_manager.iter_archive(train_archives_downloaded[k]) \
                        for k in train_archives_downloaded.keys()
                }
            ),
            datasets.SplitGenerator(
                name=datasets.Split.VALIDATION,
                gen_kwargs={
                    k: dl_manager.iter_archive(val_archives_downloaded[k]) \
                        for k in val_archives_downloaded.keys()
                }
            )
        ]
        return splits

    def _generate_examples(self, r270p, r360p, r540p, r1080p):
        for idx, resolutions in enumerate(zip(r270p, r360p, r540p, r1080p)):
            r270p_i, r360p_i, r540p_i, r1080p_i = resolutions
            sample = {
                'r270p': {'path': r270p_i[0], 'bytes': r270p_i[1].read()},
                'r360p': {'path': r360p_i[0], 'bytes': r360p_i[1].read()},
                'r540p': {'path': r540p_i[0], 'bytes': r540p_i[1].read()},
                'r1080p': {'path': r1080p_i[0], 'bytes': r1080p_i[1].read()}
            }
            yield idx, sample