Functions to draw on canvas are defined in draw.js. It is possible to draw with mouse on PC and with touches on mobile devices. Button "Clear" clears the canvas and hides unnecessary elements of interface. Pressing button "Predict" sends the data to python script (64 bit encoded JPG URL) with ajax request.
The encoded image is passed into main.py. It is decoded and is sent to functions.py. Weights of CNN are loaded when the app is initialized, so predictions can be done quickly. The weights are kept in the app on Heroky. Then the image is processed:
After this CNN model makes prediction for each object, the result is either a number or '-' for non-digits.