Football Graphics
0

Football Game to Broadcast Dataset

This dataset contains over 2,000 images of Football Manager 2018 game engine screencaps and real-life football broadcast screencaps respectively. This is intended to be used with image translation models, such as CycleGANs, although you can also use it with regular GANs as well.

To train with a CycleGAN:

mantra train cyclegan --dataset footballgraphics --image-dim 256 256

Importing

To import this dataset to your project, run:

mantra import RJT1990/data/footballgraphics

Usage

Example usage in code:

from data.maps.data import FootballGraphics d = FootballGraphics() print(d.Y.__class__) ## <class 'numpy.ndarray'> contains Football Manager 2018 images print(d.X.__class__) ## <class 'numpy.ndarray'> contains real-life football broadcast images

Data processing
import numpy as np import glob import os import inspect from mantraml.data import ImageDataset, cachedata class FootballGraphics(ImageDataset): # core metadata data_name = 'Football Graphics' data_tags = ['football', 'fm2018', 'cycle'] files = ['fm2018screencaps.tar.gz'] image_dataset = 'fm2018screencaps.tar.gz' # referring to the file that contains the images # additional default data has_labels = False image_dim = (256, 256) normalize = True @cachedata def Y(self): """ This method extracts inputs from the data. The output should be an np.ndarray that can be processed by the model. Returns -------- np.ndarray - of data inputs (X vector) """ images = glob.glob(os.path.join(self.extracted_data_path, 'game/*%s' % self.file_format)) training_data = [] self.unprocessed_images = [] self.image_file_names = [] for image_name in images: image_data = self.get_image(image_name, resize_height=self.image_shape[0], resize_width=self.image_shape[1], crop=True, normalize=self.normalize) if image_data.shape == self.image_shape: training_data.append(image_data) self.image_file_names.append(image_name.split(self.extracted_data_path +'/')[-1]) else: self.unprocessed_images.append((image_name, 'Image shape of extracted image differed from self.image_shape : %s' % image_name)) np.random.shuffle(training_data) return np.array(training_data) @cachedata def X(self): """ This method extracts inputs from the data. The output should be an np.ndarray that can be processed by the model. Returns -------- np.ndarray - of data inputs (X vector) """ images = glob.glob(os.path.join(self.extracted_data_path, 'real/*%s' % self.file_format)) training_data = [] self.unprocessed_images = [] self.image_file_names = [] for image_name in images: image_data = self.get_image(image_name, resize_height=self.image_shape[0], resize_width=self.image_shape[1], crop=True, normalize=self.normalize) if image_data.shape == self.image_shape: training_data.append(image_data) self.image_file_names.append(image_name.split(self.extracted_data_path +'/')[-1]) else: self.unprocessed_images.append((image_name, 'Image shape of extracted image differed from self.image_shape : %s' % image_name)) np.random.shuffle(training_data) return np.array(training_data)
All files
Last Modified |
raw
17 September 2018 9:38 PM
__init__.py
17 September 2018 9:38 PM
data.py
17 September 2018 9:38 PM
README.md
17 September 2018 9:38 PM