Visual Density

Visual Density

What is it?

The Trueface Visual Density Visionbox (TFVD) is a computer vision based crowd counting and analysis solution. TFVD is containerized, utilizes offline licensing, and features a simple REST API that can be used from any language, with no prior knowledge in computer vision or AI.

What can it do?

  • ๐Ÿงพ Count thousands of objects instantly from any perspective
  • ๐Ÿ—พ Return a density map representing the spatial distribution of objects

How Does it Work?

TFVD utilizes artificial intelligence and computer vision to instantly count dense objects and analyze their spatial distribution. Returning a visual density and a crowd count estimate for the image. Simply post an image to your self hosted API to process it.

How to get started?

โ€ฃ
๐Ÿ’พ Available Images

CPU

trueface/visual-density

GPU

trueface/visual-density-gpu

โ€ฃ
โ–ถ๏ธ Run API

CPU

sudo docker run -e "TOKEN=$TOKEN" -v /data:/data -p 8080:8080 -d --name visual-density -it trueface/visual-density

GPU

sudo docker run --gpus all -e "TOKEN=$TOKEN" -v /data:/data -p 8080:8080 -d --name visual-density -it trueface/visual-density-gpu
โ€ฃ
๐Ÿ“„ API Reference
โ€ฃ
Run

Path: /run

Method: POST

Payload

input_type: folder or payload. type: image - reserved for future use. input: input folder path in mounted folder or array of base64 encoded images. When passing a folder the API will process all images in the folder. output: output folder path in mounted folder.

Payload Example

{
    "input_type":"folder",
    "type": "image",
    "input": "/data/input",
    "output": "/data/output"
}

Sample Response

{
    "data": [
        {
            "count": 139,
            "density_heatmap": "/9j/4AAQSkZJRgABAQAAAQABAAD/2wBDAAIBAQEBAQIBAQECAgICAgQDAgICAgUEBAMEBgUGBgYFBgYGBwkIBgcJBwYGCAsICQoKCgoKBggLDAsKDAkKCgr/wAALCABEAAMBAREA/8QAHwAAAQUBAQEBAQEAAAAAAAAAAAECAwQFBgcICQoL/8QAtRAAAgEDAwIEAwUFBAQAAAF9AQIDAAQRBRIhMUEGE1FhByJxFDKBkaEII0KxwRVS0fAkM2JyggkKFhcYGRolJicoKSo0NTY3ODk6Q0RFRkdISUpTVFVWV1hZWmNkZWZnaGlqc3R1dnd4eXqDhIWGh4iJipKTlJWWl5iZmqKjpKWmp6ipqrKztLW2t7i5usLDxMXGx8jJytLT1NXW19jZ2uHi4+Tl5ufo6erx8vP09fb3+Pn6/9oACAEBAAA/APxK/bSW3T9sX4spaMDEPiZrwiI7r/aE+P4V7f7I+g6U39sy1lsf2wPitZTKA8PxK11HAOQCNQnBp/7aX2s/tjfFk377p/8AhZmvec2c5f8AtCfJ/PNP/bdmjuf20Pi7cQtlJPihr7KfUHUZyKg/bJmiuP2vvirPAMI/xJ11kGOx1CcioP2tCx/ap+Jhbr/wsHWc/wDgdNVj9soQj9r74rC2OY/+Fk675Z/2f7Qnx+lL+2aYG/bB+K7Wy4jPxK13yx6L/aE+P0qH9rzj9rH4oDOf+Lia3/6XzV//2Q==",
            "output": "results_e7cf8e0e-5275-46b1-b000-fb9f5c03ce77.json"
        }
    ],
    "message": "Predict count successfully!",
    "status": "OK",
    "statusCode": 200
}
โ€ฃ
Status

Path: /status

Method: GET

Sample Response

{
    "data": null,
    "message": "Your running TrueFace visual density",
    "status": "OK",
    "statusCode": 200
}
โ€ฃ
Shutdown

Path: /shutdown

Method: GET

Sample Response:

{
    "data": null,
    "message": "exiting",
    "status": "Accepted",
    "statusCode": 202
}
โ€ฃ
๐Ÿ“ซ Postman Collection
โ€ฃ
๐Ÿ Python Example
import base64
import requests

api_url = "http://localhost:8080"

headers = {
    "content-type": "application/json"
  }
  data = {
    "input_type":"payload",
    "type": "image",
    "input": [],
    "output": "data/output",
  }

  image = "test.jpg"

  data["input"].append(base64.b64encode(open("test.jpg", "rb").read()))
  r = requests.post(api_url + "/run", headers=headers, json=data)
  print(r.json())
โ€ฃ
๐ŸŒฒ Environment Variables
  • TOKEN license token obtained from Trueface.
  • WORKERS & THREADS Trueface utilizes Gunicorn. The number of Gunicorn workers and threads per worker can be arbitrarily set by the user using environment variables. Ex:
  • sudo docker run -e "WORKERS=2" -e "THREADS=10" -e "TOKEN=$TOKEN" -v $pwd/data:/data -p 8080:8080 -d --name visual-density -it trueface/visual-density
โ€ฃ
๐Ÿ“ General Use Guidelines
  • Trained and tested on images ranging from 10 to ~15,000 individuals. We recommend processing images with similar expected object counts.
โ€ฃ
๐Ÿ’ฏ Performance
โ€ฃ
๐Ÿ‘จ๐Ÿฝโ€๐Ÿ”ง Change log