Sign inSign up

rizkybs70/light-object-detect

By rizkybs70

โ€ขUpdated 13 days ago

Multi-arch Light Object Detect images with YOLO and SSD MobileNet models, tested with LightNVR

Image
Internet of things
Machine learning & AI
Developer tools
0

153

rizkybs70/light-object-detect repository overview

โ Light Object Detect - Multi Model

Multi-architecture Docker images based on opensensor/light-object-detectโ , packaged with multiple object detection models and tested as an external detection backend for LightNVRโ .

Supports AMD64 and ARM64 with two image variants:

TagRuntimeIncluded Models
multi-yoloONNX RuntimeYOLOv8n, YOLO11n, YOLO11s, YOLO26n, YOLO26s
multi-mobilenetLiteRT / TFLiteSSD MobileNet V1, SSD MobileNet V2

Model selection is done at runtime through environment variables, so switching between models in the same image does not require a rebuild.

โ Features

  • Multi-architecture: linux/amd64 and linux/arm64
  • Multiple models bundled per image
  • CPU-only inference
  • REST API object detection
  • Runtime model selection
  • Configurable confidence thresholds
  • Tested with LightNVR API Detection
  • Suitable for same-host or remote inference deployment

โ ๐Ÿš€ YOLO Image

Pull:

docker pull rizkybs70/light-object-detect:multi-yolo

Included models:

ModelTypeNotes
YOLOv8nyolov8Lightweight and mature
YOLO11nyolo11Lightweight YOLO11
YOLO11syolo11Better accuracy, higher CPU usage
YOLO26nyolo26Lightweight YOLO26
YOLO26syolo26Higher accuracy for stronger CPUs

Example using YOLO26s:

docker run -d \
  --name light-object-detect \
  --restart unless-stopped \
  --log-driver=json-file \
  --log-opt max-size=5m \
  --log-opt max-file=2 \
  -p 9001:8000 \
  -e TZ=Asia/Jakarta \
  -e BACKEND=onnx \
  -e ONNX_MODEL_PATH=backends/onnx/models/yolo26s.onnx \
  -e ONNX_LABELS_PATH=backends/onnx/models/coco.txt \
  -e ONNX_CONFIDENCE_THRESHOLD=0.35 \
  -e ONNX_IOU_THRESHOLD=0.45 \
  -e ONNX_MODEL_TYPE=yolo26 \
  rizkybs70/light-object-detect:multi-yolo
โ YOLO Model Selection
YOLOv8n
ONNX_MODEL_PATH=backends/onnx/models/yolov8n.onnx
ONNX_MODEL_TYPE=yolov8

YOLO11n
ONNX_MODEL_PATH=backends/onnx/models/yolo11n.onnx
ONNX_MODEL_TYPE=yolo11

YOLO11s
ONNX_MODEL_PATH=backends/onnx/models/yolo11s.onnx
ONNX_MODEL_TYPE=yolo11

YOLO26n
ONNX_MODEL_PATH=backends/onnx/models/yolo26n.onnx
ONNX_MODEL_TYPE=yolo26

YOLO26s
ONNX_MODEL_PATH=backends/onnx/models/yolo26s.onnx
ONNX_MODEL_TYPE=yolo26

โ โšก MobileNet Image

Pull:

docker pull rizkybs70/light-object-detect:multi-mobilenet

Included models:

ModelRuntimeNotes
SSD MobileNet V1LiteRT / TFLiteLightweight, tested for low-power ARM64 deployment
SSD MobileNet V2LiteRT / TFLiteAlternative model with higher model complexity

Example using SSD MobileNet V1:

docker run -d \
  --name light-object-detect \
  --restart unless-stopped \
  --log-driver=json-file \
  --log-opt max-size=5m \
  --log-opt max-file=2 \
  -p 9001:8000 \
  -e TZ=Asia/Jakarta \
  -e BACKEND=tflite \
  -e TFLITE_MODEL_PATH=backends/tflite/models/ssd_mobilenet_v1.tflite \
  -e TFLITE_LABELS_PATH=backends/tflite/models/coco_labels.txt \
  -e TFLITE_CONFIDENCE_THRESHOLD=0.35 \
  -e TFLITE_INTERPRETER_POOL_SIZE=1 \
  -e TFLITE_NUM_THREADS=0 \
  rizkybs70/light-object-detect:multi-mobilenet

For SSD MobileNet V2, change:

TFLITE_MODEL_PATH=backends/tflite/models/ssd_mobilenet_v2.tflite
โ Interpreter Pool

The multi-mobilenet image includes a thread-safe TFLite interpreter pool to handle concurrent detection requests without sharing one interpreter instance between multiple inference threads.

For low-power devices:

TFLITE_INTERPRETER_POOL_SIZE=1
TFLITE_NUM_THREADS=0

This serializes inference and provides natural backpressure when multiple cameras submit requests at the same time.

On more powerful systems, multiple independent interpreters can be enabled:

TFLITE_INTERPRETER_POOL_SIZE=2
TFLITE_NUM_THREADS=2

Always benchmark CPU usage and inference latency before increasing these values.


โ ๐ŸŽฅ LightNVR Integration

Tested with:

https://github.com/opensensor/lightNVRโ 

Typical deployment:

IP Cameras
    |
    v
LightNVR
    |
    | HTTP Detection Request
    v
Light Object Detect
    |
    +-- ONNX Runtime -> YOLO
    |
    +-- LiteRT -> SSD MobileNet

For multi-yolo:

API Detection URI:
http://<LOD-IP>:9001/api/v1/detect

API Detection Backend:
ONNX

For multi-mobilenet:

API Detection URI:
http://<LOD-IP>:9001/api/v1/detect

API Detection Backend:
TensorFlow Lite

Detection interval and confidence threshold can be configured per stream in LightNVR.

These images use LightNVR's external API Detection feature, not the Local LiteRT engine.

โ Same Docker Host

When both containers run on the same host:

docker network create nvrnet
docker network connect nvrnet lightnvr
docker network connect nvrnet light-object-detect

LightNVR can then use:

http://light-object-detect:8000/api/v1/detect

โ ๐Ÿงช Test Detection

โ YOLO
curl -s -X POST \
  "http://127.0.0.1:9001/api/v1/detect?backend=onnx&confidence_threshold=0.35&return_image=false" \
  -F "file=@/path/to/image.jpg"
โ MobileNet
curl -s -X POST \
  "http://127.0.0.1:9001/api/v1/detect?backend=tflite&confidence_threshold=0.35&return_image=false" \
  -F "file=@/path/to/image.jpg"
โ Generate Annotated Image

YOLO example:

curl -s -X POST \
  "http://127.0.0.1:9001/api/v1/detect?backend=onnx&confidence_threshold=0.35&return_image=true" \
  -F "file=@/path/to/image.jpg" \
  | jq -r '.image.base64_data' \
  | base64 -d > detected.jpg

For MobileNet simply change:

backend=onnx

to:

backend=tflite

Health check:

curl http://127.0.0.1:9001/health

โ ๐Ÿ› ๏ธ Build It Yourself

Clone upstream:

git clone https://github.com/opensensor/light-object-detect.git
cd light-object-detect
โ YOLO

Place ONNX models under:

backends/onnx/models/

Example:

backends/onnx/models/
โ”œโ”€โ”€ coco.txt
โ”œโ”€โ”€ yolov8n.onnx
โ”œโ”€โ”€ yolo11n.onnx
โ”œโ”€โ”€ yolo11s.onnx
โ”œโ”€โ”€ yolo26n.onnx
โ””โ”€โ”€ yolo26s.onnx

Build:

docker build -t light-object-detect:multi-yolo .
โ MobileNet

Place TFLite models under:

backends/tflite/models/

Example:

backends/tflite/models/
โ”œโ”€โ”€ coco_labels.txt
โ”œโ”€โ”€ ssd_mobilenet_v1.tflite
โ””โ”€โ”€ ssd_mobilenet_v2.tflite

Build using a Dockerfile with LiteRT support:

docker build \
  -f Dockerfile.mobilenet \
  -t light-object-detect:multi-mobilenet \
  .

โ Adding More Models

โ YOLO

Additional Ultralytics models can be exported to ONNX without installing Ultralytics directly on the host:

mkdir -p .model-export

docker run --rm \
  -v "$PWD/.model-export:/work" \
  -w /work \
  ultralytics/ultralytics:latest-python-export \
  yolo export \
  model=yolo26m.pt \
  format=onnx \
  imgsz=640 \
  simplify=True \
  device=cpu

Move the generated model into:

backends/onnx/models/

Other examples include:

yolov8s
yolov8m
yolo11m
yolo11l
yolo26m
yolo26l

Use the correct ONNX_MODEL_TYPE for each family.

โ TFLite

Additional TFLite models can be placed under:

backends/tflite/models/

but model compatibility depends on the output tensor format expected by the Light Object Detect TFLite backend.

Adding an arbitrary ONNX or TFLite model does not automatically guarantee compatibility.


โ Logs

Follow logs:

docker logs -f light-object-detect

Recommended production log rotation:

--log-driver=json-file
--log-opt max-size=5m
--log-opt max-file=2

Logging can be completely disabled with:

--log-driver=none

but docker logs will no longer be available.


โ Performance Notes

For CCTV workloads, model speed alone is not enough. Camera count and detection interval directly affect request rate.

For example:

5 cameras @ 2 second interval
โ‰ˆ 2.5 requests/second

A smaller model may provide better overall system stability than a more accurate model when many cameras share the same inference host.

Monitor:

CPU usage
Load average
Memory
Temperature
Inference latency
HTTP errors
Request backlog

Benchmark with real camera frames before selecting a production model.


โ Acknowledgements

Based on:

This repository adds multi-model packaging, bundled YOLO and SSD MobileNet models, multi-architecture Docker images, and tested LightNVR deployment.

โ License

This image contains components and model weights from multiple upstream projects.

Review the licensing terms of Light Object Detect, Ultralytics, ONNX Runtime, LiteRT, and bundled model weights before redistribution or commercial use.

Tag summary

Content type

Image

Digest

sha256:4934cd927โ€ฆ

Size

195.6 MB

Last updated

13 days ago

docker pull rizkybs70/light-object-detect:multi-mobilenet