Delivery/Package Verification

Property Value
Category Object Detection (Package and Parcel Detection)
Base Model YOLO26 (Ultralytics)
Source Framework PyTorch (Ultralytics)
Supported Precisions FP32, FP16, INT8 (mixed-precision)
Inference Engine OpenVINO
Hardware CPU, GPU, NPU
Detected Class(es) package (COCO backpack/handbag/suitcase, relabeled)

Overview

Delivery/Package Verification is a Metro Analytics use case that detects and counts delivery parcels, bags, and luggage items in camera feeds. It is built on YOLO26, a state-of-the-art real-time object detector trained on the COCO dataset, quantized to INT8 and filtered at runtime to the COCO classes that best match delivery parcels -- backpack, handbag, and suitcase -- which are all relabeled to a single package class in the output.

These COCO classes provide reliable coverage for typical delivery and package verification scenarios (for example a courier carrying a cardboard box) without requiring a custom-trained model. For label or text reading on packages, pair this with the ocr-text-recognition use case.

Typical Metro deployments include:

  • Delivery Dock Monitoring -- verify parcels placed or removed at a loading area.
  • Abandoned Luggage Detection -- flag unattended bags on platforms.
  • Package Counting -- count parcels on a conveyor or at a drop-off zone.
  • Theft Prevention -- alert when a package disappears from a monitored area.

Available variants: yolo26n, yolo26s, yolo26m, yolo26l, yolo26x. Smaller variants (yolo26n, yolo26s) are recommended for high-FPS edge deployment; larger variants improve recall for distant or partially occluded packages.


Prerequisites

Create and activate a Python virtual environment before running the scripts:

python3 -m venv .venv --system-site-packages
source .venv/bin/activate

Note: The --system-site-packages flag is required so the virtual environment can access the system-installed OpenVINO and DLStreamer Python packages.


Getting Started

Download and Quantize Model

Run the provided script to download, export to OpenVINO IR, and optionally quantize:

chmod +x export_and_quantize.sh
./export_and_quantize.sh

This exports the default yolo26n model in FP16 precision.

Optional: Select a Different Variant or Precision

./export_and_quantize.sh yolo26n FP32   # full-precision
./export_and_quantize.sh yolo26n INT8   # quantized
./export_and_quantize.sh yolo26s        # larger variant, default FP16

The script performs the following steps:

  1. Installs dependencies (openvino, ultralytics; adds nncf for INT8).
  2. Downloads a sample test image (test.jpg) and a sample test video (test_video.mp4).
  3. Downloads the PyTorch weights and exports to OpenVINO IR.
  4. (INT8 only) Quantizes the model using NNCF post-training quantization.

Output files:

  • yolo26n_openvino_model/ -- FP32 or FP16 OpenVINO IR model directory.
  • yolo26n_package_int8.xml / .bin -- INT8 quantized model (only when INT8 is selected).

Precision / Device Compatibility

Precision CPU GPU NPU
FP32 Yes Yes No
FP16 Yes Yes Yes
INT8 Yes Yes Yes

OpenVINO Sample

The sample below runs YOLO26 inference on the sample video, filters detections to the delivery-package classes (COCO backpack, handbag, suitcase, all shown as package), annotates each frame, and writes the result to output_openvino.mp4 while printing the package count per frame. Frames are letterboxed (aspect-ratio-preserving resize with padding) before inference so the input matches how DLStreamer's gvadetect preprocesses. YOLO26 is end-to-end (NMS-free), so no manual non-maximum suppression is needed. Change the device string to run on CPU, GPU, or NPU.

import cv2
import numpy as np
import openvino as ov

# COCO classes used as delivery-package proxies; all shown as "package".
PACKAGE_CLASS_IDS = {24, 26, 28}  # backpack, handbag, suitcase
PACKAGE_LABEL = "package"
BOX_COLOR = (0, 200, 0)
CONF_THRESHOLD = 0.25
INPUT_SIZE = 640
INPUT_VIDEO = "test_video.mp4"

core = ov.Core()
model = core.read_model("yolo26n_openvino_model/yolo26n.xml")

# Change device to "GPU" or "NPU" to run on integrated GPU or NPU.
compiled = core.compile_model(model, "CPU")


def letterbox(image, size=INPUT_SIZE):
    """Resize keeping aspect ratio and pad to a square (matches gvadetect)."""
    h, w = image.shape[:2]
    ratio = min(size / h, size / w)
    nw, nh = int(round(w * ratio)), int(round(h * ratio))
    resized = cv2.resize(image, (nw, nh))
    canvas = np.full((size, size, 3), 114, dtype=np.uint8)
    pad_x, pad_y = (size - nw) // 2, (size - nh) // 2
    canvas[pad_y:pad_y + nh, pad_x:pad_x + nw] = resized
    return canvas, ratio, pad_x, pad_y


cap = cv2.VideoCapture(INPUT_VIDEO)
fps = cap.get(cv2.CAP_PROP_FPS) or 30.0
width = int(cap.get(cv2.CAP_PROP_FRAME_WIDTH))
height = int(cap.get(cv2.CAP_PROP_FRAME_HEIGHT))
writer = cv2.VideoWriter(
    "output_openvino.mp4", cv2.VideoWriter_fourcc(*"mp4v"), fps, (width, height))

frame_idx = 0
while True:
    ok, frame = cap.read()
    if not ok:
        break
    frame_idx += 1

    padded, ratio, pad_x, pad_y = letterbox(frame, INPUT_SIZE)
    blob = cv2.cvtColor(padded, cv2.COLOR_BGR2RGB).astype(np.float32) / 255.0
    blob = blob.transpose(2, 0, 1)[np.newaxis, ...]  # NCHW

    # YOLO26 end-to-end output: [1, 300, 6] = [x1, y1, x2, y2, confidence, class_id]
    output = compiled([blob])[compiled.output(0)][0]
    mask = (output[:, 4] >= CONF_THRESHOLD) & np.isin(
        output[:, 5].astype(int), list(PACKAGE_CLASS_IDS))
    dets = output[mask]

    for det in dets:
        # Undo the letterbox padding and scaling to map boxes back to the frame.
        x1 = int((det[0] - pad_x) / ratio)
        y1 = int((det[1] - pad_y) / ratio)
        x2 = int((det[2] - pad_x) / ratio)
        y2 = int((det[3] - pad_y) / ratio)
        conf = float(det[4])
        label = f"{PACKAGE_LABEL} {conf:.2f}"
        cv2.rectangle(frame, (x1, y1), (x2, y2), BOX_COLOR, 2)
        cv2.putText(frame, label, (x1, y1 - 5),
                    cv2.FONT_HERSHEY_SIMPLEX, 0.6, BOX_COLOR, 2)

    writer.write(frame)
    print(f"Frame {frame_idx}: Packages detected: {len(dets)}", flush=True)

cap.release()
writer.release()

Device targets:

  • "CPU" -- default, works on all Intel platforms.
  • "GPU" -- Intel integrated or discrete GPU.
  • "NPU" -- Intel NPU (validate with benchmark_app -d NPU).

Expected Output

OpenVINO expected output

DLStreamer Sample

The pipeline below runs the FP16 YOLO26 detector on the sample video via gvadetect, renders only package bounding boxes using gvawatermark with displ-cfg=show-roi=package, saves the annotated result to output_dlstreamer.mp4, and prints the package count per frame.

Notes on running this sample:

  • Use the FP16 IR (yolo26n_openvino_model/yolo26n.xml) together with the coco_package_labels.txt label map produced by export_and_quantize.sh. It relabels the COCO backpack/handbag/suitcase classes to package, so gvadetect emits a single package class and gvawatermark renders a package label.

  • Export PYTHONPATH so the DLStreamer Python module is importable:

    source /opt/intel/openvino_2026/setupvars.sh
    source /opt/intel/dlstreamer/scripts/setup_dls_env.sh
    export PYTHONPATH=/opt/intel/dlstreamer/python:\
    /opt/intel/dlstreamer/gstreamer/lib/python3/dist-packages:${PYTHONPATH:-}
    
import gi

gi.require_version("Gst", "1.0")
gi.require_version("GstAnalytics", "1.0")
from gi.repository import Gst, GLib, GstAnalytics

Gst.init([])

INPUT_VIDEO = "test_video.mp4"
PACKAGE_LABELS = {"package"}

# For CPU: change device=GPU to device=CPU.
# For NPU: change device=GPU to device=NPU (batch-size=1, nireq=4 recommended).
pipeline_str = (
    f"filesrc location={INPUT_VIDEO} ! decodebin3 ! "
    "videoconvert ! "
    "gvadetect model=yolo26n_openvino_model/yolo26n.xml "
    "labels-file=coco_package_labels.txt "
    "device=GPU "
    "threshold=0.25 ! queue ! "
    "gvawatermark displ-cfg=show-roi=package ! "
    "videoconvert ! video/x-raw,format=I420 ! "
    "openh264enc bitrate=4000000 ! h264parse ! "
    "mp4mux ! filesink name=sink location=output_dlstreamer.mp4"
)
pipeline = Gst.parse_launch(pipeline_str)


def on_buffer(pad, info):
    buf = info.get_buffer()
    rmeta = GstAnalytics.buffer_get_analytics_relation_meta(buf)
    if rmeta is None:
        return Gst.PadProbeReturn.OK
    packages = []
    idx = 1
    while True:
        ok, od = rmeta.get_od_mtd(idx)
        if not ok:
            break
        label = GLib.quark_to_string(od.get_obj_type())
        if label in PACKAGE_LABELS:
            packages.append(label)
        idx += 1
    if packages:
        print(f"Packages detected: {len(packages)} ({', '.join(packages)})",
              flush=True)
    return Gst.PadProbeReturn.OK


sink = pipeline.get_by_name("sink")
sink.get_static_pad("sink").add_probe(Gst.PadProbeType.BUFFER, on_buffer)

pipeline.set_state(Gst.State.PLAYING)
bus = pipeline.get_bus()
bus.timed_pop_filtered(
    Gst.CLOCK_TIME_NONE,
    Gst.MessageType.EOS | Gst.MessageType.ERROR,
)
pipeline.set_state(Gst.State.NULL)

Device targets:

  • device=GPU -- default in the sample code.
  • device=CPU -- change device=GPU to device=CPU.
  • device=NPU -- change device=GPU to device=NPU; use batch-size=1 and nireq=4 for best NPU utilization.

Expected Output

DLStreamer expected output


License

Licensed under the MIT License. See LICENSE for details.

References

Downloads last month

-

Downloads are not tracked for this model. How to track
Inference Providers NEW
This model isn't deployed by any Inference Provider. 🙋 Ask for provider support

Collection including Intel/delivery-package-verification