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 the GPU Version

Using Visionbox-gpu Images requies Nvidia-Docker. To install Nvidia-Docker2

sudo apt-get install nvidia-docker2
sudo pkill -SIGHUP dockerd

Nvidia-Docker installation guide

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.