SRGD / super-resolution-games.py
epishchik's picture
fix paths
97fe6f6
raw
history blame
17 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
_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_GAME_ENGINE,
**_DESCRIPTION_DATA_DOWNSCALE
}
_DATA_FILES_GAME_ENGINE = {
'GameEngine_ActionRPG': {
'train': {
'r270p': 'data/GameEngineData/ActionRPG/train-270p.tar.gz',
'r360p': 'data/GameEngineData/ActionRPG/train-360p.tar.gz',
'r540p': 'data/GameEngineData/ActionRPG/train-540p.tar.gz',
'r1080p': 'data/GameEngineData/ActionRPG/train-1080p.tar.gz'
},
'val': {
'r270p': 'data/GameEngineData/ActionRPG/val-270p.tar.gz',
'r360p': 'data/GameEngineData/ActionRPG/val-360p.tar.gz',
'r540p': 'data/GameEngineData/ActionRPG/val-540p.tar.gz',
'r1080p': 'data/GameEngineData/ActionRPG/val-1080p.tar.gz'
}
},
'GameEngine_ArchVizInterior': {
'train': {
'r270p': 'data/GameEngineData/ArchVizInterior/train-270p.tar.gz',
'r360p': 'data/GameEngineData/ArchVizInterior/train-360p.tar.gz',
'r540p': 'data/GameEngineData/ArchVizInterior/train-540p.tar.gz',
'r1080p': 'data/GameEngineData/ArchVizInterior/train-1080p.tar.gz'
},
'val': {
'r270p': 'data/GameEngineData/ArchVizInterior/val-270p.tar.gz',
'r360p': 'data/GameEngineData/ArchVizInterior/val-360p.tar.gz',
'r540p': 'data/GameEngineData/ArchVizInterior/val-540p.tar.gz',
'r1080p': 'data/GameEngineData/ArchVizInterior/val-1080p.tar.gz'
}
},
'GameEngine_ASCTeuthisan': {
'train': {
'r270p': 'data/GameEngineData/ASCTeuthisan/train-270p.tar.gz',
'r360p': 'data/GameEngineData/ASCTeuthisan/train-360p.tar.gz',
'r540p': 'data/GameEngineData/ASCTeuthisan/train-540p.tar.gz',
'r1080p': 'data/GameEngineData/ASCTeuthisan/train-1080p.tar.gz'
},
'val': {
'r270p': 'data/GameEngineData/ASCTeuthisan/val-270p.tar.gz',
'r360p': 'data/GameEngineData/ASCTeuthisan/val-360p.tar.gz',
'r540p': 'data/GameEngineData/ASCTeuthisan/val-540p.tar.gz',
'r1080p': 'data/GameEngineData/ASCTeuthisan/val-1080p.tar.gz'
}
},
'GameEngine_BroadcastSample': {
'train': {
'r270p': 'data/GameEngineData/BroadcastSample/train-270p.tar.gz',
'r360p': 'data/GameEngineData/BroadcastSample/train-360p.tar.gz',
'r540p': 'data/GameEngineData/BroadcastSample/train-540p.tar.gz',
'r1080p': 'data/GameEngineData/BroadcastSample/train-1080p.tar.gz'
},
'val': {
'r270p': 'data/GameEngineData/BroadcastSample/val-270p.tar.gz',
'r360p': 'data/GameEngineData/BroadcastSample/val-360p.tar.gz',
'r540p': 'data/GameEngineData/BroadcastSample/val-540p.tar.gz',
'r1080p': 'data/GameEngineData/BroadcastSample/val-1080p.tar.gz'
}
},
'GameEngine_CitySample': {
'train': {
'r270p': 'data/GameEngineData/CitySample/train-270p.tar.gz',
'r360p': 'data/GameEngineData/CitySample/train-360p.tar.gz',
'r540p': 'data/GameEngineData/CitySample/train-540p.tar.gz',
'r1080p': 'data/GameEngineData/CitySample/train-1080p.tar.gz'
},
'val': {
'r270p': 'data/GameEngineData/CitySample/val-270p.tar.gz',
'r360p': 'data/GameEngineData/CitySample/val-360p.tar.gz',
'r540p': 'data/GameEngineData/CitySample/val-540p.tar.gz',
'r1080p': 'data/GameEngineData/CitySample/val-1080p.tar.gz'
}
},
'GameEngine_ElectricDreamsEnv': {
'train': {
'r270p': 'data/GameEngineData/ElectricDreamsEnv/train-270p.tar.gz',
'r360p': 'data/GameEngineData/ElectricDreamsEnv/train-360p.tar.gz',
'r540p': 'data/GameEngineData/ElectricDreamsEnv/train-540p.tar.gz',
'r1080p': \
'data/GameEngineData/ElectricDreamsEnv/train-1080p.tar.gz'
},
'val': {
'r270p': 'data/GameEngineData/ElectricDreamsEnv/val-270p.tar.gz',
'r360p': 'data/GameEngineData/ElectricDreamsEnv/val-360p.tar.gz',
'r540p': 'data/GameEngineData/ElectricDreamsEnv/val-540p.tar.gz',
'r1080p': 'data/GameEngineData/ElectricDreamsEnv/val-1080p.tar.gz'
}
},
'GameEngine_ElementalDemo': {
'train': {
'r270p': 'data/GameEngineData/ElementalDemo/train-270p.tar.gz',
'r360p': 'data/GameEngineData/ElementalDemo/train-360p.tar.gz',
'r540p': 'data/GameEngineData/ElementalDemo/train-540p.tar.gz',
'r1080p': 'data/GameEngineData/ElementalDemo/train-1080p.tar.gz'
},
'val': {
'r270p': 'data/GameEngineData/ElementalDemo/val-270p.tar.gz',
'r360p': 'data/GameEngineData/ElementalDemo/val-360p.tar.gz',
'r540p': 'data/GameEngineData/ElementalDemo/val-540p.tar.gz',
'r1080p': 'data/GameEngineData/ElementalDemo/val-1080p.tar.gz'
}
},
'GameEngine_HillsideSample': {
'train': {
'r270p': 'data/GameEngineData/HillsideSample/train-270p.tar.gz',
'r360p': 'data/GameEngineData/HillsideSample/train-360p.tar.gz',
'r540p': 'data/GameEngineData/HillsideSample/train-540p.tar.gz',
'r1080p': 'data/GameEngineData/HillsideSample/train-1080p.tar.gz'
},
'val': {
'r270p': 'data/GameEngineData/HillsideSample/val-270p.tar.gz',
'r360p': 'data/GameEngineData/HillsideSample/val-360p.tar.gz',
'r540p': 'data/GameEngineData/HillsideSample/val-540p.tar.gz',
'r1080p': 'data/GameEngineData/HillsideSample/val-1080p.tar.gz'
}
},
'GameEngine_Matinee': {
'train': {
'r270p': 'data/GameEngineData/Matinee/train-270p.tar.gz',
'r360p': 'data/GameEngineData/Matinee/train-360p.tar.gz',
'r540p': 'data/GameEngineData/Matinee/train-540p.tar.gz',
'r1080p': 'data/GameEngineData/Matinee/train-1080p.tar.gz'
},
'val': {
'r270p': 'data/GameEngineData/Matinee/val-270p.tar.gz',
'r360p': 'data/GameEngineData/Matinee/val-360p.tar.gz',
'r540p': 'data/GameEngineData/Matinee/val-540p.tar.gz',
'r1080p': 'data/GameEngineData/Matinee/val-1080p.tar.gz'
}
},
'GameEngine_MeerkatDemo': {
'train': {
'r270p': 'data/GameEngineData/MeerkatDemo/train-270p.tar.gz',
'r360p': 'data/GameEngineData/MeerkatDemo/train-360p.tar.gz',
'r540p': 'data/GameEngineData/MeerkatDemo/train-540p.tar.gz',
'r1080p': 'data/GameEngineData/MeerkatDemo/train-1080p.tar.gz'
},
'val': {
'r270p': 'data/GameEngineData/MeerkatDemo/val-270p.tar.gz',
'r360p': 'data/GameEngineData/MeerkatDemo/val-360p.tar.gz',
'r540p': 'data/GameEngineData/MeerkatDemo/val-540p.tar.gz',
'r1080p': 'data/GameEngineData/MeerkatDemo/val-1080p.tar.gz'
}
},
'GameEngine_MLDeformerSample': {
'train': {
'r270p': 'data/GameEngineData/MLDeformerSample/train-270p.tar.gz',
'r360p': 'data/GameEngineData/MLDeformerSample/train-360p.tar.gz',
'r540p': 'data/GameEngineData/MLDeformerSample/train-540p.tar.gz',
'r1080p': 'data/GameEngineData/MLDeformerSample/train-1080p.tar.gz'
},
'val': {
'r270p': 'data/GameEngineData/MLDeformerSample/val-270p.tar.gz',
'r360p': 'data/GameEngineData/MLDeformerSample/val-360p.tar.gz',
'r540p': 'data/GameEngineData/MLDeformerSample/val-540p.tar.gz',
'r1080p': 'data/GameEngineData/MLDeformerSample/val-1080p.tar.gz'
}
},
'GameEngine_ParticleEffects': {
'train': {
'r270p': 'data/GameEngineData/ParticleEffects/train-270p.tar.gz',
'r360p': 'data/GameEngineData/ParticleEffects/train-360p.tar.gz',
'r540p': 'data/GameEngineData/ParticleEffects/train-540p.tar.gz',
'r1080p': 'data/GameEngineData/ParticleEffects/train-1080p.tar.gz'
},
'val': {
'r270p': 'data/GameEngineData/ParticleEffects/val-270p.tar.gz',
'r360p': 'data/GameEngineData/ParticleEffects/val-360p.tar.gz',
'r540p': 'data/GameEngineData/ParticleEffects/val-540p.tar.gz',
'r1080p': 'data/GameEngineData/ParticleEffects/val-1080p.tar.gz'
}
},
'GameEngine_RealisticRendering': {
'train': {
'r270p': \
'data/GameEngineData/RealisticRendering/train-270p.tar.gz',
'r360p': \
'data/GameEngineData/RealisticRendering/train-360p.tar.gz',
'r540p': \
'data/GameEngineData/RealisticRendering/train-540p.tar.gz',
'r1080p': \
'data/GameEngineData/RealisticRendering/train-1080p.tar.gz'
},
'val': {
'r270p': 'data/GameEngineData/RealisticRendering/val-270p.tar.gz',
'r360p': 'data/GameEngineData/RealisticRendering/val-360p.tar.gz',
'r540p': 'data/GameEngineData/RealisticRendering/val-540p.tar.gz',
'r1080p': 'data/GameEngineData/RealisticRendering/val-1080p.tar.gz'
}
},
'GameEngine_SlayAnimationSample': {
'train': {
'r270p': \
'data/GameEngineData/SlayAnimationSample/train-270p.tar.gz',
'r360p': \
'data/GameEngineData/SlayAnimationSample/train-360p.tar.gz',
'r540p': \
'data/GameEngineData/SlayAnimationSample/train-540p.tar.gz',
'r1080p': \
'data/GameEngineData/SlayAnimationSample/train-1080p.tar.gz'
},
'val': {
'r270p': 'data/GameEngineData/SlayAnimationSample/val-270p.tar.gz',
'r360p': 'data/GameEngineData/SlayAnimationSample/val-360p.tar.gz',
'r540p': 'data/GameEngineData/SlayAnimationSample/val-540p.tar.gz',
'r1080p': \
'data/GameEngineData/SlayAnimationSample/val-1080p.tar.gz'
}
},
'GameEngine_StylizedRendering': {
'train': {
'r270p': 'data/GameEngineData/StylizedRendering/train-270p.tar.gz',
'r360p': 'data/GameEngineData/StylizedRendering/train-360p.tar.gz',
'r540p': 'data/GameEngineData/StylizedRendering/train-540p.tar.gz',
'r1080p': \
'data/GameEngineData/StylizedRendering/train-1080p.tar.gz'
},
'val': {
'r270p': 'data/GameEngineData/StylizedRendering/val-270p.tar.gz',
'r360p': 'data/GameEngineData/StylizedRendering/val-360p.tar.gz',
'r540p': 'data/GameEngineData/StylizedRendering/val-540p.tar.gz',
'r1080p': 'data/GameEngineData/StylizedRendering/val-1080p.tar.gz'
}
},
'GameEngine_SubwaySequencer': {
'train': {
'r270p': 'data/GameEngineData/SubwaySequencer/train-270p.tar.gz',
'r360p': 'data/GameEngineData/SubwaySequencer/train-360p.tar.gz',
'r540p': 'data/GameEngineData/SubwaySequencer/train-540p.tar.gz',
'r1080p': 'data/GameEngineData/SubwaySequencer/train-1080p.tar.gz'
},
'val': {
'r270p': 'data/GameEngineData/SubwaySequencer/val-270p.tar.gz',
'r360p': 'data/GameEngineData/SubwaySequencer/val-360p.tar.gz',
'r540p': 'data/GameEngineData/SubwaySequencer/val-540p.tar.gz',
'r1080p': 'data/GameEngineData/SubwaySequencer/val-1080p.tar.gz'
}
},
'GameEngine_SunTemple': {
'train': {
'r270p': 'data/GameEngineData/SunTemple/train-270p.tar.gz',
'r360p': 'data/GameEngineData/SunTemple/train-360p.tar.gz',
'r540p': 'data/GameEngineData/SunTemple/train-540p.tar.gz',
'r1080p': 'data/GameEngineData/SunTemple/train-1080p.tar.gz'
},
'val': {
'r270p': 'data/GameEngineData/SunTemple/val-270p.tar.gz',
'r360p': 'data/GameEngineData/SunTemple/val-360p.tar.gz',
'r540p': 'data/GameEngineData/SunTemple/val-540p.tar.gz',
'r1080p': 'data/GameEngineData/SunTemple/val-1080p.tar.gz'
}
}
}
_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
}
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