{
std::string name;
DimInfo dimInfo;
+ int offset = 0;
};
struct Number
{
std::string name;
DimInfo dimInfo;
+ int offset = 0;
};
struct BoxInfo
inference_box_coordinate_type_e coordinate = INFERENCE_BOX_COORDINATE_TYPE_RATIO; // 0: ratio, 1: pixel
inference_box_decoding_type_e decodingType = INFERENCE_BOX_DECODING_TYPE_BYPASS; // 0: bypass , 1:ssd with anchor
DecodeInfo decodingInfo;
+ int offset = 0;
Label label;
Number number;
{
return decodingInfo;
}
+ int GetOffset()
+ {
+ return offset;
+ }
std::string GetLabelName()
{
return label.name;
}
+ int GetLabelOffset()
+ {
+ return label.offset;
+ }
std::string GetNumberName()
{
return number.name;
{
return number.dimInfo;
}
+ int GetNumberOffset()
+ {
+ return number.offset;
+ }
int ParseBox(JsonObject *root);
} /* Inference */
} /* MediaVision */
-#endif
\ No newline at end of file
+#endif
{
return score.GetDeQuantZeroPoint();
}
+ int GetScoreOffset()
+ {
+ return score.GetOffset();
+ }
std::string GetBoxName()
{
return box.GetName();
{
return box.GetNumberDimInfo();
}
+ int GetBoxOffset()
+ {
+ return box.GetOffset();
+ }
+ int GetLabelOffset()
+ {
+ return box.GetLabelOffset();
+ }
+ int GetNumberOffset()
+ {
+ return box.GetNumberOffset();
+ }
int GetScoreCoordinate()
{
DimInfo dimInfo;
double threshold = 0.0;
int topNumber = 1;
+ int offset = 0;
inference_score_type_e type = INFERENCE_SCORE_TYPE_NORMAL;
std::shared_ptr<DeQuantization> deQuantization;
std::map<std::string, inference_score_type_e> supportedScoreTypes = { { "NORMAL", INFERENCE_SCORE_TYPE_NORMAL },
{
return topNumber;
}
+ int GetOffset()
+ {
+ return offset;
+ }
std::shared_ptr<DeQuantization> GetDeQuant()
{
return deQuantization;
} /* Inference */
} /* MediaVision */
-#endif
\ No newline at end of file
+#endif
return MEDIA_VISION_ERROR_INVALID_OPERATION;
}
+ if (json_object_has_member(pObject, "offset")) {
+ offset = static_cast<int>(json_object_get_int_member(pObject, "offset"));
+ if (offset < 0) {
+ LOGW("Invalid offset. Reset to 0");
+ offset = 0;
+ }
+ }
+ LOGI("offset: %d", offset);
+
array = json_object_get_array_member(pObject, "box_order");
elements2 = json_array_get_length(array);
LOGI("box order should have 4 elements and it has [%u]", elements2);
if (static_cast<int>(json_array_get_int_element(array, elem2)) == 1)
label.dimInfo.SetValidIndex(elem2);
}
+
+ if (json_object_has_member(pObject, "offset")) {
+ label.offset = static_cast<int>(json_object_get_int_member(pObject, "offset"));
+ if (label.offset < 0) {
+ LOGW("Invalid offset. Reset to 0");
+ label.offset = 0;
+ }
+ }
+ LOGI("offset: %d", label.offset);
}
LOGI("LEAVE");
for (unsigned int elem2 = 0; elem2 < elements2; ++elem2)
if (static_cast<int>(json_array_get_int_element(array, elem2)) == 1)
number.dimInfo.SetValidIndex(elem2);
+
+ if (json_object_has_member(pObject, "offset")) {
+ number.offset = static_cast<int>(json_object_get_int_member(pObject, "offset"));
+ if (number.offset < 0) {
+ LOGW("Invalid offset. Reset to 0");
+ number.offset = 0;
+ }
+ }
+ LOGI("offset: %d", number.offset);
}
LOGI("LEAVE");
LOGI("LEAVE");
return MEDIA_VISION_ERROR_NONE;
-}
\ No newline at end of file
+}
int boxOffset = mOutputLayerProperty.layers[outputMeta.GetBoxName()].shape[boxIndexes[0]];
int numberOfObjects = 0;
+ if (mOutputTensorBuffers.exist(outputMeta.GetBoxNumberName())) {
+ std::vector<int> numberIndexes = outputMeta.GetBoxNumberDimInfo().GetValidIndexAll();
+ if (numberIndexes.size() != 1) {
+ LOGE("Invalid dim size. It should be 1");
+ return MEDIA_VISION_ERROR_INVALID_OPERATION;
+ }
+ numberOfObjects = mOutputLayerProperty.layers[outputMeta.GetBoxNumberName()].shape[numberIndexes[0]];
+ }
+
if (outputMeta.GetBoxDecodingType() == INFERENCE_BOX_DECODING_TYPE_SSD_ANCHOR) {
std::vector<int> scoreIndexes = outputMeta.GetScoreDimInfo().GetValidIndexAll();
if (scoreIndexes.size() != 1) {
// mNumberOfObjects is set again if INFERENCE_BOX_DECODING_TYPE_BYPASS.
// Otherwise it is set already within ctor.
- mNumberOfOjects = mTensorBuffer.getValue<int>(mMeta.GetBoxNumberName(), indexes[0]);
+ int numberOfObjects = mTensorBuffer.getValue<int>(mMeta.GetBoxNumberName(), indexes[0]);
+ if (numberOfObjects > 0)
+ mNumberOfOjects = numberOfObjects;
} else if (mMeta.GetBoxDecodingType() == INFERENCE_BOX_DECODING_TYPE_SSD_ANCHOR) {
if (mMeta.GetBoxDecodeInfo().IsAnchorBoxEmpty()) {
LOGE("Anchor boxes are required but empty.");
return MEDIA_VISION_ERROR_INVALID_OPERATION;
}
} else {
+ mNumberOfOjects = 0;
LOGI("YOLO_ANCHOR does nothing");
}
cHeight /= mScaleH;
}
+ if (!mMeta.GetBoxLabelName().empty() && mMeta.GetLabelOffset())
+ idx = idx * mBoxOffset + mMeta.GetLabelOffset();
+
Box box = { .index = mMeta.GetBoxLabelName().empty() ? label :
mTensorBuffer.getValue<int>(mMeta.GetBoxLabelName(), idx),
.score = score,
Boxes boxes;
int ret = MEDIA_VISION_ERROR_NONE;
int totalIdx = mNumberOfOjects;
-
+ int scoreOffset = mMeta.GetScoreOffset();
+ int boxOffset = mMeta.GetBoxOffset();
for (int idx = 0; idx < totalIdx; ++idx) {
if (mMeta.GetBoxDecodingType() == INFERENCE_BOX_DECODING_TYPE_BYPASS) {
- float score = decodeScore(idx);
+ float score = scoreOffset > 0 ? decodeScore(idx * mBoxOffset + scoreOffset) :
+ decodeScore(idx);
if (score <= 0.0f)
continue;
- Box box = decodeBox(idx, score);
+ Box box = decodeBox(idx, score, idx, boxOffset);
mResultBoxes.push_back(box);
} else if (mMeta.GetBoxDecodingType() == INFERENCE_BOX_DECODING_TYPE_SSD_ANCHOR) {
int anchorIdx = -1;
return MEDIA_VISION_ERROR_INVALID_OPERATION;
}
+ if (json_object_has_member(pObject, "offset")) {
+ offset = static_cast<int>(json_object_get_int_member(pObject, "offset"));
+ if (offset < 0) {
+ LOGW("Invalid offset. Reset to 0");
+ offset = 0;
+ }
+ }
+ LOGI("offset: %d", offset);
+
if (json_object_has_member(pObject, "dequantization")) {
array = json_object_get_array_member(pObject, "dequantization");
JsonNode *node = json_array_get_element(array, 0);
LOGI("LEAVE");
return MEDIA_VISION_ERROR_NONE;
-}
\ No newline at end of file
+}
#define IMG_DOG \
MV_CONFIG_PATH \
"/res/inference/images/dog2.jpg"
+#define OD_LABEL_EFFICIENTDET_448_PATH \
+ MV_CONFIG_PATH \
+ "models/OD/snpe/label_coco_90.txt"
+#define OD_SNPE_WEIGHT_QC_EFFCIENTDET_448_PATH \
+ MV_CONFIG_PATH \
+ "/models/OD/snpe/fp32.dlc"
#define OD_LABEL_EFFICIENTDET_LITE2_448_PATH \
MV_CONFIG_PATH \
"models/OD/snpe/label_coco_90.txt"
}
};
+
+TEST_P(TestObjectDetectionSnpe, DISABLED_EFD2QC)
+{
+ ASSERT_TRUE(_use_json_parser);
+ engine_config_hosted_snpe_model(engine_cfg, OD_SNPE_WEIGHT_QC_EFFCIENTDET_448_PATH,
+ OD_LABEL_EFFICIENTDET_448_PATH, _use_json_parser, _target_device_type);
+
+ inference("person", IMG_BASEBALL);
+}
+
TEST_P(TestObjectDetectionSnpe, DISABLED_EFDLite2QC)
{
ASSERT_TRUE(_use_json_parser);