## 3 Methodology and Implementation
### Methods of Compilation of the Neural Network Module
#### 3.2.3 TensorFlow Serving + Flask  
After analyzing the capabilities and limitations of each approach, the next verified solution was to create a stand-alone query server for SSNs as a combination of two server environments, i.e., the Flask environment and the TensorFlow Serving environment.  
Figure 11 is a general diagram of how such an SSN model server works. In this solution, the main response server for the client program is a server program based on the Flask environment, which carries out the communication process with the SSN model and performs post-processing of the received SSN responses in order to send the appropriate response to the given client program request. Both the Flask processing server module and the SSN model server run as programs running in a Docker virtualization environment container. The SSN model server in this case is invisible to the client program, while communication with the Flask processing server takes place internally over the network on the virtual side of the Docker container.  
Figure 12 is a detailed diagram of the interaction of two query servers for the SSN model together with a client program. In the current model, requests and responses to and from the model are received via HTTP/HTTPS using the POST method. The request to the SSN model in the form of an image (b64 encoded file) is sent using a form and Ajax technology to the processing server (Flask Server). In the first step, the processing server loads a database of available images. After the database load operation, the server decodes the b64-format image file received in the POST request into byte form. The byte form of the image file is converted to a tensor (an array of floating point numbers with dimensions:  
Figure 10: Flask server dockerisation diagram.  
[height \(\times\) width \(\times\) number of channels]) in JSON file format. The loaded image files from the database are also converted to JSON input tensors. After the conversion operation, the created JSON files are sent to the SSN model server for their response in the form of similarity vectors. For the similarity vector obtained (based on the image file from the client program form), the mean square error is calculated with each similarity vector obtained from the image files from the database.  
The creation of such an SSN model server consisting of a processing and query module consists of three steps as shown in Figure 13. The first step is to create a dependency base image for the Docker container, which will contain all the necessary Python libraries and the TensorFlow environment along with the model server. An SSN model server image will be created from the dependency image. Creating a model server that is based on the dependency image will avoid lengthy downloads of required dependencies when the server image is modified and re-built. The next step after building the dependency image and then the server image is to create the image container, which is an instance of the server image. The container created is a proper dual-mode server that has the capacity to handle queries for SSN models.  
Figure 11: General diagram of operation of the SSN model server together with the Flask processing server.  
Figure 12: A diagram of the collaboration/exchange of requests and responses between the client, the processing server and the neural network model server.  
In summary, the last solution leverages the strengths of both Flask and TensorFlow Serving. A hybrid solution was implemented to create a standalone SSN model server. In this architecture, the Flask server acts as the main communication interface with client applications, the SSN model server processes the actual model requests and remains invisible to the client, and the communication between the two servers is handled internally in a Docker container.