The code of v_0.0 only allows you to recognize faces from a webcam
The code of v_1.0 allows you to find and recognize faces in a video conference, as well as count the time of presence on the video using facenet_pytorch (MTCNN, InceptionResnetV1) and OpenCV.
- Added YoloV5_face for face recognition
-
Cloning a repository:
git clone https://github.com/mkgs210/face_recognition
-
Installing the required libraries:
#facenet-pytorch==2.5.2 #opencv-python==4.6.0.66 #pandas==1.5.1 #matplotlib==3.6.2 pip install -r requirements.txt
-
Running the program with default options:
python main.py
Passed parameters:
-h
or--help
Displays description of all passed parameters-pcp
or--photo_catalog_path
The path to the photo folder. Inside this directory there should be signed folders with photos of people who will be present in the video (default=photos
)-ud
or--update_data
Updates/Creates a file data.pt (call when updating photos). This file contains encoded faces of people (embeddings)(default=True
)-dp
or--data_path
Path to the directory where the data.pt file is located (default=-wc
or--web_cam
Reading video from a webcam. Time log files will not be created (default=False
)-ivp
or--input_video_path
Full path to input video (default=video.mp4
)-dv
or--do_video
True - create a video in which all found and recognized faces will be marked. False - do not create (default=False
)-ovp
or--output_video_path
Full path of output video with tagged faces (default=new_video.mp4
)
An example of calling a program with parameters: python main.py -pcp photos -ud True -ivp video.mp4 -dv True -ovp new_video.mp4
At the first start, the InceptionResnetV1_VGGFace2
folder will be created and the InceptionResnetV1-vggface2
model will be loaded into it
At the end of the program, 4 files will be created:
- Time_{
--input_video_path
}.csv - file with calculated presence time on video
- Time_drop0_{
--input_video_path
}.csv - file with calculated time of presence on the video (values with zero time are discarded)
- barh_{
--input_video_path
}.jpg - a bar graph showing the percentage of time each person is present
- pie_{
--input_video_path
}.jpg - a pie chart showing the presence time of video participants relative to each other
Also, --do_video True
will create a video called --output_video_path
(default=new_video.mp4
)