This repository aims at replicating the Helm/Kubernetes-based vision pipeline for local development as closely as possible. It might not always be up-to-date...
A longer explanation of the architecture and the technical setup can be found in ../doc/README.md.
- Change
VIDEO_PATHin.envto a suitable video file (showing cars) on your machine - Run
docker compose up(the first time may take a while, some images are quite big) - Change into
../tools - Create and activate a virtualenv (
python3 -m venv .venv && source .venv/bin/activate) - Install dependencies (
pip install -r requirements.txt) - Run
python watch.pyand choose a stream to watch
If you do not get a consistent framerate or your machine gets slow, try lowering the max_fps value on the video-source (i.e. 5 fps) in ./video-source-py/video-source-stream1.settings.yaml. Also, you might want to try setting up your Nvidia GPU, if you have one (see below).
If you want to have database output, i.e. store the tracker output in a Postgres DB (which is what prod deployments do), you can replace step 3 from above to docker compose -f docker-compose-with-db.yaml up. You'll find a pgadmin web UI to browse the database at http://localhost:5050.
All relevant components (Redis and Postgres) have healthchecks in place, s.t. docker compose up should "just work".
In order to have more control you might want to start all components separately (e.g. in tmux panes).
For a working (basic) pipeline you need (at least) the following components running (which is what docker compose up will give you by default):
- redis
- video-source-py
- object-detector
- object-tracker
- streaming-server
For the video source you either need to have a video stream readily available (and configure its uri accordingly) or you can use the streaming-server compose service, which will play a video file on demand (that you have to mount, that is what VIDEO_PATH in .env is for).
Caution: Do not try to mount the video file directly into the video source container. This is currently not supported as the video source relies on the source to pace itself, the video source will read frames as fast as possible!
If you have a Nvidia GPU in your system, you can try changing the device on object-detector and -tracker from cpu to cuda. No guarantees whether that will work!
The ../tools/watch.py script can be used to visually look into the data flows within the pipeline. See more detailed description it its readme.
- Install
nvidia-container-toolkit(see https://docs.nvidia.com/datacenter/cloud-native/container-toolkit/latest/install-guide.html#installing-with-apt) - Configure NVIDIA container toolkit (see https://docs.nvidia.com/datacenter/cloud-native/container-toolkit/latest/install-guide.html#configuring-docker)
- Test if the Nvidia runtime works (https://docs.nvidia.com/datacenter/cloud-native/container-toolkit/latest/sample-workload.html#running-a-sample-workload-with-docker)
- Enable GPU support for compose services, where you want it (e.g.
object-detector) Add the following section to each service that needs GPU support:deploy: resources: reservations: devices: - driver: nvidia count: all capabilities: [gpu]
- Configure application to use Nvidia CUDA
- In the case of
object-detectorchangemodel.devicein its settings file (by default at./object-detector/object-detector.settings.yaml) fromcputocuda
- In the case of