Getting Started with Visionbox

The Trueface Visionboxes offer state of the art computer vision in a self hosted REST API. Start with a Trueface Visionbox in one command:

Start a new container:

sudo docker run -e "TOKEN=<your token>" -v "$(pwd)"/collections:/collections -p 8080:8080 -it trueface/visionbox:latest

The start command will download the image and start the API. You are then ready to call and start using your API.

In case you want to use all the available CPU's on the host machine:

sudo docker run -e "TOKEN=<your token>" -e "WORKERS=<number of CPU's you want to utilize>" -v "$(pwd)"/collections:/collections -p 8080:8080 -it trueface/visionbox:latest

In case you want to use the GPU Version

Make sure you have installed the NVIDIA driver and Docker 19.03 or newer for your Linux distribution Note that you do not need to install the CUDA toolkit on the host, but the driver needs to be installed.

Running a GPU Image

sudo docker run --gpus=all -e "TOKEN=<your token>" -v "$(pwd)"/collections:/collections -p 8080:8080 -it trueface/visionbox-gpu:latest

Your API is ready! Let's test this!

  • First we will enroll a person's photo in our collection. We will also pass a label under which we want the person to be recognized (usually their name but this could be random ID as well)

  • Then we will run an identify call to see that the SDK recognized the person and returns the correct label

Get the test images

  • Download two images, one to enroll the person and a different one to later identify them.
curl -s https://pbs.twimg.com/profile_images/704366711739387904/dBlzfG_S_400x400.jpg > enroll_george.jpg
curl -s https://www.etonline.com/sites/default/files/styles/max_1280x720/public/images/2013-05/640_george_clooney_20130120_159272928.jpg > identify_george.jpg

# install the requests package
pip install requests

Enroll a new image in a collection

  • Create a test_enroll.py file with the following content
import base64
import json
import requests
import sys

license_token = '<your token>'

BASEURL = 'http://0.0.0.0:8080'

url = BASEURL + "/enroll"

data = {
    "source": base64.b64encode(open("enroll_george.jpg", 'rb').read()),
    "namespace": "celebrities",
    "collection_id": "actors",
    "label": "George"
}

request = requests.post(url, json=data)

print(request.text)

Then run python test_enroll.py

{"execution_time": 0.4712061882019043, 
  "message": "enroll successful", 
  "data": "data": "xbIsveWT... <long base64 string truncated>",
  "success": true
}

Identify an image

Create a test_identify.py file with the following content

import base64
import json
import requests
import sys

license_token = '<your token>'

BASEURL = 'http://0.0.0.0:8080'

url = BASEURL + "/identify"

data = {
    "source": base64.b64encode(open("identify_george.jpg").read()),
    "namespace": "celebrities",
    "collection_id": "actors"
}

request = requests.post(url, json=data)

print(request.text)
{"execution_time": 2.1204941272735596, 
 "message": "Identify performed successfully", 
 "data": [{
       "confidence": 0.6769804316535968, 
       "predicted_label": "George", 
       "bounding_box": [393.3023436367512, 125.14740616083145, 771.620245963335, 659.4643105119467, 0.9999953508377075]}, 
 "success": true}

Your Turn!

Head over to the API Reference and start building something great!

Getting Started with Visionbox


Suggested Edits are limited on API Reference Pages

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