The task that I encountered was to construct a program, which can run by itself and should keep watching multiple Database tables at different time intervals. To make it possible, I used the thread with TCP/IP to check whether new data tables are updated in SQL. If new data is found, then I access the data while remembering previously processed one. After transforming the newly scanned data into a 2D matrix and projecting it as an image, I implemented trained CNN model to predict the grade of a product. Finally, I write the prediction result with corresponding information on an outcome table and saved the image into the path(written in JSON file).
Structure of Codes
Global Variables: Required information to access SQL
JSON file: Paths where to save image and where trained model parameter located
Class A: SQL manager
Class B: Deep Learning Model and Pre-Processing
Function C: scheduler, which calls the functions in Class A and Class B to check whether a new data came in and execute to save the image and perform prediction.
3. Main function
Class A initialization enables us to connect database.
Class B initialization read JSON file for necessary paths
SetModel function in Class B ensures whether trained model parameters are loaded
Catch for Function C
Build executable file(.exe) using pyinstaller
Things to remember
If Tensorflow environment is CPU(GPU) based, trained model should be built upon CPU(GPU)
Type in required packages when building an executable file
Example of generating one python executable file in command line.