The Family Tree Software Series

Facial recognition and Configuration: Wrapping up #7

Article explaining configuration and other application details

gksriharsha

--

Source Complex gear system.

This is the final article about building genealogy software using a graph database. In the previous articles, we have looked into traversal and transforming the relation chains into named relations. In this article, I would be writing about configuration and structure in the application.

Flask

My project structure

I have followed the following structure where all the route endpoints are placed inside the respective folders with _routes suffix. The related gremlin commands are placed in the corresponding gremlin_Interface files. I have chosen to follow this structure because logically all the functions and endpoints can be easily separated into different files. The entire application is present inside a python package. The crucial commands like the traversalSource initialization are performed in the __init__.py file. The creation of groovy procedures in the graph database is also done from the init file. All the corresponding groovy functions are stored in the .groovy file. These groovy procedures make building the rest of the application easy. I strongly recommend using an appropriate DSL (Domain Specific Language) for the application which is in development.

Security

Source Keeping it safe.

The application is currently being developed for executing on a laptop. Therefore security is not factored while its development. At least a Bearer token would be introduced in the future to protect the information present in the application. There are security options for Janus Graph, Cassandra and Elastic Search. Those must be properly configured to prevent the theft of valuable information. Designing security for this application is a separate topic that takes a lot of time and effort. I would be writing an article about it once completed.

Configuration Management

Applications that are of this size, definitely require a common file that contains the values of all configurations. It is not encouraged to develop an application that has values that are hard-coded all over. It is best to create a class that contains all basic configurations in one place. We can later build different classes that inherit from this base class and override the required values. I have learned a lot by watching this video. Structuring the application is very important. My application is currently 2.3 k lines of code. Going through all of it to just find one hard-coded value is hell. Therefore, I strongly suggest following the structure explained in this video.

Facial Recognition
Python has a face-recognition library available which can be directly used in the project. There are many tutorials on using this library on the internet but the most useful one to me was the following.

Video explaining the usage of facial recognition library
pip install face-recognition

Many family gatherings happened in my life and I have pictures of all of the events. This library can detect multiple people in a picture. Using that feature and other libraries called openCV and PIL, I could crop the face and store them in a folder with a unique ID. To get a better match and to counter the effects of growth and facial changes, photos from all the time for the same person will be grouped into the same folder.
Once all the photos are processed, unique IDs of the folders are assigned to different vertex id numbers present in the graph database. Therefore now when a picture search is initiated, this library can be used to get the unique ID of the folder and get the corresponding person. Similar code can be used for video sources or live feeds ( from AR).

GPU requirement

Source RTX graphics card!

have worked with this application without a GPU and have experienced a response time of 3–3.5 seconds from the Flask server. During the development phase, this wait time is tolerable. If this application were to go mainstream, it definitely needs a GPU to speed up the face recognition process. There are three main components to setting up GPU to this project.

  1. After installing the hardware, install the related Nvidia drivers.
  2. Create an account for working as Nvidia developer. With the help of this account you have to download CUDA.
  3. Once this is completed, you have to download and install cudnn software from Nvidia.
  4. Once these softwares are installed, remove the dlib package from python (if present) and reinstall it from the dlib GitHub page.
  5. Search in the installation log for “dlib configured to use CUDA”.
  6. Once this statement is printed in the log, the face-recognition library uses the GPU present in the system

The face-recognition has functions some of which support a parameter called model. This is set to “hog” by default which means CPU is performing the computation. Change it to “cnn” which gives the processing to the configured GPU. There are other parameters such as num_jitters which can improve the accuracy and resolution of the task. Feel free to explore their documentation while configuring this package. These parameters should be tuned according to the hardware availability and software requirement.

Summary

As I have mentioned in the previous article, this software is still under development. I would be uploading the source code to my GitHub account. If you have any questions in going through the series of articles, please feel free to message me on my LinkedIn account. Thank you everyone for reading my articles. I would be posting more articles on the projects that I would be working on.

--

--