The Trueface Developer Hub

Welcome to the Trueface developer hub. You'll find comprehensive guides and documentation to help you start working with Trueface as quickly as possible, as well as support if you get stuck. Let's jump right in!

Getting started with the SDK

Installing dependencies and the python wheel

# copy wheel url from 
# https://github.com/getchui/offline_sdk/releases/latest
# and run
# pip install [wheel_url]

# for example for Linux:
pip install https://github.com/getchui/offline_sdk/releases/download/0.6.6/trueface-0.6.6-cp36-cp36m-linux_x86_64.whl

# for a Mac:
pip install https://github.com/getchui/offline_sdk/releases/download/0.6.6/trueface-0.6.6-cp36-cp36m-macosx_10_14_x86_64.whl


#install pip on Mac
sudo easy_install pip

Installing models

Download and unzip the following two model directories:
https://github.com/getchui/offline_sdk/releases/download/models-latest/fd_model.zip
https://github.com/getchui/offline_sdk/releases/download/models-latest/model-tfv4.zip

more SDK downloads can be found here:

https://github.com/getchui/offline_sdk/releases

Getting your credentials

Request a credentials file from the Trueface team.

Your image collection

Have a directory with the images of the people you would like to recognize
Each subfolder should be named after the person and contain their images.

Your directory structure would look like this:

collection
├── Manuel
│   ├── profile2015.png
│   └── profile.png
└── Nezare
    ├── 10.jpg
    └── 11.jpg

Write your first example

from trueface.recognition import FaceRecognizer
from trueface.video import VideoStream
import cv2


fr = FaceRecognizer(ctx='cpu',
                    fd_model_path='./fd_model',
                    fr_model_path='./model-tfv4/model.trueface',
                    params_path='./model-tfv4/model.params',
                    license='<your license key>'
                    )

fr.create_collection(folder='collection', name=collection.npz', return_features=False)

vcap = VideoStream(src=0).start()

while(True):
    frame = vcap.read()
    frame = cv2.resize(frame, (640, 480))
    bounding_boxes, points, chips = fr.find_faces(frame,
                                              return_chips=True,
                                              return_binary=True)
    if bounding_boxes is None:
            continue
    for i, chip in enumerate(chips):
        identity = fr.identify(chip,
                               threshold=0.3,
                               collection='./collection.npz')
        print(identity)
        if 'predicted_label' in identity:
            fr.draw_label(
                frame,
                (int(bounding_boxes[i][0]),
                 int(bounding_boxes[i][1])),
                identity['predicted_label'])
        fr.draw_box(frame, bounding_boxes[i])
    cv2.imshow('Trueface.ai', frame)
    if cv2.waitKey(33) == ord('q'):
        break

Run it. Don't forget to smile!

python live_face_recognition.py

# hit "q" to quit the face recognition

Updated 6 days ago

Getting started with the SDK


Suggested Edits are limited on API Reference Pages

You can only suggest edits to Markdown body content, but not to the API spec.