World flags' latent space generated using a convolutional autoencoder of flags

- 2 mins

Latent Flags

When you plot the 2D TNSE representation of RGB images, in general what you find is that images are clustered according the colors. For this particular case I plot the TSNE representation of the flags of the different countries.

TNSE representation of the country flags

As I said, the main feature that cluster the different flags is the color. Then some other features such as vertical or horizontal lines, or the presence of the Great Britain flag inside the flag.

I was wondering how much this changes if we train a convolutional autoencoder using flags and we plot the TSNE of latent representation of the flags.

Autoencoder

Data

To train the autoencoder first I used around 3000 synthetic flags using the FlagsMashupBot and I scrapped around 3000 images from the FlagsMashupBot twitter account, twitter scrapper script. The reason why I scrapped their twitter account is because they have special edition flags that you can’t create using the bot.

I used the notebook preprocess_images.ipynb to resize all the images to squared shape and some other images preprocessing.

Autoencoder

Then I trained a very simple convolutional autoencoder following the notebook autoencoder.ipynb.

TSNE representation

In the notebook latente_space.ipynb contains the code snippets used to generate the latent space of the real flags and plot the TSNE representation of the flags.

The TSNE-latent representation of the images at first glance looks quite similar to the TSNE representation of the real images, however there are some differences.

TNSE-latent representation of the country flags

At first glance the images are clustered also mainly by colors. However the flags that have horizontal stripes (left region of the plot) have a greater variety of colors, this applies also for the vertical ones (right region of the plot). Structure of the flags is important in the latent space.

One thing that I liked is that the flags that contain the UK flag inside are quite close independently of the color (blue, light blue, and red, and UK).

Work in progress, to be continued…

Resources

Ivan Lengyel

Ivan Lengyel

I wanted to be a surfer and I ended up being a nerd.

comments powered by Disqus
rss facebook twitter github gitlab youtube mail spotify lastfm instagram linkedin google google-plus pinterest medium vimeo stackoverflow reddit quora quora googlescholar