feat(perception): prewarm RF-DETR before source admission
This commit is contained in:
@@ -74,9 +74,7 @@ class _Resizer:
|
||||
def __init__(self) -> None:
|
||||
self.source: NDArray[np.uint8] | None = None
|
||||
|
||||
def resize(
|
||||
self, image: NDArray[np.uint8], width: int, height: int
|
||||
) -> NDArray[np.uint8]:
|
||||
def resize(self, image: NDArray[np.uint8], width: int, height: int) -> NDArray[np.uint8]:
|
||||
self.source = image.copy()
|
||||
output = np.empty((height, width, 3), dtype=np.uint8)
|
||||
output[:, :, 0] = 255
|
||||
@@ -135,9 +133,7 @@ def test_postprocess_maps_sparse_coco_slots_and_emits_only_risk_classes() -> Non
|
||||
assert tuple(item.label for item in result.detections) == ("person", "dog")
|
||||
assert result.detections[0].score == pytest.approx(0.8, abs=0.001)
|
||||
assert result.detections[1].score == pytest.approx(0.75, abs=0.001)
|
||||
assert result.detections[1].bbox_xyxy == pytest.approx(
|
||||
(300.0, 200.0, 500.0, 400.0), abs=0.03
|
||||
)
|
||||
assert result.detections[1].bbox_xyxy == pytest.approx((300.0, 200.0, 500.0, 400.0), abs=0.03)
|
||||
assert dict(result.rejected) == {"non-risk-class": 1, "unmapped-class-slot": 1}
|
||||
|
||||
with pytest.raises(RfDetrDetectorError, match="tensor types"):
|
||||
@@ -193,6 +189,30 @@ def test_shadow_provider_reports_preprocess_transport_and_postprocess_timing() -
|
||||
}
|
||||
|
||||
|
||||
def test_shadow_provider_warmup_is_idempotent_and_excluded_from_frame_counts() -> None:
|
||||
backend = _Backend(_output())
|
||||
provider = RfDetrShadowDetectorProvider(
|
||||
mask=np.ones((600, 800), dtype=np.bool_),
|
||||
backend=backend,
|
||||
resizer=_Resizer(),
|
||||
clock_ns=iter((10, 20, 50, 70)).__next__,
|
||||
)
|
||||
|
||||
first = provider.warm_up()
|
||||
second = provider.warm_up()
|
||||
|
||||
assert first is second
|
||||
assert backend.calls == 1
|
||||
assert first.completed is True
|
||||
assert first.inference_passes == 1
|
||||
assert first.preprocess_duration_ns == 10
|
||||
assert first.inference_transport_duration_ns == 30
|
||||
assert first.postprocess_duration_ns == 20
|
||||
assert first.total_duration_ns == 60
|
||||
assert provider.snapshot().input_frames == 0
|
||||
assert provider.snapshot().completed_frames == 0
|
||||
|
||||
|
||||
def test_shadow_profile_is_fixed_and_transport_pins_model_version() -> None:
|
||||
assert RF_DETR_CONFIG.minimum_score == 0.25
|
||||
with pytest.raises(RfDetrDetectorError, match="cannot be tuned"):
|
||||
@@ -209,16 +229,11 @@ def test_shadow_profile_is_fixed_and_transport_pins_model_version() -> None:
|
||||
|
||||
def test_shadow_profile_pins_worker_engine_and_retains_false_authority() -> None:
|
||||
profile = json.loads(
|
||||
(REPOSITORY_ROOT / "config/perception/rf-detr-large-risk-shadow-v0.json").read_text(
|
||||
"utf-8"
|
||||
)
|
||||
(REPOSITORY_ROOT / "config/perception/rf-detr-large-risk-shadow-v0.json").read_text("utf-8")
|
||||
)
|
||||
|
||||
assert profile["model"]["strongly_typed_fp16_onnx_sha256"] == RF_DETR_FP16_ONNX_SHA256
|
||||
assert (
|
||||
profile["model"]["worker_006_rtx4090_tensorrt_11_engine_sha256"]
|
||||
== RF_DETR_ENGINE_SHA256
|
||||
)
|
||||
assert profile["model"]["worker_006_rtx4090_tensorrt_11_engine_sha256"] == RF_DETR_ENGINE_SHA256
|
||||
assert profile["emission"]["single_inference_per_source_frame"] is True
|
||||
assert profile["emission"]["geometry_owns_static_occupancy"] is True
|
||||
assert profile["emission"]["unlisted_semantic_classes_emitted"] is False
|
||||
|
||||
Reference in New Issue
Block a user