修复人脸画框2
This commit is contained in:
parent
3cd9971996
commit
dd1f419406
@ -163,6 +163,8 @@ bool ExtractNc(const Tensor& t, int c, NcTensor& out) {
|
||||
int n = 0;
|
||||
enum class Layout { FlatNc, CxN, NCHW, NHWC } layout = Layout::FlatNc;
|
||||
int dN = 1, dH = 1, dW = 1;
|
||||
const bool tried_shape = (t.dims.size() == 2 || t.dims.size() == 3 || t.dims.size() == 4);
|
||||
|
||||
if (t.dims.size() == 3) {
|
||||
// Common: [1, C, N] or [1, N, C]
|
||||
const uint32_t d1 = t.dims[1];
|
||||
@ -208,6 +210,12 @@ bool ExtractNc(const Tensor& t, int c, NcTensor& out) {
|
||||
}
|
||||
}
|
||||
|
||||
// IMPORTANT: when dims are present but don't match the requested channel count,
|
||||
// do NOT fallback to element-count heuristics (it will mis-classify tensors).
|
||||
if (tried_shape && n <= 0) {
|
||||
return false;
|
||||
}
|
||||
|
||||
if (n <= 0) {
|
||||
if (elem_cnt % static_cast<size_t>(c) != 0) return false;
|
||||
n = static_cast<int>(elem_cnt / static_cast<size_t>(c));
|
||||
@ -598,6 +606,9 @@ private:
|
||||
det.model_name = "retinaface";
|
||||
|
||||
DecodeRetinaFace(tensors, src_w, src_h, in_w, in_h, det);
|
||||
if (!logged_decode_.exchange(true)) {
|
||||
LogInfo("[ai_face_det] decoded faces=" + std::to_string(det.faces.size()));
|
||||
}
|
||||
frame->face_det = std::make_shared<FaceDetResult>(std::move(det));
|
||||
}
|
||||
|
||||
@ -628,6 +639,11 @@ private:
|
||||
continue;
|
||||
}
|
||||
}
|
||||
if (!logged_decode_detail_.exchange(true)) {
|
||||
LogInfo("[ai_face_det] decode tensors: loc_parts=" + std::to_string(locs.size()) +
|
||||
" conf_parts=" + std::to_string(confs.size()) +
|
||||
" lmk_parts=" + std::to_string(landms.size()));
|
||||
}
|
||||
if (locs.empty() || confs.empty()) return;
|
||||
|
||||
// Concatenate along N.
|
||||
@ -783,6 +799,8 @@ private:
|
||||
uint32_t n_output_ = 0;
|
||||
|
||||
std::atomic<bool> logged_io_{false};
|
||||
std::atomic<bool> logged_decode_{false};
|
||||
std::atomic<bool> logged_decode_detail_{false};
|
||||
};
|
||||
|
||||
REGISTER_NODE(AiFaceDetNode, "ai_face_det");
|
||||
|
||||
Loading…
Reference in New Issue
Block a user