Skip to content

Commit

Permalink
Merge branch 'blakeblackshear:dev' into dev
Browse files Browse the repository at this point in the history
  • Loading branch information
weitheng authored Oct 30, 2024
2 parents e901371 + c7a4220 commit e19b223
Show file tree
Hide file tree
Showing 6 changed files with 35 additions and 12 deletions.
1 change: 1 addition & 0 deletions .github/pull_request_template.md
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
- [ ] New feature
- [ ] Breaking change (fix/feature causing existing functionality to break)
- [ ] Code quality improvements to existing code
- [ ] Documentation Update

## Additional information

Expand Down
7 changes: 4 additions & 3 deletions docker/tensorrt/Dockerfile.arm64
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,8 @@ ARG DEBIAN_FRONTEND
# Use a separate container to build wheels to prevent build dependencies in final image
RUN apt-get -qq update \
&& apt-get -qq install -y --no-install-recommends \
python3.9 python3.9-dev \
wget build-essential cmake git \
python3.9 python3.9-dev \
wget build-essential cmake git \
&& rm -rf /var/lib/apt/lists/*

# Ensure python3 defaults to python3.9
Expand Down Expand Up @@ -41,7 +41,8 @@ RUN --mount=type=bind,source=docker/tensorrt/detector/build_python_tensorrt.sh,t
&& TENSORRT_VER=$(cat /etc/TENSORRT_VER) /deps/build_python_tensorrt.sh

COPY docker/tensorrt/requirements-arm64.txt /requirements-tensorrt.txt
RUN pip3 wheel --wheel-dir=/trt-wheels -r /requirements-tensorrt.txt
RUN pip3 uninstall -y onnxruntime \
&& pip3 wheel --wheel-dir=/trt-wheels -r /requirements-tensorrt.txt

FROM build-wheels AS trt-model-wheels
ARG DEBIAN_FRONTEND
Expand Down
1 change: 1 addition & 0 deletions docker/tensorrt/requirements-arm64.txt
Original file line number Diff line number Diff line change
@@ -1 +1,2 @@
cuda-python == 11.7; platform_machine == 'aarch64'
onnxruntime @ https://nvidia.box.com/shared/static/9aemm4grzbbkfaesg5l7fplgjtmswhj8.whl; platform_machine == 'aarch64'
6 changes: 3 additions & 3 deletions docs/docs/configuration/object_detectors.md
Original file line number Diff line number Diff line change
Expand Up @@ -22,14 +22,14 @@ Frigate supports multiple different detectors that work on different types of ha
- [ONNX](#onnx): OpenVINO will automatically be detected and used as a detector in the default Frigate image when a supported ONNX model is configured.

**Nvidia**
- [TensortRT](#nvidia-tensorrt-detector): TensorRT can run on Nvidia GPUs, using one of many default models.
- [ONNX](#onnx): TensorRT will automatically be detected and used as a detector in the `-tensorrt` Frigate image when a supported ONNX model is configured.
- [TensortRT](#nvidia-tensorrt-detector): TensorRT can run on Nvidia GPUs and Jetson devices, using one of many default models.
- [ONNX](#onnx): TensorRT will automatically be detected and used as a detector in the `-tensorrt` or `-tensorrt-jp(4/5)` Frigate images when a supported ONNX model is configured.

**Rockchip**
- [RKNN](#rockchip-platform): RKNN models can run on Rockchip devices with included NPUs.

**For Testing**
- [CPU Detector (not recommended for actual use](#cpu-detector-not-recommended): Use a CPU to run tflite model, this is not recommended and in most cases OpenVINO can be used in CPU mode with better results.
- [CPU Detector (not recommended for actual use](#cpu-detector-not-recommended): Use a CPU to run tflite model, this is not recommended and in most cases OpenVINO can be used in CPU mode with better results.

:::

Expand Down
30 changes: 25 additions & 5 deletions docs/docs/configuration/semantic_search.md
Original file line number Diff line number Diff line change
Expand Up @@ -43,9 +43,32 @@ The text model is used to embed tracked object descriptions and perform searches

Differently weighted CLIP models are available and can be selected by setting the `model_size` config option:

:::tip
```yaml
semantic_search:
enabled: True
model_size: small
```

- Configuring the `large` model employs the full Jina model and will automatically run on the GPU if applicable.
- Configuring the `small` model employs a quantized version of the model that uses much less RAM and runs faster on CPU with a very negligible difference in embedding quality.

The CLIP models are downloaded in ONNX format, which means they will be accelerated using GPU hardware when available. This depends on the Docker build that is used. See [the object detector docs](../configuration/object_detectors.md) for more information.
### GPU Acceleration

The CLIP models are downloaded in ONNX format, and the `large` model can be accelerated using GPU hardware, when available. This depends on the Docker build that is used.

:::info

If the correct build is used for your GPU and the `large` model is configured, then the GPU will be detected and used automatically.

**AMD**
- ROCm will automatically be detected and used for semantic search in the `-rocm` Frigate image.

**Intel**
- OpenVINO will automatically be detected and used as a detector in the default Frigate image.

**Nvidia**
- Nvidia GPUs will automatically be detected and used as a detector in the `-tensorrt` Frigate image.
- Jetson devices will automatically be detected and used as a detector in the `-tensorrt-jp(4/5)` Frigate image.

:::

Expand All @@ -55,9 +78,6 @@ semantic_search:
model_size: small
```

- Configuring the `large` model employs the full Jina model and will automatically run on the GPU if applicable.
- Configuring the `small` model employs a quantized version of the model that uses much less RAM and runs faster on CPU with a very negligible difference in embedding quality.

## Usage and Best Practices

1. Semantic search is used in conjunction with the other filters available on the Search page. Use a combination of traditional filtering and semantic search for the best results.
Expand Down
2 changes: 1 addition & 1 deletion frigate/config/config.py
Original file line number Diff line number Diff line change
Expand Up @@ -667,7 +667,7 @@ def load(cls, **kwargs):
migrate_frigate_config(config_path)

# Finally, load the resulting configuration file.
with open(config_path, "a+") as f:
with open(config_path, "a+" if new_config else "r") as f:
# Only write the default config if the opened file is non-empty. This can happen as
# a race condition. It's extremely unlikely, but eh. Might as well check it.
if new_config and f.tell() == 0:
Expand Down

0 comments on commit e19b223

Please sign in to comment.