mirror of
https://github.com/blakeblackshear/frigate.git
synced 2026-02-12 22:25:24 +03:00
Updated dockerfile so it dose not download the model file.
add function to download it at runtime. update model path.
This commit is contained in:
parent
511b446631
commit
b60f4ff905
@ -77,8 +77,6 @@ FROM deps AS h8l-frigate
|
|||||||
COPY --from=h8l-wheels /h8l-wheels /deps/h8l-wheels
|
COPY --from=h8l-wheels /h8l-wheels /deps/h8l-wheels
|
||||||
COPY --from=build-hailort /hailo-wheels /deps/hailo-wheels
|
COPY --from=build-hailort /hailo-wheels /deps/hailo-wheels
|
||||||
COPY --from=build-hailort /etc/environment /etc/environment
|
COPY --from=build-hailort /etc/environment /etc/environment
|
||||||
RUN mkdir /hailo8l_models
|
|
||||||
RUN wget -O /hailo8l_models/ssd_mobilenet_v1.hef https://hailo-model-zoo.s3.eu-west-2.amazonaws.com/ModelZoo/Compiled/v2.11.0/hailo8l/ssd_mobilenet_v1.hef
|
|
||||||
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)") && \
|
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
|
echo "CC=$CC" >> /etc/environment
|
||||||
|
|
||||||
|
|||||||
@ -406,7 +406,7 @@ detectors:
|
|||||||
type: hailo8l
|
type: hailo8l
|
||||||
device: PCIe
|
device: PCIe
|
||||||
model:
|
model:
|
||||||
path: /hailo8l_models/ssd_mobilenet_v1.hef
|
path: /config/model_cache/h8l_cache/ssd_mobilenet_v1.hef
|
||||||
|
|
||||||
model:
|
model:
|
||||||
width: 300
|
width: 300
|
||||||
|
|||||||
@ -1,4 +1,6 @@
|
|||||||
import logging
|
import logging
|
||||||
|
import os
|
||||||
|
import urllib.request
|
||||||
|
|
||||||
import numpy as np
|
import numpy as np
|
||||||
from hailo_platform import (
|
from hailo_platform import (
|
||||||
@ -50,9 +52,13 @@ class HailoDetector(DetectionApi):
|
|||||||
self.h8l_model_type = detector_config.model.model_type
|
self.h8l_model_type = detector_config.model.model_type
|
||||||
self.h8l_tensor_format = detector_config.model.input_tensor
|
self.h8l_tensor_format = detector_config.model.input_tensor
|
||||||
self.h8l_pixel_format = detector_config.model.input_pixel_format
|
self.h8l_pixel_format = detector_config.model.input_pixel_format
|
||||||
|
self.model_url = "https://hailo-model-zoo.s3.eu-west-2.amazonaws.com/ModelZoo/Compiled/v2.11.0/hailo8l/ssd_mobilenet_v1.hef"
|
||||||
|
self.cache_dir = "/config/model_cache/h8l_cache"
|
||||||
|
self.expected_model_filename = "ssd_mobilenet_v1.hef"
|
||||||
output_type = "FLOAT32"
|
output_type = "FLOAT32"
|
||||||
|
|
||||||
logger.info(f"Initializing Hailo device as {self.h8l_device_type}")
|
logger.info(f"Initializing Hailo device as {self.h8l_device_type}")
|
||||||
|
self.check_and_prepare_model()
|
||||||
try:
|
try:
|
||||||
# Validate device type
|
# Validate device type
|
||||||
if self.h8l_device_type not in ["PCIe", "M.2"]:
|
if self.h8l_device_type not in ["PCIe", "M.2"]:
|
||||||
@ -99,6 +105,24 @@ class HailoDetector(DetectionApi):
|
|||||||
logger.error(f"Failed to initialize Hailo device: {e}")
|
logger.error(f"Failed to initialize Hailo device: {e}")
|
||||||
raise
|
raise
|
||||||
|
|
||||||
|
def check_and_prepare_model(self):
|
||||||
|
# Ensure cache directory exists
|
||||||
|
if not os.path.exists(self.cache_dir):
|
||||||
|
os.makedirs(self.cache_dir)
|
||||||
|
|
||||||
|
# Check for the expected model file
|
||||||
|
model_file_path = os.path.join(self.cache_dir, self.expected_model_filename)
|
||||||
|
if not os.path.isfile(model_file_path):
|
||||||
|
logger.info(
|
||||||
|
f"A model file was not found at {model_file_path}, Downloading one from {self.model_url}."
|
||||||
|
)
|
||||||
|
urllib.request.urlretrieve(self.model_url, model_file_path)
|
||||||
|
logger.info(f"A model file was downloaded to {model_file_path}.")
|
||||||
|
else:
|
||||||
|
logger.info(
|
||||||
|
f"A model file already exists at {model_file_path} not downloading one."
|
||||||
|
)
|
||||||
|
|
||||||
def detect_raw(self, tensor_input):
|
def detect_raw(self, tensor_input):
|
||||||
logger.debug("[detect_raw] Entering function")
|
logger.debug("[detect_raw] Entering function")
|
||||||
logger.debug(
|
logger.debug(
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user