Skip to content
imaged

Person re-identification

OSNet-AIN x1.0

Recognizes the same person again across frames and cameras from their appearance: a 512-number descriptor per person, from a 2.2-million-parameter network.

Non-commercial research onlyperson re-identificationreidosnettrackingmulti-cameratorchreidnon-commercial
Choose a variant

About this model

Re-identification answers "have I seen this person before?". Give it a crop of a person from a detector and it returns 512 numbers describing their appearance (clothing, colors, build, carried bags); two crops of the same person give similar descriptors, two different people give different ones. Compare descriptors with cosine similarity to follow people through a scene, keep track of them when they are hidden for a moment, or match them across cameras.

OSNet (omni-scale network) is a small network built for this task; the AIN variant adds instance normalization so it holds up on cameras it was not trained on. This pack is torchreid's osnet_ain_x1_0 trained on the MSMT17 dataset (all of it), the setting that generalizes best to new cameras among the published models.

Slab stretches the crop to 128 x 256 pixels as torchreid does; the app crops each detector box with Frame.crop (no copy).

What you can build

  • Count people across several cameras without counting the same person twice
  • Keep a person's identity in a tracker through occlusions and missed detections
  • Measure how people move through a space (shops, stations) without storing images

The same people 2 seconds later

f16
Input
A busy crossing at Yonge and Dundas, Toronto

Raysonho @ Open Grid Scheduler / Grid Engine, CC0, https://commons.wikimedia.org/wiki/File:DiagonalCrosswalkYongeDundas.webm (frames)

Output
Two frames 2 seconds apart, each person and their match outlined in the same color and number
People found by YOLO26n in two frames 2 s apart (8 and 8), described by OSNet-AIN on Apple Neural Engine (FP16) and paired by cosine similarity, most similar first, each person used once. Pairs at 0.7 or more are drawn: 0.88, 0.74, 0.80. Every drawn pair is the same person; pairs below 0.7 in these frames were often not.

The same people 2 seconds later

f16
Input
A busy crossing at Yonge and Dundas, Toronto

Raysonho @ Open Grid Scheduler / Grid Engine, CC0, https://commons.wikimedia.org/wiki/File:DiagonalCrosswalkYongeDundas.webm (frames)

Output
Two frames 2 seconds apart, each person and their match outlined in the same color and number
People found by YOLO26n in two frames 2 s apart (8 and 7), described by OSNet-AIN on Apple Neural Engine (FP16) and paired by cosine similarity, most similar first, each person used once. Pairs at 0.7 or more are drawn: 0.70, 0.75, 0.86, 0.79, 0.89. Every drawn pair is the same person; pairs below 0.7 in these frames were often not.

Variants & downloads

Choose the build for your app

Model files are hosted on Google Drive. Large files may open a confirmation page before downloading.

Standard

Slab

Weights stored in FP16: half the size of FP32, the same descriptors (see Accuracy).

Platforms: macos · android

osnet-ain-x1-0-f16.slab

7.4 MB · Hosted download

Download
SHA-256 checksum
e8d146d1c5bbfaca16982c310e477f7bdb04728815a9efa85ad9fc26a3eadb13

LICENSE-torchreid.txt

1 KB

Download
SHA-256 checksum
59489828935ddd817677a2477b849222502fe1c365c2fc69387ac14afe379b9e
Conversion details
command
git clone https://github.com/KaiyangZhou/deep-person-reid && git -C deep-person-reid checkout f8cd150fdf77e8d9e1ed143b7f308c2c609ded50 gdown 1SigwBE6mPdqiJMqhuIY4aqC7--5CsMal -O osnet_ain_x1_0_msmt17.pth python -c "import importlib.util, torch; s = importlib.util.spec_from_file_location('osnet_ain', 'deep-person-reid/torchreid/models/osnet_ain.py'); o = importlib.util.module_from_spec(s); s.loader.exec_module(o); m = o.osnet_ain_x1_0(num_classes=1, pretrained=False, loss='softmax'); sd = torch.load('osnet_ain_x1_0_msmt17.pth', map_location='cpu', weights_only=False); sd = sd.get('state_dict', sd); m.load_state_dict({k.replace('module.', ''): w for k, w in sd.items() if not k.replace('module.', '').startswith('classifier')}, strict=False); torch.onnx.export(m.eval(), torch.zeros(1, 3, 256, 128), 'model.onnx', input_names=['image'], output_names=['features'], opset_version=17, dynamo=False)" slab-load convert model.onnx model.slab --input image=1x3x256x128 --meta task=embed --meta resize=stretch --meta interpolation=bilinear --meta antialias:bool=true --meta normalize=imagenet --meta color=rgb slab-load quantize model.slab osnet-ain-x1-0-f16.slab --f16 slab-load meta set osnet-ain-x1-0-f16.slab default_backend.macos=npu

Integration examples

Python

python

import slab

cfg = slab.Config(cache_dir="/tmp/slab_cache", license=open("license.slablic.txt").read())
detector = slab.Session(cfg, "yolo26n-f16.slab")      # any person detector
reid = slab.Session(cfg, "osnet-ain-x1-0-f16.slab")

def people(path):
    frame = slab.Frame.open(path)
    out = []
    for b in detector.run(slab.Input(frame=frame)).boxes(score_threshold=0.5, iou_threshold=1.0):
        if b.label != "person":
            continue
        x, y = int(max(b.x1, 0)), int(max(b.y1, 0))
        crop = frame.crop(x, y, int(min(b.x2, frame.width)) - x, int(min(b.y2, frame.height)) - y)
        d = reid.run(slab.Input(frame=crop))
        d.normalize_l2()
        out.append(d)
    return out

before, after = people("frame1.jpg"), people("frame2.jpg")
for i, p in enumerate(before):
    best = max(range(len(after)), key=lambda j: p.cosine_similarity(after[j]))
    s = p.cosine_similarity(after[best])
    print(i, "->", best if s >= 0.7 else "no match", round(s, 2))

Device & backend compatibility

Pack default: macos / NPU. Fastest per person by far: 1.2 ms against 6.9 ms on the GPU, which matters with many people per frame. It prepares in about 2 s, once.

Available execution backends for OSNet-AIN x1.0
PlatformEngineStatusPrecision
apple

CPU

CPU

Supported

Measured on macOS.

f32
apple

Metal

GPU

Supported

Measured on macOS.

f32
apple

Apple Neural Engine

NPU

Supported

Measured on macOS. The default; computes in FP16.

f16
android

CPU

CPU

Supported

Measured on a Samsung Galaxy S23 Ultra (Snapdragon 8 Gen 2, Adreno 740), Android 17.

f32
android

Vulkan

GPU

Supported

Measured on a Samsung Galaxy S23 Ultra (Snapdragon 8 Gen 2, Adreno 740), Android 17.

f32
android

Qualcomm Hexagon NPU (QNN)

NPU

Supported

Measured on a Samsung Galaxy S23 Ultra (Snapdragon 8 Gen 2, Adreno 740), Android 17. The NPU computes in FP16 (the int8 pack's weights are widened to FP16).

f16

Performance

Results depend on the device, runtime, and test conditions. Each measurement keeps its own context.

Mac with Apple M1 Max

Slab · CPU

macOS 26.6.2

22.5 ms

Measured time · scope below

f16Session open (ms): 2 Platform: macos Runs: 100 Input: 1, 3, 256, 128 Measured: 2026-10-30

Median of 100 warm runs of the model (Slab's run time). One person cropped from a 1920 x 1080 frame (Frame.crop, resizing included): 23.29 ms median of 100.

Mac with Apple M1 Max

Slab · GPU

macOS 26.6.2

4.7 ms

Measured time · scope below

f16Session open (ms): 100 Platform: macos Runs: 100 Input: 1, 3, 256, 128 Measured: 2026-10-30

Median of 100 warm runs of the model (Slab's run time). One person cropped from a 1920 x 1080 frame (Frame.crop, resizing included): 6.93 ms median of 100.

Mac with Apple M1 Max

Slab · NPU

macOS 26.6.2

0.9 ms

Measured time · scope below

f16Session open (ms): 1731 Platform: macos Runs: 100 Input: 1, 3, 256, 128 Measured: 2026-10-30

Median of 100 warm runs of the model (Slab's run time). One person cropped from a 1920 x 1080 frame (Frame.crop, resizing included): 1.15 ms median of 100.

Samsung Galaxy S23 Ultra (Snapdragon 8 Gen 2)

Slab · CPU

Android 17

39.7 ms

Measured time · scope below

f16Session open (ms): 38 Platform: android Runs: 100 Input: 1, 3, 256, 128 Measured: 2026-11-06

Median of 100 warm runs of the model (Slab's run time). open_ms: opening the session. Peak memory (resident) after the runs: 68 MB.

Samsung Galaxy S23 Ultra (Snapdragon 8 Gen 2)

Slab · GPU

Android 17

17.1 ms

Measured time · scope below

f16Session open (ms): 49 Platform: android Runs: 100 Input: 1, 3, 256, 128 Measured: 2026-11-06

Median of 100 warm runs of the model (Slab's run time). open_ms: opening the session with the GPU programs already in the cache folder (the first open on a device compiles them, about 0.3 s more). Peak memory (resident) after the runs: 78 MB.

Samsung Galaxy S23 Ultra (Snapdragon 8 Gen 2)

Slab · NPU

Android 17

2.0 ms

Measured time · scope below

f16Session open (ms): 262 Platform: android Runs: 100 Input: 1, 3, 256, 128 Measured: 2026-11-06

Median of 100 warm runs of the model (Slab's run time). open_ms: opening the session, including preparing the model for the Hexagon NPU. Peak memory (resident) after the runs: 73 MB.

Accuracy checks

macos · CPU · f16

The upstream PyTorch model (torchreid at f8cd150fdf77) with torchreid's test transform (PIL bilinear resize to 256 x 128, ImageNet normalization) on 148 people found by the YOLO26n pack in 28 frames of a CC0 street video (one frame every 2 s)

Cosine similarity to the upstream descriptor 0.999990 on average, 0.999940 at worst. Matching each person to the most similar person 2 s later gives the same choice as upstream for 142 of 142.

macos · GPU · f16

The upstream PyTorch model (torchreid at f8cd150fdf77) with torchreid's test transform (PIL bilinear resize to 256 x 128, ImageNet normalization) on 148 people found by the YOLO26n pack in 28 frames of a CC0 street video (one frame every 2 s)

Cosine similarity to the upstream descriptor 0.999990 on average, 0.999940 at worst. Matching each person to the most similar person 2 s later gives the same choice as upstream for 142 of 142.

macos · NPU · f16

The upstream PyTorch model (torchreid at f8cd150fdf77) with torchreid's test transform (PIL bilinear resize to 256 x 128, ImageNet normalization) on 148 people found by the YOLO26n pack in 28 frames of a CC0 street video (one frame every 2 s)

Cosine similarity to the upstream descriptor 0.999911 on average, 0.999787 at worst. Matching each person to the most similar person 2 s later gives the same choice as upstream for 142 of 142.

android · NPU · f16

Slab's CPU engine (FP32) on the same 1920 x 1080 photo

Cosine similarity of the output with the CPU's: 0.99780.

Before you choose this model

  • Training data for non-commercial research (see License).
  • Descriptors of people are personal data under laws such as the GDPR: get legal advice before storing or matching them, and do not use the model to identify people.
  • Appearance only: a change of clothes, a coat taken off or very different lighting breaks it; it is not face recognition.
  • Similarity needs a threshold of your own: in our street footage, pairs at 0.7 or more were the same person and pairs below were often not.
  • It needs a person detector first, and small crops (under about 90 pixels tall) describe people poorly.
  • On the Neural Engine the first open takes about 2 s to prepare the model.