Download pictures of Chess world champions from google and store them in a way that's compatible with imagenet.
On google images, search for the names of champions, then this on the Developer Console:
urls = Array.from(document.querySelectorAll('.rg_di .rg_meta')).map(el=>JSON.parse(el.textContent).ou);
window.open('data:text/csv;charset=utf-8,' + escape(urls.join('\n')));
Load a ResNet-50 model with weigths pre-trained from the imagenet dataset, then use it a as backbone for the champions classifier model.
Using transfer learning method to reuse the capabilities learnt by the image-net based model. 1. Remove the last layer of the original model as it was trained to classify images to one of 1000 imagenet classes (as it's use less in our case) 1. Add a header on top of this base model, 2. Freeze the layers in this base model 3. Train only the head to learn how to classify the picture of the champions.
Helper functions to set the layers of a NN to trainable or not
First: we need to train only the top layers (which were randomly initialized) and freeze all layers from the base model
We need to generates batches of samples indefinitely, our features is an array of data with shape (batch_size,224,224,3) and labels is an array of data with shape (batch_size,1). We use data from features and labels to train our model.
calculate the output of the activation layer
average on the last dimension then scale the 7x7 matrix to image_size then display it on top of the original image