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 31, 2024
2 parents e19b223 + ac8ddad commit e5090cb
Show file tree
Hide file tree
Showing 8 changed files with 22 additions and 18 deletions.
7 changes: 5 additions & 2 deletions docker/tensorrt/Dockerfile.arm64
Original file line number Diff line number Diff line change
Expand Up @@ -41,8 +41,11 @@ 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 uninstall -y onnxruntime \
&& pip3 wheel --wheel-dir=/trt-wheels -r /requirements-tensorrt.txt
ADD https://nvidia.box.com/shared/static/9aemm4grzbbkfaesg5l7fplgjtmswhj8.whl /tmp/onnxruntime_gpu-1.15.1-cp39-cp39-linux_aarch64.whl

RUN pip3 uninstall -y onnxruntime-openvino \
&& pip3 wheel --wheel-dir=/trt-wheels -r /requirements-tensorrt.txt \
&& pip3 install --no-deps /tmp/onnxruntime_gpu-1.15.1-cp39-cp39-linux_aarch64.whl

FROM build-wheels AS trt-model-wheels
ARG DEBIAN_FRONTEND
Expand Down
3 changes: 1 addition & 2 deletions docker/tensorrt/requirements-arm64.txt
Original file line number Diff line number Diff line change
@@ -1,2 +1 @@
cuda-python == 11.7; platform_machine == 'aarch64'
onnxruntime @ https://nvidia.box.com/shared/static/9aemm4grzbbkfaesg5l7fplgjtmswhj8.whl; platform_machine == 'aarch64'
cuda-python == 11.7; platform_machine == 'aarch64'
6 changes: 3 additions & 3 deletions docs/docs/configuration/genai.md
Original file line number Diff line number Diff line change
Expand Up @@ -31,15 +31,15 @@ cameras:
:::warning
Using Ollama on CPU is not recommended, high inference times make using generative AI impractical.
Using Ollama on CPU is not recommended, high inference times and a lack of support for multi-modal parallel requests will make using Generative AI impractical.
:::
[Ollama](https://ollama.com/) allows you to self-host large language models and keep everything running locally. It provides a nice API over [llama.cpp](https://github.com/ggerganov/llama.cpp). It is highly recommended to host this server on a machine with an Nvidia graphics card, or on a Apple silicon Mac for best performance.
Most of the 7b parameter 4-bit vision models will fit inside 8GB of VRAM. There is also a [docker container](https://hub.docker.com/r/ollama/ollama) available.
Most of the 7b parameter 4-bit vision models will fit inside 8GB of VRAM. There is also a [Docker container](https://hub.docker.com/r/ollama/ollama) available.
Parallel requests also come with some caveats. See the [Ollama documentation](https://github.com/ollama/ollama/blob/main/docs/faq.md#how-does-ollama-handle-concurrent-requests).
Parallel requests also come with some caveats, and multi-modal parallel requests are currently not supported by Ollama. Depending on your hardware and the number of requests made to the Ollama API, these limitations may prevent Ollama from being an optimal solution for many users. See the [Ollama documentation](https://github.com/ollama/ollama/blob/main/docs/faq.md#how-does-ollama-handle-concurrent-requests).
### Supported Models
Expand Down
7 changes: 3 additions & 4 deletions frigate/api/media.py
Original file line number Diff line number Diff line change
Expand Up @@ -917,7 +917,7 @@ def grid_snapshot(
ret, jpg = cv2.imencode(".jpg", frame, [int(cv2.IMWRITE_JPEG_QUALITY), 70])

return Response(
jpg.tobytes,
jpg.tobytes(),
media_type="image/jpeg",
headers={"Cache-Control": "no-store"},
)
Expand Down Expand Up @@ -1453,7 +1453,6 @@ def preview_thumbnail(file_name: str):

return Response(
jpg_bytes,
# FIXME: Shouldn't it be either jpg or webp depending on the endpoint?
media_type="image/webp",
headers={
"Content-Type": "image/webp",
Expand Down Expand Up @@ -1482,7 +1481,7 @@ def label_thumbnail(request: Request, camera_name: str, label: str):
ret, jpg = cv2.imencode(".jpg", frame, [int(cv2.IMWRITE_JPEG_QUALITY), 70])

return Response(
jpg.tobytes,
jpg.tobytes(),
media_type="image/jpeg",
headers={"Cache-Control": "no-store"},
)
Expand Down Expand Up @@ -1535,6 +1534,6 @@ def label_snapshot(request: Request, camera_name: str, label: str):
_, jpg = cv2.imencode(".jpg", frame, [int(cv2.IMWRITE_JPEG_QUALITY), 70])

return Response(
jpg.tobytes,
jpg.tobytes(),
media_type="image/jpeg",
)
7 changes: 7 additions & 0 deletions frigate/config/camera/record.py
Original file line number Diff line number Diff line change
Expand Up @@ -94,3 +94,10 @@ class RecordConfig(FrigateBaseModel):
enabled_in_config: Optional[bool] = Field(
default=None, title="Keep track of original state of recording."
)

@property
def event_pre_capture(self) -> int:
return max(
self.alerts.pre_capture,
self.detections.pre_capture,
)
2 changes: 1 addition & 1 deletion frigate/events/external.py
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@ def create_manual_event(
"sub_label": sub_label,
"score": score,
"camera": camera,
"start_time": now,
"start_time": now - camera_config.record.event_pre_capture,
"end_time": end,
"thumbnail": thumbnail,
"has_clip": camera_config.record.enabled and include_recording,
Expand Down
6 changes: 1 addition & 5 deletions frigate/record/maintainer.py
Original file line number Diff line number Diff line change
Expand Up @@ -299,16 +299,12 @@ async def validate_and_move_segment(
# if it doesn't overlap with an event, go ahead and drop the segment
# if it ends more than the configured pre_capture for the camera
else:
pre_capture = max(
record_config.alerts.pre_capture,
record_config.detections.pre_capture,
)
camera_info = self.object_recordings_info[camera]
most_recently_processed_frame_time = (
camera_info[-1][0] if len(camera_info) > 0 else 0
)
retain_cutoff = datetime.datetime.fromtimestamp(
most_recently_processed_frame_time - pre_capture
most_recently_processed_frame_time - record_config.event_pre_capture
).astimezone(datetime.timezone.utc)
if end_time < retain_cutoff:
Path(cache_path).unlink(missing_ok=True)
Expand Down
2 changes: 1 addition & 1 deletion web/src/components/overlay/detail/ObjectLifecycle.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -509,7 +509,7 @@ export default function ObjectLifecycle({
containScroll: "keepSnaps",
dragFree: true,
}}
className="w-full max-w-[72%] md:max-w-[85%]"
className="max-w-[72%] md:max-w-[85%]"
setApi={setThumbnailApi}
>
<CarouselContent
Expand Down

0 comments on commit e5090cb

Please sign in to comment.