Fix ANSONNXYOLO:

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.
This commit is contained in:
2026-05-01 20:24:08 +10:00
parent 1c8abf2a88
commit fc9cf9671b
4 changed files with 80 additions and 16 deletions
+22 -12
View File
@@ -266,18 +266,28 @@ namespace ANSCENTER
UNLICENSE = 3
};
struct ModelConfig {
DetectionType detectionType;
ModelType modelType;
PrecisionType precisionType;
int inpWidth;
int inpHeight;
float modelConfThreshold;
float modelMNSThreshold;
float detectionScoreThreshold;
int numKPS; // Number of pose keypoint
float kpsThreshold;
bool autoGPUDetection;
float unknownPersonThreshold;
// All POD members default-initialized. Several callers (notably
// CreateANSODHandle in ANSODEngine/dllmain.cpp) declare a local
// ModelConfig and only set a subset of fields before passing it
// to ANSODBase::Initialize. Without these defaults inpWidth /
// inpHeight enter Initialize() as indeterminate stack values; the
// existing `<=0 → 640` guard in ANSONNXYOLO::Initialize only
// catches non-positive garbage, so a small positive stack value
// (e.g. 80) would slip through and end up driving the ORT
// session at 80x80 — which crashes YOLOv11 in /model.12/Concat
// because 2*ceil(80/32) ≠ ceil(80/16) in the FPN.
DetectionType detectionType{};
ModelType modelType{};
PrecisionType precisionType{};
int inpWidth = 0;
int inpHeight = 0;
float modelConfThreshold = 0.0f;
float modelMNSThreshold = 0.0f;
float detectionScoreThreshold = 0.0f;
int numKPS = 0; // Number of pose keypoint
float kpsThreshold = 0.0f;
bool autoGPUDetection = false;
float unknownPersonThreshold = 0.0f;
int gpuOptBatchSize = 1; // The batch size which should be optimized for.
int gpuMaxBatchSize = 1; // Maximum allowable batch size
int gpuDeviceIndex = 0; // GPU device index