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
hawkeye217 authored Oct 30, 2024
2 parents 9a9dca0 + 89ca085 commit be5f5eb
Show file tree
Hide file tree
Showing 26 changed files with 160 additions and 265 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
4 changes: 2 additions & 2 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -34,14 +34,14 @@ jobs:
STABLE_TAG=${BASE}:stable
PULL_TAG=${BASE}:${BUILD_TAG}
docker run --rm -v $HOME/.docker/config.json:/config.json quay.io/skopeo/stable:latest copy --authfile /config.json --multi-arch all docker://${PULL_TAG} docker://${VERSION_TAG}
for variant in standard-arm64 tensorrt tensorrt-jp4 tensorrt-jp5 rk; do
for variant in standard-arm64 tensorrt tensorrt-jp4 tensorrt-jp5 rk h8l rocm; do
docker run --rm -v $HOME/.docker/config.json:/config.json quay.io/skopeo/stable:latest copy --authfile /config.json --multi-arch all docker://${PULL_TAG}-${variant} docker://${VERSION_TAG}-${variant}
done
# stable tag
if [[ "${BUILD_TYPE}" == "stable" ]]; then
docker run --rm -v $HOME/.docker/config.json:/config.json quay.io/skopeo/stable:latest copy --authfile /config.json --multi-arch all docker://${PULL_TAG} docker://${STABLE_TAG}
for variant in standard-arm64 tensorrt tensorrt-jp4 tensorrt-jp5 rk; do
for variant in standard-arm64 tensorrt tensorrt-jp4 tensorrt-jp5 rk h8l rocm; do
docker run --rm -v $HOME/.docker/config.json:/config.json quay.io/skopeo/stable:latest copy --authfile /config.json --multi-arch all docker://${PULL_TAG}-${variant} docker://${STABLE_TAG}-${variant}
done
fi
44 changes: 14 additions & 30 deletions docker/hailo8l/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,9 @@

ARG DEBIAN_FRONTEND=noninteractive

# NOTE: also update user_installation.sh
ARG HAILO_VERSION=4.19.0

# Build Python wheels
FROM wheels AS h8l-wheels

Expand All @@ -19,6 +22,7 @@ RUN pip3 wheel --wheel-dir=/h8l-wheels -c /requirements-wheels.txt -r /requireme
# Build HailoRT and create wheel
FROM wheels AS build-hailort
ARG TARGETARCH
ARG HAILO_VERSION

SHELL ["/bin/bash", "-c"]

Expand Down Expand Up @@ -50,55 +54,35 @@ RUN PYTHON_VERSION=$(python3 --version 2>&1 | awk '{print $2}' | cut -d. -f1,2)
RUN . /etc/environment && \
git clone https://github.com/hailo-ai/hailort.git /opt/hailort && \
cd /opt/hailort && \
git checkout v4.18.0 && \
cmake -H. -Bbuild -DCMAKE_BUILD_TYPE=Release -DHAILO_BUILD_PYBIND=1 -DPYBIND11_PYTHON_VERSION=${PYTHON_VERSION} && \
git checkout v${HAILO_VERSION} && \
cmake -H. -Bbuild -DCMAKE_BUILD_TYPE=Release && \
cmake --build build --config release --target libhailort && \
cmake --build build --config release --target _pyhailort && \
cp build/hailort/libhailort/bindings/python/src/_pyhailort.cpython-${PYTHON_VERSION_NO_DOT}-$(if [ $TARGETARCH == "amd64" ]; then echo 'x86_64'; else echo 'aarch64'; fi )-linux-gnu.so hailort/libhailort/bindings/python/platform/hailo_platform/pyhailort/ && \
cp build/hailort/libhailort/src/libhailort.so hailort/libhailort/bindings/python/platform/hailo_platform/pyhailort/

RUN ls -ahl /opt/hailort/build/hailort/libhailort/src/
RUN ls -ahl /opt/hailort/hailort/libhailort/bindings/python/platform/hailo_platform/pyhailort/

# Remove the existing setup.py if it exists in the target directory
RUN rm -f /opt/hailort/hailort/libhailort/bindings/python/platform/setup.py

# Copy generate_wheel_conf.py and setup.py
COPY docker/hailo8l/pyhailort_build_scripts/generate_wheel_conf.py /opt/hailort/hailort/libhailort/bindings/python/platform/generate_wheel_conf.py
COPY docker/hailo8l/pyhailort_build_scripts/setup.py /opt/hailort/hailort/libhailort/bindings/python/platform/setup.py

# Run the generate_wheel_conf.py script
RUN python3 /opt/hailort/hailort/libhailort/bindings/python/platform/generate_wheel_conf.py
cmake --build build --config release --target hailortcli && \
cmake --build build --config release --target install

# Create a wheel file using pip3 wheel
RUN cd /opt/hailort/hailort/libhailort/bindings/python/platform && \
python3 setup.py bdist_wheel --dist-dir /hailo-wheels

RUN mkdir -p /rootfs/usr/local/lib /rootfs/usr/local/bin && \
cp /usr/local/lib/libhailort.so* /rootfs/usr/local/lib && \
cp /usr/local/bin/hailortcli /rootfs/usr/local/bin

# Use deps as the base image
FROM deps AS h8l-frigate
ARG HAILO_VERSION

# Copy the wheels from the wheels stage
COPY --from=h8l-wheels /h8l-wheels /deps/h8l-wheels
COPY --from=build-hailort /hailo-wheels /deps/hailo-wheels
COPY --from=build-hailort /etc/environment /etc/environment
RUN CC=$(python3 -c "import sysconfig; import shlex; cc = sysconfig.get_config_var('CC'); cc_cmd = shlex.split(cc)[0]; print(cc_cmd[:-4] if cc_cmd.endswith('-gcc') else cc_cmd)") && \
echo "CC=$CC" >> /etc/environment
COPY --from=build-hailort /rootfs/ /

# Install the wheels
RUN pip3 install -U /deps/h8l-wheels/*.whl
RUN pip3 install -U /deps/hailo-wheels/*.whl

RUN . /etc/environment && \
mv /usr/local/lib/python${PYTHON_VERSION}/dist-packages/hailo_platform/pyhailort/libhailort.so /usr/lib/${CC} && \
cd /usr/lib/${CC}/ && \
ln -s libhailort.so libhailort.so.4.18.0

# Copy base files from the rootfs stage
COPY --from=rootfs / /

# Set environment variables for Hailo SDK
ENV PATH="/opt/hailort/bin:${PATH}"
ENV LD_LIBRARY_PATH="/usr/lib/$(if [ $TARGETARCH == "amd64" ]; then echo 'x86_64'; else echo 'aarch64'; fi )-linux-gnu:${LD_LIBRARY_PATH}"

# Set workdir
WORKDIR /opt/frigate/
67 changes: 0 additions & 67 deletions docker/hailo8l/pyhailort_build_scripts/generate_wheel_conf.py

This file was deleted.

111 changes: 0 additions & 111 deletions docker/hailo8l/pyhailort_build_scripts/setup.py

This file was deleted.

4 changes: 2 additions & 2 deletions docker/hailo8l/user_installation.sh
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ else
fi

# Clone the HailoRT driver repository
git clone --depth 1 --branch v4.18.0 https://github.com/hailo-ai/hailort-drivers.git
git clone --depth 1 --branch v4.19.0 https://github.com/hailo-ai/hailort-drivers.git

# Build and install the HailoRT driver
cd hailort-drivers/linux/pcie
Expand All @@ -38,7 +38,7 @@ cd ../../
if [ ! -d /lib/firmware/hailo ]; then
sudo mkdir /lib/firmware/hailo
fi
sudo mv hailo8_fw.4.18.0.bin /lib/firmware/hailo/hailo8_fw.bin
sudo mv hailo8_fw.*.bin /lib/firmware/hailo/hailo8_fw.bin

# Install udev rules
sudo cp ./linux/pcie/51-hailo-udev.rules /etc/udev/rules.d/
Expand Down
2 changes: 1 addition & 1 deletion docker/main/rootfs/usr/local/go2rtc/create_config.py
Original file line number Diff line number Diff line change
Expand Up @@ -165,7 +165,7 @@
birdseye: dict[str, any] = config.get("birdseye")

input = f"-f rawvideo -pix_fmt yuv420p -video_size {birdseye.get('width', 1280)}x{birdseye.get('height', 720)} -r 10 -i {BIRDSEYE_PIPE}"
ffmpeg_cmd = f"exec:{parse_preset_hardware_acceleration_encode(ffmpeg_path, config.get('ffmpeg', {}).get('hwaccel_args'), input, '-rtsp_transport tcp -f rtsp {output}')}"
ffmpeg_cmd = f"exec:{parse_preset_hardware_acceleration_encode(ffmpeg_path, config.get('ffmpeg', {}).get('hwaccel_args', ''), input, '-rtsp_transport tcp -f rtsp {output}')}"

if go2rtc_config.get("streams"):
go2rtc_config["streams"]["birdseye"] = ffmpeg_cmd
Expand Down
29 changes: 24 additions & 5 deletions docs/docs/configuration/semantic_search.md
Original file line number Diff line number Diff line change
Expand Up @@ -43,9 +43,31 @@ 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.

:::

Expand All @@ -55,9 +77,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/comms/mqtt.py
Original file line number Diff line number Diff line change
Expand Up @@ -133,7 +133,7 @@ def _on_connect(
"""Mqtt connection callback."""
threading.current_thread().name = "mqtt"
if reason_code != 0:
if reason_code == "Server Unavailable":
if reason_code == "Server unavailable":
logger.error(
"Unable to connect to MQTT server: MQTT Server unavailable"
)
Expand Down
Loading

0 comments on commit be5f5eb

Please sign in to comment.