A Tensorflow application to detect person alive by the camera using a Siamese Convolutional Net and LFW Dataset.
The heimdall is an application developed in Python version 3.7.9 64-bit.
Prerequisites:
Download and install Python 3.7.9, CUDA Toolkit 11.4 and cuDNN SDK 8.2.2.
NOTE: To run this application, it's recommended to have a GPU microprocessor and you should have a cam.
- First, clone the repository:
git clone https://github.com/erickmp07/heimdall.git
cd heimdall
-
Download the official weights pretrained on COCO Dataset here.
-
Save the file with the weights downloaded in the weights folder.
Then:
- Install the dependencies with
pip command
:
pip install -r requirements.txt
-
Download the LFW Dataset here.
-
Save the TGZ file in the heimdall root path.
-
To skip the model training, you can download a model pretrained here.
-
Extract the model pretrained to the heimdall root path.
Then:
- Install the dependencies with
pip command
:
pip install -r requirements.txt
- Load the pretrained weights and converts them to the Tensorflow format using the
convert_weights.py
script:
python convert_weights.py
- The pattern command to run the
video.py
script is:
python video.py <iou threshold> <confidence threshold> <filename>
NOTE: The video.py
script has a GPU check (recommended). So, if you don't have a GPU installed and want to run the model, comment this line at the script:
assert len(physical_devices) > 0, "Not enough GPU hardware devices available"
- Runs the model using one of following commands, for example:
python video.py 0.7 0.8 YOLOv3/data/videos/video01.mp4 # For video file input
or
python video.py 0.8 0.9 0 # For cam input
NOTE: Hit the "q" key to quit the detection.
Then, you can find the detections in the videos folder where the file name has the sufix "_detection" and the extension ".avi".
NOTE: Only one video can be processed at one run.
- The pattern command to run the
face_id.py
script is:
python face_id.py <detection threshold> <verification threshold> <train flag> <test flag>
All the arguments are "optional" and the default values are:
detection_threshold = 0.5
verification_threshold = 0.5
train_flag = ''
test_flag = ''
The command below run the face_id.py
script with the default values and DON'T train the model and DON'T make predictions with the test data:
python face_id.py
The command below run the face_id.py
script with values to detection and verification thresholds, DON'T train the model and make predictions with the test data:
python face_id.py 0.8 0.7 '' test
The command below run the face_id.py
script with values to detection and verification thresholds, train the model and make predictions with the test data:
python face_id.py 0.8 0.7 train test
After run one of the flavors of the face_id
command, a dialog will open with your cam image.
You should collect some positive (hitting the "p" key) and anchor (hitting the "a" key) examples. To quit the image collector, hit the "q" key.
Then, a new dialog will open with your cam image. Now, you can test the facial recognition. Hit the "v" key for verify if your face will be recognized or hit the "q" key for quit the recognition.
-
When running the YOLO Proof Of Concept or the Face ID project, the TensorFlow may not find "cusolver64_10.dll". To solve this, rename the "cusolver64_11.dll" in the CUDA bin folder to "cusolver64_10.dll".
-
If your cam is being used by another task, an exception will be raised while the OpenCV tries to establish a connection with your cam. If possible, end the task that is using the cam and try again.
-
If you have more than one cam, the script may not find the correct cam while running. To solve this, change the value of the
VIDEO_INDEX
constant and try again.
This project was developed with the following technologies:
NOTE: This is a graduation project from the Computer Engineering course at PUC-Rio.
To ask a question, please contact me.
Licensed under MIT license.