SRGD / super-resolution-games.py
epishchik's picture
fix
6a16dec
raw
history blame
5.35 kB
import datasets
_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 el in r270p:
print(el)
break
for el1, el2, el3, el4 in zip(r270p, r360p, r540p, r1080p):
print(el1, el2, el3, el4)
# r270p_i, r360p_i, r540p_i, r1080p_i = files
# yield r270p_i, r360p_i, r540p_i, r1080p_i