fix(YOLO12OD): decode an end-to-end head instead of reading it as a grid
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>
This commit is contained in:
@@ -59,6 +59,15 @@ namespace ANSCENTER {
|
||||
std::vector<Ort::Value>& outputTensors,
|
||||
float confThreshold, float iouThreshold);
|
||||
|
||||
/// The [1, N, 6] head: rows of (x1 y1 x2 y2 score class) whose
|
||||
/// non-maximum suppression happened inside the graph. postprocess()
|
||||
/// hands the tensor here when it recognises that shape; reading it
|
||||
/// as a [1, 4+nc, anchors] grid returns boxes covering the frame.
|
||||
std::vector<Object> postprocessEndToEnd(const cv::Size& originalImageSize,
|
||||
const cv::Size& resizedImageShape,
|
||||
std::vector<Ort::Value>& outputTensors,
|
||||
float confThreshold);
|
||||
|
||||
private:
|
||||
template <typename T>
|
||||
typename std::enable_if<std::is_arithmetic<T>::value, T>::type
|
||||
|
||||
Reference in New Issue
Block a user