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. The exception is the FaceEngine settings, which are set in the configuration file "faceengine.conf" and transferred during the launch of the FaceStream container.
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).
FaceStream and LUNA Streams settings are uploaded into the Configurator in different ways.
Upload LUNA Streams settings#
To upload LUNA Streams 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 \
--rm \
--entrypoint='' \
--network=host \
dockerhub.visionlabs.ru/lunastreams-configs:v.0.5.17 \
python3 -m streams_configs.migrate head --config_db_url postgres://luna:luna@127.0.0.1:5432/luna_configurator
--config_db_url postgres://luna:luna@127.0.0.1:5432/luna_configurator
- luna_configurator
database address flag
Upload FaceStream settings#
FaceStream settings are located in a special file "facestream_dump.json". To upload these settings into the Configurator service, you should use the "load_dump.py" script.
The "load_dump.py" script requires Python version 2.x or 3.x. If version 2.x is installed, then the script should be run using the
python
command. If version 3.x is installed, then the script should be run using thepython3
command.
- Go to the directory with script and dump file:
cd /var/lib/fs/fs-current/example-docker/luna_configurator/dumps/
- Run the script to upload FaceStream settings into the Configurator service, specifying the installed version of Python (the command below gives an example of running the script for Python version 3.x):
python3 -m load_dump --dump-file=facestream_dump.json --luna-config=http://127.0.0.1:5070/1
All necessary parameters will be automatically added to the Configurator service.
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 \
-v /tmp/logs/streams:/srv/logs \
dockerhub.visionlabs.ru/lunaluna-streams:v.0.5.17 \
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/lunaluna-streams:v.0.5.17
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.0.5.17.
Launch FaceStream container#
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/lunafacestream:v.5.1.18
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 {}.
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/lunafacestream:v.5.1.18
--gpus device=0
- 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 {}.
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:
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, usedocker 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 athttp://127.0.0.1:34569/api/1/streams/preview/<stream_id>
.