Can Machine Learning Design a Football Kit?

Algorithms have far too much influence on our lives. A computer decides what you’ll see on your news feed, what you’ll watch next on YouTube, how much you’ll pay for your insurance and so many other things.

But humanity is yet to pose the big question to artifical intelligence – can a computer design my team’s next football kit?

Inspired by super creepy websites and papers that create faces of people that don’t exist, we took a run at trying to convince a computer to create a shirt. In this article, we’ll run you through our process, see how far we get and where we hit our limits. Nike’s designers don’t need to worry too much just yet.

Collecting our data

Our project starts with needing a dataset of training images for our machine learning algorithm to digest before it takes on the world’s best designers. In our case, we need a shedload of football kit images.

I am a terrible and lazy programmer, so I need to find images with consistent sizes and backgrounds. This will save me from cropping and resizing everything, allowing our algorithm to efficiently focus on the important aspects of the design.

As far as I know, there are no datasets for football kit images and going to each club website is going to be effort-intensive (lazy, remember). This leads us to one of our favourite parts of the internet – classicfootbalshirts.co.uk.

There, we can scrape through shirt listings and save heaps of kit images with about 5 lines of code. CFS, I hope that this mention balances out scraping a few thousand images from your site and I thank you for your diligent kit photography 🙇‍♂️

In our first pass, we made a collection of CFS’ array of Premier League shirts. Example of just a few below 👇

Grid of Premier League Shirts

Let’s see what we can do with this.

Generating Kits

As we have a bank of images that we want to try and base some creations from, we are going to use a generative adversarial network for our model. This is a class of machine learning frameworks that uses two algorithms to learn how to create new outputs based on a training set of data. One algorithm is like an artist, it creates a picture for the other algorithm to assess how similar it is to the training set. The critic algorithm’s feedback is used by the artist to try over and over again until it can hopefully fool the critic into thinking that it is real.

Obviously there is an insane amount of maths behind this and I recommend you Google resources smarter than this for a proper explanation if you are interested.

We ran our model for hundreds of repetitions against the Premier League training set and here is how the generated designs evolved throughout the process:

Kit Generation Evolution

At the beginning, we just have static. This is the algorithm’s first guess – random pixels. From there, it quickly figures out the shape of the shirt, then gets on with mimicking the designs. It even learns to add in a badge and sponsor for a lot of the shirts.

Comparison grid of real images vs created ones

Comparing against our real pictures, I think the model has done a great job. Some could easily pass for kits at this zoomed out, blurred level. We even have some whacky designs that definitely could be a Warrior or Nike third kit. We do also have some that are definite misses, but all in all I reckon there is some really cool stuff here.

Even the Premier League influence from the training set is apparent. Some clear Barclays vibes going on that with a number of the kits – I see Ramsey’s Arsenal shirt, Ronaldo’s AIG United kit and even Leeds’ 95/96 green & blue away among others.

Let’s try with another dataset taken from a couple thousand random shirts all over the Classic Football Shirts website.

Kit Gen Evolution

And a few favourites:

Generated Kit Designs

Some absolute gold in here. The stripes-hoop combo is an instant classic, orange & blue reminds me of terrible Sunday League templates and the blue plaid design reminds me of a Marseille team with Gignac, Heinze and Valbuena pulling the strings. Alongside these, also a few that actually look like the bones of a real kit.

I am incredibly happy with what we have here. Starting with just a folder of a few thousand football kits we have created synthetic designs that could easily be your team’s next kit. Although we clearly do have a few problems…

Our Limits

These algorithms are computationally expensive. They take a huge amount of processing power and time, and only increase when you want to add more detail or train stronger models. To keep our model simple and runnable, the output images are limited to 64×64 pixels, leaving us with the grainy images that we have produced. Despite this, each model ran for around 5 hours in an accelerated Kaggle notebook, going to show the resources needed to run a professional-level model. Models can easily take days to run for adequate results.

Additionally, although we used thousands of pictures, a model built for any realistic purpose needs so many more than what we collected for this proof of concept. Classic Football Shirts, if you are reading this, send me your images!

If we were to do this properly, we’d need to store this vast number of images with AWS, Google Cloud or similar and run our model with them for a longer time than we managed here. That’s before we even get to fully optimising the model – it is easy to hide issues when the images are so small and grainy!

Conclusion

Despite clear limitations with image size and clarity, I am very happy with what we managed to create. We scraped a load of football shirts and trained a model that gave us some pretty decent starting points for football kit designs.

Loads of the kits looked like regular ones that we see each week, but some had super extroverted designs that would fit in better in South American leagues or as experimental third kits.

I was particularly impressed by the handful of synthetic kits from the Premier League model that clearly are recognisable as being based on a particular team design. I’d love to do this in the future with other leagues, and with a lot more time & computing power to increase the kit size.

Generative adversarial networks are incredible and what people have achieved with them with stronger hardware and skills is both inspiring and frightening in equal measure.

Let us know your thoughts on this at Twitter. This was great fun to put together and thank you for reading.

Further reading

In place of my code, please find some better takes on this subject:

Introduction to generative adversarial network with Python

Creating Pokemon with a Generative Adversarial Network

TensorFlow GAN Tutorial