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!

Simple High Availability setup

If you want to load balance your HTTP requests to our REST API across multiple nodes you can base your setup off of this very simple configuration example. This is meant as a starting point since your architecture might have more specific requirements.

Create a shared file volume on the docker host machine

docker volume create collections

Start 4 trueface nodes mapped to a different port each

docker run -dit -p 8085:8080 \
    --name trueface_tfv3cpu1 \
    --mount source=collections,target=/collections trueface/tfv3-cpu
docker run -dit -p 8086:8080 \
    --name trueface_tfv3cpu2 \
    --mount source=collections,target=/collections trueface/tfv3-cpu
docker run -dit -p 8087:8080 \
    --name trueface_tfv3cpu3 \
    --mount source=collections,target=/collections trueface/tfv3-cpu
docker run -dit -p 8088:8080 \
    --name trueface_tfv3cpu4 \
    --mount source=collections,target=/collections trueface/tfv3-cpu

Copy over your credentials file

docker cp creds.json trueface_tfv3cpu1:/
docker cp creds.json trueface_tfv3cpu2:/
docker cp creds.json trueface_tfv3cpu3:/
docker cp creds.json trueface_tfv3cpu4:/

Start the app

docker exec -dit trueface_tfv3cpu1 sh -c 'pm2 start app'
docker exec -dit trueface_tfv3cpu2 sh -c 'pm2 start app'
docker exec -dit trueface_tfv3cpu3 sh -c 'pm2 start app'
docker exec -dit trueface_tfv3cpu4 sh -c 'pm2 start app'

You now have 4 Trueface Vision Box nodes up and running!

Let's make this HA!

Install nginx on your host machine, the one that is running the docker containers

sudo apt install -y nginx jq

Configure NginX for load balancing

Use the following configuration in /etc/nginx/sites-enabled/default

upstream trueface {

server {
	listen 80 default_server;
	listen [::]:80 default_server;

	# add your SSL configuration here
	# listen 443 ssl default_server;
	# listen [::]:443 ssl default_server;
	# Note: You should disable gzip for SSL traffic.
	# See:
	# Read up on ssl_ciphers to ensure a secure configuration.
	# See:
	# Self signed certs generated by the ssl-cert package
	# Don't use them in a production server!
	# include snippets/snakeoil.conf;

	root /var/www/html;

	server_name _;

	location / {
            proxy_pass http://trueface;

Reload NginX

sudo service nginx reload

You are done! Let's test this!

Enroll a new image in a collection

# let's get some images
curl -s > enroll_george.jpg
curl -s > identify_george.jpg

# make sure you have your creds.json file in the same
# directory you are running this command
curl \
	-H "content-type: application/json" \
	--data "{ \"namespace\": \"celebrities\", \"collection_id\": \"actors\", \"label\": \"George\", \"image\": { \"data\": \"$(base64 -w0 enroll_george.jpg)\" } }" \
{"execution_time": 0.6958839893341064,
 "message": "match performed succesfully",
 "data": "xbIsveWT... <long base64 string truncated>",
 "success": true}

If you look at the filesystem on each node, you will see the collection getting created or updated.
The collection is located on the shared volume we mounted when we created the container so it will be updated across all your nodes.

docker exec -it trueface_tfv3cpu1 sh -c 'find /collections'

Identify an image

curl \
	-H "content-type: application/json" \
	--data "{ \"namespace\": \"celebrities\", \"collection_id\": \"actors\", \"image\": { \"data\": \"$(base64 -w0 identify_george.jpg)\" } }" \
{"execution_time": 2.1204941272735596, 
 "message": "Identify preformed successfully successfully", 
 "data": [{
       "confidence": 0.6769804316535968, 
       "predicted_label": "George", 
       "bounding_box": [393.3023436367512, 125.14740616083145, 771.620245963335, 659.4643105119467, 0.9999953508377075]}, 
 "success": true}

Updated 2 months ago

Simple High Availability setup

Suggested Edits are limited on API Reference Pages

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