DeGirum Face Tracking Application Package
Project description
Face Tracking Demo
Demonstrates the following technologies:
- Face Detection in a video stream. Yolo models from DeGirum zoo are used.
- Creating face embeddings by DeepFace
- Saving face metadata, including embeddings, in a vector database (LanceDB)
- Recognition of detected faces, using saved faces metadata.
Used as a mock-up for development of hybrid deployment of a vector db.
1.Installation
Create a new conda environment:
conda env create -f environment.yml
Activate it:
conda activate dg_face_tracking
Create a database folder:
mkdir db
Open env.ini file and fill the DEGIRUM_CLOUD_TOKEN field with a valid DeGirum cloud platform API access token.
2. Running
A laptop with an enabled camera must be used.
Start the face tracking app:
python track.py -d <deployment> -c <config>
Options:
- deployment: cloud, local or docker
- config: config path, relative to Configs subfolder
Press OK button to finalize keying.
Ctrl+C stops the app.
3. Creating a dataset.
- Edit the
face_tracker_camera.cfg
config file by adding
[${data_source.id}, ${dataset_writer}]
line in data_connections
section.
- In
dataset
section ofLocalDBWriter.cfg
config file:
- Set the valid paths for catalogue (
catalogue_path
) and the datasets path (datasets_path
); - Set dataset name
dataset_name
- If you want to overwrite the existing dataset, set
write_mode
as "overwrite"
Run the application.
To stop data collection, press Ctrl+C
4. Running on a dataset
python DataFace.py face_tracker_dataset
dataset
section of FaceTrackerDataset.cfg
must contain the valid parameters of the dataset to be used:
- Set the valid paths for catalogue (
catalogue_path
) and the datasets path (datasets_path
); - Set the dataset name (
dataset_name
)
Run the application.
To stop running, press Ctrl+C
5. Face to ID functionality
To label a cropped face image: import face2id
function
from dg_face_tracking.Face2ID.face2id import face2id
Interface:
def face2id(img: Union[str, np.ndarray],
deployment: str = "docker",
async_support: bool = False,
verbose: bool = False) -> str:
Parameters:
img : str or ndarray: face image as base64 encoded png or numpy array
deployment: ["cloud", "local", "docker"]
async_support: bool: do we need to enable async support
verbose: bool: for testing purpose only
Return value: json string
{"label": "<some label or empty string>", "error": "<error message or empty string>"}
Label can be a name of a person, unknown
or empty (in case of internal error)
Error is empty string on success or contains some error message
6. CI/CD
To make new release perform the following steps:
-
Assign new git tag by running the following command:
./rel-tag.sh x.y.z
where
x.y.z
is semantic version of new release. -
Open Github Release action page and configure release action by clicking Run workflow combo box, selecting Tags tab in Branch combo box, and specifying the tag, which corresponds to the released version:
-
Start release action by pressing green Run workflow button.
-
Make sure Release action finishes successfully (green checkmark new recent Release action run status)
-
Open Github Upload action page and configure upload action by clicking Run workflow combo box and specifying the release version tag in Release tag containing wheels to upload edit box:
-
Start upload action by pressing green Run workflow button.
-
Make sure Upload action finishes successfully (green checkmark new recent Upload action run status)
-
Verify, that release is avaiable for installation by running the following command:
pip uninstall -y dg_face_tracking && pip install -U dg_face_tracking
You should see the following prompt:
Successfully installed dg_face_tracking-x.y.z
6. Orin Local Demo Installation
6.1 Prerequisites
- Install the NVIDIA Container Toolkit and Configure Docker
https://docs.nvidia.com/datacenter/cloud-native/container-toolkit/latest/install-guide.html
- Start AIServer in Docker with nvidia runtime:
docker run -d -p 8778:8778 -v /my/model/zoo/dir:/zoo --runtime nvidia --privileged degirum/aiservertrt:latest
- Download models from DeGirum cloud zoo https://docs.degirum.com/documentation/PySDK-0.11.0/user-guide/cli/
6.2. Create conda environment and install dg_face_tracking package
conda create --name face_tracking python=3.9
conda activate face_tracking
pip install dg_face_tracking
6.3 Run the Demo
dr_face_tracking
To stop the demo: hit "x".
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distributions
Built Distribution
File details
Details for the file dg_face_tracking-0.1.5-py3-none-any.whl
.
File metadata
- Download URL: dg_face_tracking-0.1.5-py3-none-any.whl
- Upload date:
- Size: 131.3 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/5.0.0 CPython/3.9.19
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 98377afe0bee00d71d8cfc8b4d7aa57fe21328b1e599bee97861b0bb3c8c20ca |
|
MD5 | f470c94d89dcc282de078558f39441ee |
|
BLAKE2b-256 | 7540e7a1f04f0b78f59d9458e8b47065ab893f2daeb114f6aac5c0b6327eaf06 |