mirror of
https://github.com/ruvnet/RuView
synced 2026-08-07 20:01:43 +00:00
fix(cog-pose-estimation): emit frames under default config (ADR-159 A1)
pose_v1 has no confidence head, so infer() emits a constant 0.185 per frame. The config default_min_confidence was 0.3 and the runtime gates on confidence >= min_confidence, so a default install silently emitted ZERO pose.frame events while health reported healthy. - Add inference::MODEL_TYPICAL_CONFIDENCE (0.185, the validation PCK@50) as the single published per-frame confidence. - Pin default_min_confidence() to MODEL_TYPICAL_CONFIDENCE so a default install clears its own gate and emits. - Warn at run.started when min_confidence exceeds the model typical confidence (disclosed, not silent); document the trade-off in the config field, the JSON schema, and inference.rs. Failing-on-old test: default_config_emits_frames_with_real_model (with old 0.3 it panics: "default install would emit zero pose.frame events"). Co-Authored-By: claude-flow <ruv@ruv.net>
This commit is contained in:
@@ -23,6 +23,13 @@ pub struct CogConfig {
|
||||
pub poll_ms: u64,
|
||||
|
||||
/// Confidence threshold below which a frame's keypoints are not emitted.
|
||||
///
|
||||
/// Defaults to [`crate::inference::MODEL_TYPICAL_CONFIDENCE`] (0.185) — the
|
||||
/// model's published per-frame confidence. `pose_v1` has no confidence head,
|
||||
/// so every frame carries this same value; a default above it would silently
|
||||
/// suppress *all* `pose.frame` events while health still reports healthy.
|
||||
/// The runtime warns at `run.started` if this is raised above the model's
|
||||
/// typical confidence rather than dropping frames quietly.
|
||||
#[serde(default = "default_min_confidence")]
|
||||
pub min_confidence: f32,
|
||||
}
|
||||
@@ -36,7 +43,9 @@ fn default_poll_ms() -> u64 {
|
||||
}
|
||||
|
||||
fn default_min_confidence() -> f32 {
|
||||
0.3
|
||||
// Pinned to the model's typical/published confidence so a default install
|
||||
// actually emits frames. See `min_confidence` doc and ADR-159 §A1.
|
||||
crate::inference::MODEL_TYPICAL_CONFIDENCE
|
||||
}
|
||||
|
||||
impl CogConfig {
|
||||
|
||||
@@ -27,6 +27,16 @@ pub const INPUT_SUBCARRIERS: usize = 56;
|
||||
pub const INPUT_TIMESTEPS: usize = 20;
|
||||
pub const OUTPUT_KEYPOINTS: usize = 17;
|
||||
|
||||
/// The model's typical self-reported confidence. `pose_v1` has **no confidence
|
||||
/// head** (the head emits 34 keypoint coordinates only), so per-frame confidence
|
||||
/// is not available from the network. This is the validation-set PCK@50 (18.5%)
|
||||
/// the training run reported, used as the published per-frame confidence floor.
|
||||
///
|
||||
/// Surfaced as a public constant so the runtime can warn when a configured
|
||||
/// `min_confidence` threshold exceeds it — otherwise a default install would
|
||||
/// silently emit zero `pose.frame` events while health reports healthy.
|
||||
pub const MODEL_TYPICAL_CONFIDENCE: f32 = 0.185;
|
||||
|
||||
#[derive(Debug, Clone)]
|
||||
pub struct CsiWindow {
|
||||
pub data: Vec<f32>, // length INPUT_SUBCARRIERS * INPUT_TIMESTEPS
|
||||
@@ -283,12 +293,15 @@ impl InferenceEngine {
|
||||
let out = model.net.forward(&t)?; // [1, 34]
|
||||
let flat: Vec<f32> = out.flatten_all()?.to_vec1()?;
|
||||
// Confidence from pose_v1 is a published constant rather than per-frame —
|
||||
// the trained model didn't emit a confidence head. Use the validation-set
|
||||
// PCK@50 (18.5%) as the published self-reported confidence so downstream
|
||||
// consumers can gate display decisions on it.
|
||||
// the trained model has no confidence head (the head emits 34 keypoint
|
||||
// coordinates only), so a real per-frame value is genuinely unavailable.
|
||||
// We surface the validation-set PCK@50 (`MODEL_TYPICAL_CONFIDENCE`) as the
|
||||
// honest self-reported confidence. The runtime's `min_confidence` default
|
||||
// is pinned at or below this so a default install actually emits frames
|
||||
// (and warns if an operator raises the threshold above the model's reach).
|
||||
Ok(PoseOutput {
|
||||
keypoints: flat,
|
||||
confidence: 0.185,
|
||||
confidence: MODEL_TYPICAL_CONFIDENCE,
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
@@ -113,6 +113,18 @@ fn cmd_run(
|
||||
let cfg = CogConfig::load(&config_path)?;
|
||||
emit_event(&Event::run_started(COG_ID, &cfg));
|
||||
|
||||
// Disclosure: pose_v1 has no confidence head, so every frame carries the
|
||||
// same `MODEL_TYPICAL_CONFIDENCE`. A `min_confidence` above that silently
|
||||
// suppresses *all* pose.frame events. Warn loudly rather than drop quietly.
|
||||
if cfg.min_confidence > cog_pose_estimation::inference::MODEL_TYPICAL_CONFIDENCE {
|
||||
tracing::warn!(
|
||||
min_confidence = cfg.min_confidence,
|
||||
model_typical_confidence = cog_pose_estimation::inference::MODEL_TYPICAL_CONFIDENCE,
|
||||
"configured min_confidence exceeds the model's typical confidence; \
|
||||
no pose.frame events will be emitted until this is lowered"
|
||||
);
|
||||
}
|
||||
|
||||
let engine = InferenceEngine::with_adapter(adapter.as_deref())?;
|
||||
if engine.is_calibrated() {
|
||||
tracing::info!("per-room calibration adapter loaded");
|
||||
|
||||
Reference in New Issue
Block a user