The gateway's product table already runs to 1009 ANSMIND and 1010 ANSGW.
The licensing library stopped at 1008, so a real ANSMIND licence could not
be named, deactivated or listed here, while every product name it did not
recognise quietly became product 1009. With 1009 now a real product, that
fallback would mint an ANSMIND trial for a typo.
ANSPRODUCTS gains ANSMIND = 1009 and ANSGW = 1010, and both are added
wherever the product table is spelled out: ActivateTrialLicense,
DeactivateLicense, ActivateLicense, ActivateLicenseWithCustomHWID and
ListLicenses, which now reports an ANSMIND and an ANSGW row like the
gateway does.
Unknown names no longer map to any id. ActivateTrialLicense returns 0, its
existing failure value, instead of generating a key. ListLicenses skips
the row. ActivateLicense and ActivateLicenseWithCustomHWID keep passing
the name through as the registration name: they never assigned an id, the
key's own validation data rejects a name it was not issued for, and the
gateway resolves an unknown product the same way.
The ANSVIS master-licence rule in LicenseVerification is untouched.
Separately, the fallback loops in ANSUtilities, ANSAWSS3 and ANSLLM asked
for product 1008 under the registration name "ANSSRT". The product is
ANSTS, so a genuine ANSTS licence could never satisfy them. Only that
string changes; the loops still stop at 1008.
Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
A .ansmodel reaching the GPU path went to ModelOptimizer, which knows one
way to open a model — unzip it — and failed on the first byte. Even past
that, the TensorRT engine only ever parsed an ONNX file, so the one thing
the format exists to prevent, a decrypted model on disk, was the only way
it could have run.
The builder now takes its bytes from memory when it has them. The path it
is given still names the plan that gets cached beside it, because a plan
is a built artefact and carries no model: the second run loads it and
never needs the ONNX at all. For a package the plan lands in the folder
the zip flow used, so a model converted from a zip reuses the plan that
zip already built.
OptimizeModelStr recognises a package and skips the unzip-and-optimise
leg entirely: the handle below it opens the package in memory and builds
the plan from the decrypted bytes, which is the same work by a shorter
road.
Still on the file path: the other TensorRT handlers (segmentation, pose,
classification). Only the YOLO detector reads a package today.
Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
This engine took the feature count from outputShape[1] unconditionally.
For a yolo26 export with end2end on — [1, 300, 6], rows of
(x1 y1 x2 y2 score class) with the suppression already inside the graph
— that means 296 classes, coordinates read as class scores, and boxes
covering the frame. No error, just nonsense, which is exactly what the
Labelling Tool produced from the same model before its decoder was
fixed.
Its sibling ANSONNXYOLO has recognised that head from the tensor shape
for a while; this one had not, and the backend marker cannot tell them
apart because it names the runtime rather than the head.
The branch fires only where the tensor cannot be a grid: the 6 must be
the last axis with a detection count before it, hundreds rather than the
thousands of anchors a two-class [1, 6, 8400] export carries.
The decoder reuses this engine's own scaleCoords rather than repeating
the letterbox arithmetic, so both heads undo the padding the same way
and agree about where a box is, and the rounding into the integral box
type is spelled out instead of left to a narrowing conversion.
NOT COMPILED. The engine layer needs CUDA and the ANSLibs tree, neither
of which exists on this machine, so this is verified by reading: the
shape rule matches the one the other three products now share, every
symbol it uses is declared in this translation unit, and the arithmetic
is delegated to the function the grid path already trusts.
Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
An engine's model has always been a path to a password-protected zip:
ANSODBase inflates it into a folder, and every engine then picks out
train_last.onnx, classes.names and model_config.json. A .ansmodel
package replaces all four with one sealed file, and this is the part
that turns it back into what the engines already understand.
ANSODBase::LoadModel and ::Initialize now recognise a .ansmodel path and
take a second route: the package is opened with the process keyring, the
model is decrypted into memory, and the classes, task and input geometry
come out of the manifest instead of loose files. Nothing is extracted,
so the unprotected model never touches the disk — which is the reason
the format exists, and it is one function's job to keep.
The engines follow it down. BasicOrtHandler gains a constructor that
takes the bytes rather than a path; it keeps a view of them, not a copy,
because the weights are in RAM either way once a session exists and a
copy would only double what every loaded model costs. The owner of the
plaintext is ANSODBase, which holds it for as long as the engine object
lives — that is what lets the DirectML recovery path rebuild a session
after a driver fault — and wipes it on teardown.
Wired through ANSONNXYOLO (and so the classification facade), ANSONNXOBB,
ANSONNXPOSE, ANSONNXSEG and YOLO12OD. YOLOOD is left alone: it loads
darknet weights and OpenCV DNN graphs, neither of which the writer
produces. A zip still loads exactly as before, on every engine.
Keys come from SetProcessModelKeys, as in ANSMINDCORE, with the same
development fallback from the environment. With none set, a package is
refused with a sentence saying so and every zip still works, so a build
made before the key ceremony runs everything except packages.
The engine layer needs CUDA to compile, so the contract it depends on is
checked where it can be: ANSModelPackage-UnitTest now opens the fixture
ANSMINDCORE wrote through the same glue ANSODBase uses, and covers the
refusal a keyless build gives. 32 checks, no failures.
Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
Every engine built its session from a file path, which is why opening an
encrypted model package means inflating it to a directory first: the
unprotected model lands on disk, is optimised, and is zipped back into a
cache. The new package format cannot avoid that from the outside — the
engines have to be able to take bytes.
ANSModelSource.h introduces a ModelSource (a path, or bytes with a name
for logs) and one MakeSession that builds from either. The six ONNX
engines — classification, OBB, pose, segmentation, YOLO12 and YOLO —
each gain a load overload taking it, with the existing string form
delegating so no caller changes. The Windows wide-path conversion and
the from-memory call now live in one place instead of the eleven copies
they were spread across; YOLOOD, which had only the Windows branch,
becomes portable as a side effect.
The factories are named rather than implicit, so a call with a plain
string literal still resolves to the path overload without ambiguity.
Not compiled here: this layer builds only where CUDA is present, so
verification on this machine was the new header compiled and run, plus a
structural check that every engine declares and defines both overloads,
calls MakeSession exactly once, and has no raw session construction
left. It needs a build on a CUDA box before it ships.
Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
The legacy display remap in FaceAttributeToJsonString rewrote most
emotions to "Attentive", which hid the v1.4 classifier's real classes.
The remap now applies ONLY to the legacy OpenVINO model's lowercase
classes (sad/happy/neutral/anger/surprise - v1.1 output unchanged);
every other name, i.e. the classes read from emotionsrecognition.names
(Angry, Fear, Happy, Neutral, Sad), passes through verbatim. A retrained
classifier with a different .names list needs no code change.
Verified on the classroom video: faces previously labelled "Attentive"
now read "Angry (100%)"; smiling faces read "Happy (100%)". Parity test
updated to check each pack against its own emotion vocabulary.
Note for client code: v1.4 deployments no longer emit "Attentive" -
anything matching that string must handle Angry/Fear/Sad instead.
Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
With the heavier v1.4 ONNX age-gender model, interval 20 benchmarks at
throughput parity with the v1.1 pack (16.8 ms / 59 fps vs 16.0 ms / 62
fps on RTX 3070, classroom.mp4, ~3.1 faces/frame) versus 19.9 ms / 50
fps at the old default of 5. Attributes refresh every ~0.8 s on a 25 fps
camera (1.6 s on stable scenes, faster when faces appear), which is
ample for age/gender/emotion; head pose and recognition still run every
frame. Deployments wanting fresher attributes can lower it at runtime
via SetANSRFAttributeInterval. Full test suite passes at the new
default; GetANSRFModelInfo reports "attribute_interval":20.
Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
New API SetANSRFAttributeInterval(Handle, frames) / UpdateAttributeInterval
(1..60, default 5) controls how often the slow attributes (age/gender +
emotions) refresh per camera; head pose and recognition are unaffected.
GetANSRFModelInfo now reports "attribute_interval". The adaptive logic's
stable-scene branch previously capped at a hardcoded 10 - it now doubles
the configured interval instead (default behaviour 10/5/2 unchanged).
Motivation: the v1.4 ViT age-gender model is heavier per attribute frame
than the old OpenVINO IR. Interval sweep on RTX 3070 (classroom.mp4,
~3.1 faces/frame) vs the v1.1 baseline at 16.0 ms / 62 fps:
interval 5 (default): 19.9 ms / 50 fps (+3.9 ms)
interval 10: 17.1 ms / 58 fps (+1.1 ms)
interval 20: 16.5 ms / 61 fps (parity)
Recommendation: default on 8 GB GPUs; interval 10 on small-VRAM machines.
ANSFR-UnitTest: --bench old|new [interval] runs the sweep.
Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
SetANSRFRecognizerModel now records the choice in the face database
(SETTINGS key RECOGNIZER_MODEL_PREF), and LoadEngine restores it when no
explicit choice was made in the current session - so a runtime switch to
ArcFace (or AdaFace) survives server restarts without re-calling the API.
Kept separate from EMBEDDING_MODEL on purpose: only an actual API call is
recorded as a preference. An automatic ArcFace fallback (pre-v1.4 zip
without adafacerecognizer.onnx) is not persisted, so upgrading such a
deployment to the v1.4 pack still gets the AdaFace default.
ANSFR-UnitTest: TestModelSwitchV14 (now also runnable via --test) gains a
simulated restart - release handle, recreate on the same database, and
assert the persisted ArcFace choice is restored and still recognizes the
enrolled user. Verified ALL PASSED.
Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
- Recognizer: adafacerecognizer.onnx (AdaFace, new default) with automatic
fallback to ansfacerecognizer.onnx (ArcFace) for pre-v1.4 zips. AdaFace
consumes BGR: new AdaFace handler in ONNXEngine skips the BGR2RGB swap,
and the TensorRT paths gate their cvtColor on m_swapRB.
- New C API: SetANSRFRecognizerModel (0=AdaFace, 1=ArcFace),
GetANSRFRecognizerModel, GetANSRFModelInfo. A live switch reloads the
recognizer and regenerates all stored embeddings from the enrolled face
crops; the generating model is persisted in a new SETTINGS table
(EMBEDDING_MODEL) so upgrading an ArcFace database to the AdaFace
default migrates automatically on LoadEngine.
- Attributes: prefer agegender.onnx (ViT: gender_logits [male,female] +
age_pred in years; also handles the single-tensor research export) and
emotionsrecognition.onnx (YOLOv11-cls, classes from .names) behind new
IAgeGenderEstimator/IEmotionsClassifier interfaces, falling back to the
legacy OpenVINO IRs. EP follows hardware: NVIDIA uses TensorRT EP with
disk-cached engines, AMD DirectML, Intel OpenVINO.
- Emotion JSON mapping: handle the new Fear class and the never-matched
surprise label (both map to Attentive).
- ANSFR-UnitTest: TestModelSwitchV14 covers default model selection, ONNX
attribute backends, enrollment, and adaface<->arcface switching.
Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
Comments out the unconditional `return 1` added in b5a88b9, so the function
runs its real body again: the argument guards (null Handle / zero-length
buffer -> -1), cv::imdecode, and ANSFacialRecognition::CheckFace with the
detector confidence threshold, isValidFace's geometry gate and the
_minFaceSize filter.
The bypass line is left in place commented rather than deleted, so it stays
easy to flip back on.
Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
CheckFaceEmbedding returns 1 unconditionally, ahead of the JPEG decode and the
CheckFace() call, so every caller is told the submitted image is acceptable.
Deliberate temporary bypass, not a fix. What stops running behind it:
- argument guards -- a null Handle or a zero-length buffer used to return -1
and now returns 1
- cv::imdecode, so an undecodable JPEG is no longer rejected
- ANSFacialRecognition::CheckFace, and with it the detector confidence
threshold, isValidFace's geometry gate (5 landmarks inside the box, roll
<= 27 deg, yaw asymmetry <= 0.5, pitch 0.15-0.75, mouth/eye ratio 0.6-1.6)
and the _minFaceSize filter
Enrollment callers that relied on this as a pre-check now accept any input.
Revert this commit to restore the checks.
Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
Enrolling a face while the recognizer engine is down used to store the
user row and silently drop the embedding: InsertUser is a pure DB write,
Feature() returns empty when uninitialized, and InsertFace's size check
misreported that as "Invalid embedding generated" — blaming the face.
The result surfaces hours later as every match returning Unknown/2.0
with nothing in the log saying why (seen on the A400: 45 users, zero
embeddings).
- ANSFRBase gains a public IsInitialized() accessor (flag existed but
was protected).
- InsertFace / InsertMultipleFaces gate on it before computing the
embedding and log the true cause: recognizer not initialized, face
NOT enrolled, fix engine errors then re-enroll.
- The residual invalid-embedding message now reports actual vs expected
size and the remaining causes (unusable crop / recognizer reloading).
- Reload() warns when the database has users but zero embeddings — the
one line that identifies stale half-enrolled databases at startup.
Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
A ServerOptimised zip is a per-GPU cache of a previous engine build. When
the engine profile changes (batch gate, TRT/CUDA upgrade), the cached
engine inside it goes stale: every re-extract (e.g. after Temp cleanup)
restores the old engine and costs a full ONNX rebuild, forever, because
the server only regenerates the zip when the file is missing.
Engine now records rebuiltFromOnnx() + engineFilePath() in
buildLoadNetwork (set only on the generate-from-ONNX branch; cache hits
and alternative-precision loads don't raise it). After a rebuild,
ANSFaceRecognizer::Initialize deletes the stale same-GPU engine variants
from the model folder and the supplied optimised zip, so the server's
next optimize pass recreates it with the fresh engine.
Safety: only zips whose parent folder is ServerOptimised/-ized qualify —
base model zips can never match. Engine purge is scoped to the
"<model>.engine.<GPU>." prefix, leaving other GPUs' engines intact on
multi-GPU machines. All deletes are best-effort (error_code); multi-GPU
pool paths never set the flag, so the purge is a no-op there.
Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
Batch-4 was tuned for 8 GB GPUs; its TRT workspace (~54 MiB per batch
unit) crowds out the other engines on smaller cards. VramCappedBatch
keeps the configured batch on 8 GB-class cards and up (threshold
7.5 GiB — 8 GB cards report ~8188 MiB) and drops to single-face batches
below that: identical results, multi-face frames just run sequentially,
~160 MiB freed on a 4 GB RTX A400. Also caps the legacy 8/32 LoadEngine
profile, whose .b32 engine (~1.7 GB workspace) would be fatal on small
cards. Initialize() and OptimizeModel() share the same call so their
profiles cannot drift.
Small cards rebuild the recognizer engine once (filename loses the .b4
suffix); 8 GB+ machines keep their cached engines unchanged.
Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
Field logs showed clusters of uploads taking exactly 20004/20007/20003 ms —
the default _idleTimeoutMs — across several workers at the same instant, then
recurring. Cause: a connection whose request failed was returned to the pool,
so a socket silently dropped by a middlebox was handed to worker after worker,
each paying the full idle timeout to rediscover it. Chilkat's autoReconnect
only covers a cleanly closed connection, not a half-open one.
Connection handling:
- DiscardConnection(): a TRANSPORT failure closes the connection instead of
pooling it (23 sites). An HTTP error status is not a transport failure - the
server answered - so those connections are still reused.
- Pooled connections idle longer than 15 s are dropped at acquire time.
- First request on a reused connection uses a short idle timeout (a quarter of
the configured one, 5 s by default); a fresh connection keeps the full one.
A dead socket now costs ~5 s once, not 20 s repeatedly.
- One upload call is capped at 30 s wall-clock. The attempt count alone was not
a time bound: 20 attempts x 20 s could block the caller for ~400 s.
- RetryLoop no longer gives up after one failed connect. Callers call Connect()
once at startup, so returning left the handle dead for the process lifetime.
Now backs off 3 s -> 30 s until connected or stopped.
- Connections carry the config generation they were built against, so a connect
completing just after SetAuthentication cleared the pool cannot leave an
unauthenticated connection behind (those uploads would 403).
- Stale per-request state is cleared on acquire: multipart uploadId/partNumber
query params, and the gzip Content-Encoding set by UploadTextData. Not
ClearAllHeaders - that wipes SigV4 state (fcc985e).
Return codes - upload exports now say whether a retry is worthwhile:
-20 permanent (bad argument, licence, or HTTP 4xx), -21 not connected yet,
-22 transient. Recorded per thread, since one handle is shared by many workers.
Success stays the only positive value, so rc == 1 and rc != 1 are unchanged.
Handle and exception codes (-1/-3/-4) made consistent across all upload
wrappers; some previously returned 0 for these.
Also fixes a misclassification this surfaced: Chilkat reports failure for an
HTTP 4xx delivered during an Expect: 100-continue exchange, so NoSuchBucket was
treated as a network error and retried 20 times before reporting "transient".
The failure path now checks the response status. Chilkat's ~2 KB error dump per
failure is compressed to one line carrying the actual S3 error code.
Verified against live S3: 14,701 uploads across 15 threads with a 150 s idle
gap, 0 failures, no call over 5 s (avg 90 ms, p95 136 ms), matching the
pre-change baseline; and all six return-code classes confirmed end to end.
Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
Verified on dual RTX 5080: 355/355 detections, both GPUs in round-robin,
zero CUDA errors. Requires TensorRT >= 10.16.1 in SharedCore (10.15.1 has
a Myelin l2cm crash when creating a context on a second Blackwell device).
1. blobFromGpuMats: thread_local GpuMat caches (tl_blob/tl_floatImg) were
device-blind — a pool thread warming GPU[1] then GPU[0] reused device-1
memory with a device-0 stream, causing an async illegal memory access
that poisoned every CUDA context (sticky 700). Track owning device and
rebuild the cache on device switch.
2. runInference: pool round-robin can dispatch to a slot on a different
GPU than the one the caller prepared inputs on. Detect foreign input
GpuMats via cudaPointerGetAttributes and migrate them through a pinned
host staging buffer (two-hop D2H+H2D; direct cross-device cudaMemcpy2D
is unsupported and GeForce has no P2P).
3. warmUp: now pins its own CUDA device before uploading dummy inputs and
returns success/failure; loadNetwork rejects engines whose warmup fails
so broken slots can never join the pool silently.
4. Blackwell builder workaround: setMaxAuxStreams(0) on SM 12.x plus an
.aux0 engine-cache suffix so pre-workaround caches rebuild.
Also: ANSFR-UnitTest gains --gpu N flag (sets CUDA_VISIBLE_DEVICES) for
single-GPU bisection, and rich diagnostics on input-copy failures.
Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
1. core/ANSLicensingSystem/ANSLicense.h:268 — added default initializers to ModelConfig POD members (inpWidth = 0, inpHeight = 0, etc.). This was the actual bug: CreateANSODHandle declares a local ModelConfig and only sets a few fields, leaving inpWidth/inpHeight as indeterminate stack memory. On your machine that memory consistently held ~80, slipping past the <=0 → 640 guard and driving the ORT session at 80×80 — which crashes YOLOv11's /model.12/Concat because 2·ceil(80/32)=6 ≠ ceil(80/16)=5.
2. modules/ANSODEngine/ANSONNXYOLO.h:75 — ONNXYOLO::setInputShape() now snaps width/height up to the next multiple of 32 (with a 64-pixel floor). Defense in depth: even if a future caller hands in a non-stride-32 size, the FPN concat alignment is preserved.
3. modules/ANSODEngine/ANSONNXYOLO.cpp — two diagnostic additions:
WarmUpEngine bails with a clear log line if the warm-up dims aren't a multiple of 32, instead of letting the model.12 error fire and mask the real cause.
transform() logs the input shape, canvas shape, source size, and dynamic flag once per session in DebugView — so any future shape-mismatch crash points at the offending HxW directly.