Pixel Pal (PART 4) : Training a model

Posted on Sun 19 April 2020 in Linux, HiDPI, PixelPal

Pixel Pal is a project I have started whose purpose is to bring new life to old icon themes. Many old icon themes are in raster format and are not available for HiDPI screens (their resolution are too small). Currently the only way to handle old icon themes is to resample them by the desired factor, but the icons look pixelated. The goal of this project is to use deep learning to upsample small icons into icons for HiDPI screens.

This is the fourth article about this project. Here are the other three:

  1. Part #1 Explaining the project.
  2. Part #2 Building the dataset
  3. Part #3 Measuring model quality

In this part I will be training models. To build and train models I will use _Tensorflow: https://www.tensorflow.org/ and _Keras: https://keras.io/. Tensorflow and keras are at this point the industry standard for neural networks in Python. I won't explain how to train networks in Keras there is already a lot of documentation on how to do this. In this section I want to talk about a couple of important things to do when training to avoid wasting time (training well is time consuming):

  1. Output metrics during learning not just the loss to visualise the learning live.
  2. Use a validation dataset to measure the progress of learning on a dataset which is different from the training dataset. The point is to see the real progress of the learning and spot early issues like overfitting (or learning too fast).
  3. Use a early stopping callback : This will check the progress of the validation metrics and stop the learning if the training algorithm is no longer learning. This helps avoid of leaving the training algorithm going on for nothing.
  4. Use checkpoints : This will save the model regularly and if your training crashes you can restart from where you left.
  5. Regularly save the output (as an image) of the neural network on fixed image inputs. This helps you visualise the progress of the learning.