diff --git a/configs/sample_person_shoe_two_stage.json b/configs/sample_person_shoe_two_stage.json index 9793e91..646e805 100644 --- a/configs/sample_person_shoe_two_stage.json +++ b/configs/sample_person_shoe_two_stage.json @@ -74,19 +74,20 @@ "type": "ai_shoe_det", "role": "filter", "enable": true, - "infer_fps": 2, + "infer_fps": 1, "model_path": "./models/shoe_detector_openimages_ppe_v1.rknn", "model_w": 640, "model_h": 640, "conf": 0.25, "nms": 0.45, + "v8_box_format": "cxcywh", "append_detections": true, "dynamic_roi": { "enable": true, "person_class_id": 0, "shoe_class_id": 1, "debug_roi_class_id": 2, - "max_rois": 4, + "max_rois": 3, "min_person_height": 80, "x_offset": -0.20, "y_offset": 0.68, diff --git a/plugins/ai_shoe_det/ai_shoe_det_node.cpp b/plugins/ai_shoe_det/ai_shoe_det_node.cpp index 159eb6b..3c2064f 100644 --- a/plugins/ai_shoe_det/ai_shoe_det_node.cpp +++ b/plugins/ai_shoe_det/ai_shoe_det_node.cpp @@ -283,6 +283,28 @@ public: conf_thresh_ = config.ValueOr("conf", 0.25f); nms_thresh_ = config.ValueOr("nms", 0.45f); append_detections_ = config.ValueOr("append_detections", false); + { + const std::string bf = config.ValueOr("v8_box_format", "auto"); + if (bf == "xyxy") { + v8_box_format_ = V8BoxFormat::XyXy; + } else if (bf == "xywh") { + v8_box_format_ = V8BoxFormat::XyWh; + } else if (bf == "cxcywh") { + v8_box_format_ = V8BoxFormat::CxCyWh; + } else { + v8_box_format_ = V8BoxFormat::Auto; + } + } + { + const std::string act = config.ValueOr("v8_cls_activation", "auto"); + if (act == "sigmoid") { + v8_cls_activation_ = V8ClsActivation::Sigmoid; + } else if (act == "none") { + v8_cls_activation_ = V8ClsActivation::None; + } else { + v8_cls_activation_ = V8ClsActivation::Auto; + } + } infer_interval_ms_ = std::max( 0, static_cast(config.ValueOr("infer_interval_ms", 0))); @@ -581,7 +603,7 @@ private: auto append_box = [&](float a, float b, float c, float d, float conf) { if (!std::isfinite(a) || !std::isfinite(b) || !std::isfinite(c) || !std::isfinite(d)) return; float x = 0.0f, y = 0.0f, w = 0.0f, h = 0.0f; - DecodeV8Box(a, b, c, d, model_w_, model_h_, V8BoxFormat::Auto, x, y, w, h); + DecodeV8Box(a, b, c, d, model_w_, model_h_, v8_box_format_, x, y, w, h); if (!std::isfinite(x) || !std::isfinite(y) || !std::isfinite(w) || !std::isfinite(h)) return; if (w <= 1e-3f || h <= 1e-3f) return; if (w > model_w_ * 1.2f || h > model_h_ * 1.2f) return; @@ -599,7 +621,7 @@ private: if (outputs[0].type == RKNN_TENSOR_FLOAT32) { const float* data = reinterpret_cast(outputs[0].data); const bool apply_sigmoid = ResolveV8ApplySigmoid( - data, num_boxes, kNumClasses, layout.channels_first, V8ClsActivation::Auto); + data, num_boxes, kNumClasses, layout.channels_first, v8_cls_activation_); for (int i = 0; i < num_boxes; ++i) { const float score = layout.channels_first ? data[4 * num_boxes + i] : data[i * num_channels + 4]; @@ -618,7 +640,7 @@ private: fp32_decode_buf_[i] = Fp16ToFp32(data[i]); } const bool apply_sigmoid = ResolveV8ApplySigmoid( - fp32_decode_buf_.data(), num_boxes, kNumClasses, layout.channels_first, V8ClsActivation::Auto); + fp32_decode_buf_.data(), num_boxes, kNumClasses, layout.channels_first, v8_cls_activation_); for (int i = 0; i < num_boxes; ++i) { const float score = layout.channels_first ? fp32_decode_buf_[4 * num_boxes + i] : fp32_decode_buf_[i * num_channels + 4]; @@ -733,6 +755,8 @@ private: float conf_thresh_ = 0.25f; float nms_thresh_ = 0.45f; bool append_detections_ = false; + V8BoxFormat v8_box_format_ = V8BoxFormat::Auto; + V8ClsActivation v8_cls_activation_ = V8ClsActivation::Auto; int64_t infer_interval_ms_ = 0; int64_t last_infer_pts_ms_ = 0; DynamicRoiConfig dynamic_roi_;