Skip to content

Launch FaceStream#

There are two ways to launch FaceStream — manual and automatic using a Docker Compose script.

Use the hyperlinks below to go to the instructions for the required launch method:

Launch FaceStream manually#

Note. Perform these actions only if you are going to launch FaceStream manually. If you are going to launch FaceStream using the Docker Compose script, go to "Launch FaceStream using Docker Compose".

Upload settings to LUNA Configurator#

The main settings of LUNA Streams and FaceStream should be set in the Configurator service after its launch.
FaceEngine and Runtime settings can be set both in the Configurator service and in the configuration files "faceengine.conf" and "runtime.conf" and passed during the FaceStream container launching.

If necessary, you can use configuration files instead of the Configurator service settings and transfer them during container launching (for more information, see the "Use FaceStream with configuration files" section of the administrator manual).

To upload LUNA Streams and FaceStream settings into the Configurator service, you should use the configuration migration mechanism.

docker run \
-v /etc/localtime:/etc/localtime:ro \
-v /tmp/logs/streams:/srv/logs \
--entrypoint=/bin/bash \
--rm \
--network=host \
dockerhub.visionlabs.ru/luna/streams-configs:v.1.2.1 \
-c "python3 -m streams_configs.migrate head --config_db_url postgres://luna:luna@127.0.0.1:5432/luna_configurator"

Here:

  • python3 -m streams_configs.migrate — Migration script.
  • --config_db_url postgres://luna:luna@127.0.0.1:5432/luna_configurator — The "luna_configurator" database address flag.

Prepare LUNA Streams database#

To launch FaceStream, you need to launch the LUNA Streams service by creating and initializing a database for it. This service is not included in the LUNA PLATFORM 5 distribution, so it should be launched separately.

Create LUNA Streams database#

Create a database for LUNA Streams:

docker exec -i postgres psql -U luna -c "CREATE DATABASE luna_streams;"

Allow the user to log in to the database:

docker exec -i postgres psql -U luna -c "GRANT ALL PRIVILEGES ON DATABASE luna_streams TO luna;"

Activate PostGIS:

docker exec -i postgres psql -U luna luna_streams -c "CREATE EXTENSION postgis;"

Initialize LUNA Streams database#

Initialize the data in the LUNA Streams database:

docker run -v /etc/localtime:/etc/localtime:ro \
--rm \
--network=host \
dockerhub.visionlabs.ru/luna/luna-streams:v.1.2.1 \
python3 ./base_scripts/db_create.py --luna-config http://localhost:5070/1

Launch LUNA Streams container#

The container is launched with the following command:

docker run \
--env=CONFIGURATOR_HOST=127.0.0.1 \
--env=CONFIGURATOR_PORT=5070 \
--env=PORT=5160 \
--env=WORKER_COUNT=1 \
--env=RELOAD_CONFIG=1 \
--env=RELOAD_CONFIG_INTERVAL=10 \
-v /etc/localtime:/etc/localtime:ro \
-v /tmp/logs/streams:/srv/logs \
--name=luna-streams \
--restart=always \
--detach=true \
--network=host \
dockerhub.visionlabs.ru/luna/luna-streams:v.1.2.1

To check if the service started correctly, you can perform a GET request http://127.0.0.1:5160/version. The response should return the LUNA Streams version v.1.2.1.

Launch FaceStream container#

The following launch commands use the mount parameters of the faceengine.conf and runtime.conf configuration files:

  • -v /var/lib/fs/fs-current/extras/conf/configs/faceengine.conf:/srv/facestream/data/faceengine.conf \ — this parameter allows you to use FaceEngine settings from the "faceengine.conf" configuration file.
  • -v /var/lib/fs/fs-current/extras/conf/configs/runtime.conf:/srv/facestream/data/runtime.conf \ — this parameter allows you to use runtime settings from the "runtime.conf" configuration file.

Important! Parameters can be specified either via the Configurator service (see the "Settings in LUNA Configurator service" section of the administrator's guide) or in configuration files simultaneously. If the parameters match, the value specified in the Configurator service takes precedence.

The Configurator service allows you to configure only basic user settings. For more detailed settings, you should use a configuration file.

Launch FaceStream container using CPU#

The container is launched as follows:

docker run \
--env=CONFIGURATOR_HOST=127.0.0.1 \
--env=CONFIGURATOR_PORT=5070 \
-v /var/lib/fs/fs-current/extras/conf/configs/faceengine.conf:/srv/facestream/data/faceengine.conf \
-v /var/lib/fs/fs-current/extras/conf/configs/runtime.conf:/srv/facestream/data/runtime.conf \
-v /etc/localtime:/etc/localtime:ro \
-v /tmp/logs/facestream:/srv/logs \
--env=PORT=34569 \
--detach=true \
--restart=always \
--name=facestream \
--network=host \
dockerhub.visionlabs.ru/luna/facestream:v.5.2.15

For a description of the remaining parameters and launching keys, see the "Launching keys" section.

To verify that the application was launched correctly, you can perform a GET request http://127.0.0.1:34569/version. The response should return the FaceStream v.5.2.15.

Launch FaceStream container using GPU#

Note. Use this command only if you are going to use FaceStream with GPU.

Before launching FaceStream in GPU mode, additional dependencies should be installed (see "Install GPU dependencies" section).

Before starting the FaceStream container with GPU, it is required to enable GPU for calculations in the FaceStream settings using the "enable_gpu_processing" parameter (see the "FaceStream configuration" section in the administrator manual).

docker run \
--env=CONFIGURATOR_HOST=127.0.0.1 \
--env=CONFIGURATOR_PORT=5070 \
-v /var/lib/fs/fs-current/extras/conf/configs/faceengine.conf:/srv/facestream/data/faceengine.conf \
-v /var/lib/fs/fs-current/extras/conf/configs/runtime.conf:/srv/facestream/data/runtime.conf \
-v /etc/localtime:/etc/localtime:ro \
-v /tmp/logs/facestream:/srv/logs \
--env=PORT=34569 \
--gpus device=0 \
--detach=true \
--restart=always \
--name=facestream \
--network=host \
dockerhub.visionlabs.ru/luna/facestream:v.5.2.15

Here --gpus device=0 is the parameter specifies the used GPU device and enables GPU utilization. A single GPU can be utilized per FaceStream instance. Multiple GPU utilization per instance is not available.

For a description of the remaining parameters and launching keys, see the "Launching keys" section.

To verify that the application was launched correctly, you can perform a GET request http://127.0.0.1:34569/version. The response should return the FaceStream v.5.2.15.

Launch FaceStream using Docker Compose#

The Docker Compose script:

  • Loads LUNA Streams and FaceStream settings into Configurator.

  • Creates and initializes the LUNA Streams database.

  • Launches the LUNA Streams and FaceStream.

  • Is tested using the default LUNA Streams and FaceStream configurations.

  • Is not intended to be used for FaceStream scaling:

    • It is not used for the deployment of FaceStream services on several servers.

    • It is not used for deployment and balancing of several FaceStream services on a single service.

  • Supports GPU utilization for FaceStream calculations.

  • Does not provide the possibility to use external database for LUNA Streams already installed on the server.

  • Does not perform migrations from previous FaceStream versions and updates from the previous FaceStream build.

See the "docker-compose.yml" file and other files in the "example-docker" directory for the information about launched services and performed actions.

You can write your scenario that deploys and configures all the required services. This document does not include information about scenario creation or tutorial for Docker usage. Please refer to the Docker documentation to find more information about Docker and Docker Compose:

https://docs.docker.com

Launch FaceStream command#

Go to the Docker Compose folder:

cd /var/lib/fs/fs-current/example-docker

Make sure that FS container are not launched before executing the script. An error will occur if you try to run a container with the same name as an existing container. If one or several LP containers are launched, you should stop them using the docker container rm -f <container_name> command. To stop all the containers, use docker container rm -f $(docker container ls -aq).

To launch FaceStream with GPU using Docker Compose, you need to follow the steps in "Install GPU dependencies".

Launch Docker Compose:

You should be logged in the VisionLabs registry (see section "Login to registry")

./start_facestream.sh --configurator_address=127.0.0.1

--configurator_address=127.0.0.1 — LUNA Configurator service address

Check the state of launched Docker containers.

docker ps

The list of streams is available at http://127.0.0.1:34569/api/1/streams/. Viewing the stream in the browser is available at http://127.0.0.1:34569/api/1/streams/preview/<stream_id>.