Objectness
/src/nms.hppLines 97–192This function takes as input a tensor with box coordinates, objectness probability and class scores and returns a tensor of box coordinates and another tensor with class scores.
template <std::int32_t numBoxes,
std::int32_t numClasses,
std::int32_t numValidBoxes,
typename InputShape,
FracRepType InFracBits,
typename OutputBoxShape,
FracRepType BoxFracBits,
typename OutputScoreShape,
FracRepType ScoreFracBits>
INLINE nmsObjectness(NmsSpec& nmsObj,
InputShape& ocmRawInp,
OutputBoxShape& ocmValidBoxes,
OutputScoreShape& scores,
FixedPoint<std::int32_t, InFracBits>& confidenceThreshFP)| Name | Type | Default | Description |
|---|---|---|---|
numBoxes | std::int32_t | The number of boxes in the input tensor. | |
numClasses | std::int32_t | The number of classes in the input tensor. | |
numValidBoxes | std::int32_t | The maximum number of boxes selected after objectness filtering. | |
InputShape | typename | the shape of the input tensor. | |
InFracBits | FracRepType | The number of fractional bits in the input type of the input tensor. | |
OutputBoxShape | typename | The shape of the output box tensor. | |
BoxFracBits | FracRepType | The number of fractional bits in the type of the box tensor. | |
OutputScoreShape | typename | The shape of the output score tensor. | |
ScoreFracBits | FracRepType | The number of fractional bits in the type of the output score tensor. |
| Name | Type | Description |
|---|---|---|
nmsObj | NmsSpec& | A structure of various constants associated with nms used this function. |
ocmRawInp | InputShape& | Input tensor with box coordinates, objectness probability and class scores. |
ocmValidBoxes | OutputBoxShape& | Tensor containing valid boxes that are not filtered by NMS. |
scores | OutputScoreShape& | Scores of boxes that are deemed valid and are not filtered by NMS. |
confidenceThreshFP | FixedPoint<std::int32_t, InFracBits>& | Confidence threshold below which bounding boxes will be filtered. |
INLINE — nms_results An integer specifying the number of boxes and associated class scores selected from the input tensor. / // clang-format on
Intersection-over-Union (IoU)
/src/nms.hppLines 221–282Computes Non-Max Suppression (NMS) of Intersection-over-Union predictions.
The box tensor has a list of boxes, The arrays qSortedR and qTScores are arrays of indices and scores (sorted by scores). These are qVars where each core has data for one class. The indices specify the box in the boxes tensor. The score is the score for a class for the box. A qvar (qValidBoxCount) specifies the number of boxes for each class with valid scores. overlapthreshFP is used to eleminate boxes with overlap greater than this threshold.
template <typename BoxTensorShape,
std::int16_t boxCacheSize,
std::size_t numSortedBoxes,
std::size_t numScores,
std::uint8_t numBoxFracBits,
std::uint8_t numScoreFracBits>
INLINE nmsIou(BoxTensorShape& boxes,
std::int32_t vmaxcount,
container::NDArray<qVar_t<FixedPoint<std::int32_t, numBoxFracBits>>, boxCacheSize, 4>& qBoxCache,
container::NDArray<qVar_t<std::int16_t>, numSortedBoxes>& qSortedR,
container::NDArray<qVar_t<FixedPoint<std::int16_t, numScoreFracBits>>, numScores>& qTScores,
qVar_t<std::int16_t> qValidBoxCount,
FixedPoint<std::int32_t, numBoxFracBits> overlapthreshFP)| Name | Type | Default | Description |
|---|---|---|---|
BoxTensorShape | typename | Shape of the box tensor. It is a 2-dimensional tensor of 4 rows and validBoxSize columns. It has elements of type `FixedPoint<int32, numBoxFracBits>`. | |
boxCacheSize | std::int16_t | The size of the box Cache array on the core | |
numSortedBoxes | std::size_t | The size of the index array qSortedR | |
numScores | std::size_t | The size of the score array qTScores | |
numBoxFracBits | std::uint8_t | The number of fractional bits for the boxes in the box tensor and core box variables | |
numScoreFracBits | std::uint8_t | The number of fractional bits for the scores in the qTScores array. |
| Name | Type | Description |
|---|---|---|
boxes | BoxTensorShape& | The input box tensor |
vmaxcount | std::int32_t | The count of valid boxes in the box tensor |
qBoxCache | container::NDArray<qVar_t<FixedPoint<std::int32_t, numBoxFracBits>>, boxCacheSize, 4>& | An array on the core that is used to cache boxes loaded into the core from OCM. it has a maximum size of boxCacheSize. |
qSortedR | container::NDArray<qVar_t<std::int16_t>, numSortedBoxes>& | An array of indices. The index (column number in the box tensor) refers to box in the box tensor. |
qTScores | container::NDArray<qVar_t<FixedPoint<std::int16_t, numScoreFracBits>>, numScores>& | An array of scores per class (on each core) of the box referenced by the indices |
qValidBoxCount | qVar_t<std::int16_t> | The initial count of valid boxes (indices/scores) per class. These are usually boxes with scores above a scorethreshold |
overlapthreshFP | FixedPoint<std::int32_t, numBoxFracBits> | The value of overlap threshold |
INLINE — qValidBoxCount The number of valid bounding boxes, i.e. boxes not filtered out by NMS algorithm. / // clang-format on
