@trillboards/edge-sdk 0.2.178 → 0.2.185
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/THIRD-PARTY-NOTICES.md +220 -0
- package/deploy/detector/bench/actor-appearance-qualified-v1.json +106 -0
- package/deploy/detector/bench/actor-appearance.md +52 -0
- package/deploy/detector/bench/export_actor_appearance.py +134 -0
- package/deploy/detector/bench/qualify_actor_appearance.py +77 -0
- package/deploy/detector/bench/qualify_actor_appearance_client.cjs +50 -0
- package/deploy/detector/bench/qualify_actor_appearance_wire.py +170 -0
- package/deploy/detector/bench/requirements-appearance-export.txt +4 -0
- package/deploy/detector/pyproject.toml +1 -1
- package/deploy/detector/tests/fixtures/actor-appearance-original-g326-v1.json +27105 -0
- package/deploy/detector/tests/test_actor_appearance_tracking.py +196 -0
- package/deploy/detector/tests/test_appearance_wire.py +80 -0
- package/deploy/detector/tests/test_loader.py +9 -7
- package/deploy/detector/trillboards_detector/_version.py +2 -2
- package/deploy/detector/trillboards_detector/actor_identity.py +323 -0
- package/deploy/detector/trillboards_detector/actor_tracking.py +163 -1
- package/deploy/detector/trillboards_detector/appearance.py +149 -0
- package/deploy/detector/trillboards_detector/loader.py +6 -0
- package/deploy/detector/trillboards_detector/registry.py +30 -1
- package/deploy/detector/trillboards_detector/server.py +56 -1
- package/deploy/detector/trillboards_detector/tasks.py +7 -1
- package/dist/ActorAppearance.d.ts +13 -0
- package/dist/ActorAppearance.d.ts.map +1 -0
- package/dist/ActorAppearance.js +17 -0
- package/dist/ActorAppearance.js.map +1 -0
- package/dist/ActorPerception.d.ts +2 -0
- package/dist/ActorPerception.d.ts.map +1 -1
- package/dist/ActorPerception.js +12 -5
- package/dist/ActorPerception.js.map +1 -1
- package/dist/ActorTracking.d.ts +3 -1
- package/dist/ActorTracking.d.ts.map +1 -1
- package/dist/ActorTracking.js +10 -3
- package/dist/ActorTracking.js.map +1 -1
- package/dist/CloudSensingManager.d.ts +1 -0
- package/dist/CloudSensingManager.d.ts.map +1 -1
- package/dist/CloudSensingManager.js +1 -0
- package/dist/CloudSensingManager.js.map +1 -1
- package/dist/ConnectorStatusClient.d.ts +2 -0
- package/dist/ConnectorStatusClient.d.ts.map +1 -1
- package/dist/ConnectorStatusClient.js.map +1 -1
- package/dist/DurableVlmCandidateSpool.d.ts.map +1 -1
- package/dist/DurableVlmCandidateSpool.js +10 -0
- package/dist/DurableVlmCandidateSpool.js.map +1 -1
- package/dist/EdgeAgent.js +1 -1
- package/dist/LocalDetectorClient.d.ts +2 -1
- package/dist/LocalDetectorClient.d.ts.map +1 -1
- package/dist/LocalDetectorClient.js +9 -2
- package/dist/LocalDetectorClient.js.map +1 -1
- package/dist/RuntimeModelSelection.d.ts.map +1 -1
- package/dist/RuntimeModelSelection.js +15 -1
- package/dist/RuntimeModelSelection.js.map +1 -1
- package/dist/VlmCandidateBuffer.d.ts +14 -0
- package/dist/VlmCandidateBuffer.d.ts.map +1 -1
- package/dist/VlmCandidateBuffer.js.map +1 -1
- package/dist/connectorUpdate.d.ts +4 -16
- package/dist/connectorUpdate.d.ts.map +1 -1
- package/dist/connectorUpdate.js +37 -13
- package/dist/connectorUpdate.js.map +1 -1
- package/dist/diagnose.d.ts +1 -1
- package/dist/diagnose.js +1 -1
- package/package.json +2 -2
- package/retained/__tests__/actor-perception.test.cjs +29 -6
- package/retained/manager.cjs +20 -9
|
@@ -0,0 +1,170 @@
|
|
|
1
|
+
"""Real client + HTTP + RF-DETR + pose + appearance + persistent actor journal."""
|
|
2
|
+
|
|
3
|
+
import argparse
|
|
4
|
+
import hashlib
|
|
5
|
+
import json
|
|
6
|
+
import os
|
|
7
|
+
from pathlib import Path
|
|
8
|
+
import subprocess
|
|
9
|
+
import tempfile
|
|
10
|
+
import threading
|
|
11
|
+
|
|
12
|
+
from trillboards_detector.actor_identity import MODEL_ID, MODEL_SHA256
|
|
13
|
+
from trillboards_detector.actor_tracking import ActorTrackerJournal
|
|
14
|
+
from trillboards_detector.labels import RFDETR_MEDIUM
|
|
15
|
+
from trillboards_detector.loader import DetectorLoader
|
|
16
|
+
from trillboards_detector.server import DetectorServer
|
|
17
|
+
from trillboards_detector.tasks import RTMPOSE_BODY7, PERSON_APPEARANCE
|
|
18
|
+
|
|
19
|
+
|
|
20
|
+
def main():
|
|
21
|
+
parser = argparse.ArgumentParser()
|
|
22
|
+
parser.add_argument("--detector", required=True)
|
|
23
|
+
parser.add_argument("--pose", required=True)
|
|
24
|
+
parser.add_argument("--appearance", required=True)
|
|
25
|
+
parser.add_argument("--original-frames", required=True)
|
|
26
|
+
parser.add_argument("--result-dir", required=True)
|
|
27
|
+
args = parser.parse_args()
|
|
28
|
+
result_dir = Path(args.result_dir).resolve()
|
|
29
|
+
result_dir.mkdir(parents=True, exist_ok=True)
|
|
30
|
+
bench = Path(__file__).resolve().parent
|
|
31
|
+
fixture_path = bench.parent / "tests/fixtures/actor-appearance-original-g326-v1.json"
|
|
32
|
+
fixture = json.loads(fixture_path.read_text())
|
|
33
|
+
first = fixture["frames"][0]
|
|
34
|
+
base_policy = {
|
|
35
|
+
"version": 1,
|
|
36
|
+
"cameraId": first["request"]["cameraId"],
|
|
37
|
+
"sourceId": first["request"]["sourceId"],
|
|
38
|
+
"detector": {"modelId": "rfdetr_medium", "sha256": first["modelHashes"]["rfdetr_medium"]},
|
|
39
|
+
"pose": {"modelId": RTMPOSE_BODY7.model_name, "sha256": RTMPOSE_BODY7.sha256},
|
|
40
|
+
"minConfidence": 0.25,
|
|
41
|
+
}
|
|
42
|
+
appearance_policy = {**base_policy, "appearance": {"modelId": MODEL_ID, "sha256": MODEL_SHA256}}
|
|
43
|
+
old_data_dir = os.environ.get("TRILLBOARDS_DATA_DIR")
|
|
44
|
+
loader = None
|
|
45
|
+
with tempfile.TemporaryDirectory(prefix="actor-appearance-native-") as temp:
|
|
46
|
+
temp = Path(temp)
|
|
47
|
+
try:
|
|
48
|
+
for model_id, artifact in [
|
|
49
|
+
("rfdetr_medium", args.detector),
|
|
50
|
+
(RTMPOSE_BODY7.model_name, args.pose),
|
|
51
|
+
(MODEL_ID, args.appearance),
|
|
52
|
+
]:
|
|
53
|
+
directory = temp / "models" / model_id
|
|
54
|
+
directory.mkdir(parents=True)
|
|
55
|
+
(directory / "model.onnx").symlink_to(Path(artifact).resolve())
|
|
56
|
+
os.environ["TRILLBOARDS_DATA_DIR"] = str(temp)
|
|
57
|
+
loader = DetectorLoader(
|
|
58
|
+
Path(args.detector),
|
|
59
|
+
"rfdetr_medium",
|
|
60
|
+
intra_op_threads=4,
|
|
61
|
+
ram_budget_bytes=1536 * 1024**2,
|
|
62
|
+
vocabularies=(RFDETR_MEDIUM,),
|
|
63
|
+
accelerator="cpu",
|
|
64
|
+
task_models=(RTMPOSE_BODY7, PERSON_APPEARANCE),
|
|
65
|
+
log=lambda line: print(line, flush=True),
|
|
66
|
+
)
|
|
67
|
+
loader.registry.refresh()
|
|
68
|
+
initial = loader.info()
|
|
69
|
+
if initial["state"] != "ready" or MODEL_ID in initial["resident_models"]:
|
|
70
|
+
raise ValueError(
|
|
71
|
+
"Native appearance must be presence-discovered and lazily admitted"
|
|
72
|
+
)
|
|
73
|
+
|
|
74
|
+
def replay(label, policy, begin, end, journal):
|
|
75
|
+
policy_file = result_dir / (label + "-policy.json")
|
|
76
|
+
output = result_dir / (label + "-frames.json")
|
|
77
|
+
policy_file.write_text(json.dumps(policy) + "\n")
|
|
78
|
+
tracker = ActorTrackerJournal(journal, frame_rate=2)
|
|
79
|
+
server = DetectorServer(
|
|
80
|
+
("127.0.0.1", 0), loader, log_line=lambda line: None, actor_tracker=tracker
|
|
81
|
+
)
|
|
82
|
+
worker = threading.Thread(
|
|
83
|
+
target=lambda: server.serve_forever(poll_interval=0.01), daemon=True
|
|
84
|
+
)
|
|
85
|
+
worker.start()
|
|
86
|
+
try:
|
|
87
|
+
subprocess.run(
|
|
88
|
+
[
|
|
89
|
+
"node",
|
|
90
|
+
str(bench / "qualify_actor_appearance_client.cjs"),
|
|
91
|
+
"http://127.0.0.1:" + str(server.server_port),
|
|
92
|
+
str(fixture_path),
|
|
93
|
+
str(Path(args.original_frames).resolve()),
|
|
94
|
+
str(policy_file),
|
|
95
|
+
str(output),
|
|
96
|
+
str(begin),
|
|
97
|
+
str(end),
|
|
98
|
+
],
|
|
99
|
+
check=True,
|
|
100
|
+
timeout=360,
|
|
101
|
+
)
|
|
102
|
+
finally:
|
|
103
|
+
server.shutdown()
|
|
104
|
+
server.server_close()
|
|
105
|
+
worker.join(timeout=5)
|
|
106
|
+
tracker.close()
|
|
107
|
+
if worker.is_alive():
|
|
108
|
+
raise RuntimeError("Owned native qualification service did not stop")
|
|
109
|
+
return json.loads(output.read_text())["frames"]
|
|
110
|
+
|
|
111
|
+
count = len(fixture["frames"])
|
|
112
|
+
before = replay("before", base_policy, 0, count, temp / "before.sqlite")
|
|
113
|
+
part1 = replay("after-first", appearance_policy, 0, 28, temp / "after.sqlite")
|
|
114
|
+
# The first item is an exact committed-frame retry after SQLite/service restart.
|
|
115
|
+
part2 = replay("after-restart", appearance_policy, 27, count, temp / "after.sqlite")
|
|
116
|
+
if part1[-1]["result"]["tracking"] != part2[0]["result"]["tracking"]:
|
|
117
|
+
raise ValueError("Service restart changed the committed physical person proof")
|
|
118
|
+
after = part1 + part2[1:]
|
|
119
|
+
final = loader.info()
|
|
120
|
+
finally:
|
|
121
|
+
if old_data_dir is None:
|
|
122
|
+
os.environ.pop("TRILLBOARDS_DATA_DIR", None)
|
|
123
|
+
else:
|
|
124
|
+
os.environ["TRILLBOARDS_DATA_DIR"] = old_data_dir
|
|
125
|
+
|
|
126
|
+
def actor(results, point):
|
|
127
|
+
frame = next(f for f in results if f["sourceFrame"] == point["sourceFrame"])
|
|
128
|
+
return next(
|
|
129
|
+
a["actor"]["id"]
|
|
130
|
+
for a in frame["result"]["tracking"]["actors"]
|
|
131
|
+
if a["detectionIndex"] == point["detectionIndex"]
|
|
132
|
+
)
|
|
133
|
+
|
|
134
|
+
controls = fixture["reviewedContinuityControls"]
|
|
135
|
+
before_ids = {actor(before, point) for point in controls}
|
|
136
|
+
after_ids = {actor(after, point) for point in controls}
|
|
137
|
+
caller_ids = {actor(after, point) for point in fixture["reviewedCallerFrames"]}
|
|
138
|
+
if len(before_ids) != 1 or len(after_ids) != 3 or len(caller_ids) != 1:
|
|
139
|
+
raise ValueError("Original physical-person continuity controls failed")
|
|
140
|
+
if MODEL_ID not in final["resident_models"] or final["evictions"] != 0:
|
|
141
|
+
raise ValueError("Appearance did not use the shared bounded native model portfolio")
|
|
142
|
+
report = {
|
|
143
|
+
"passed": True,
|
|
144
|
+
"scope": "native client/service identity continuity on original source JPEGs",
|
|
145
|
+
"fixtureSha256": hashlib.sha256(fixture_path.read_bytes()).hexdigest(),
|
|
146
|
+
"sourceFrames": count,
|
|
147
|
+
"nativePersonObservations": sum(
|
|
148
|
+
len(f["appearance"]["descriptors"]) for f in fixture["frames"]
|
|
149
|
+
),
|
|
150
|
+
"beforeReviewedPeople": 3,
|
|
151
|
+
"beforePhysicalHistories": len(before_ids),
|
|
152
|
+
"afterReviewedPeople": 3,
|
|
153
|
+
"afterPhysicalHistories": len(after_ids),
|
|
154
|
+
"reviewedCallerFrames": len(fixture["reviewedCallerFrames"]),
|
|
155
|
+
"reviewedCallerPhysicalHistories": len(caller_ids),
|
|
156
|
+
"nativeChunkedHttpClient": True,
|
|
157
|
+
"nativeWebsiteManagerModelAdmission": True,
|
|
158
|
+
"committedRetryAfterServiceRestart": True,
|
|
159
|
+
"appearanceModel": appearance_policy["appearance"],
|
|
160
|
+
"residentModels": final["resident_models"],
|
|
161
|
+
"ramBudgetBytes": final["ram_budget_bytes"],
|
|
162
|
+
"evictions": final["evictions"],
|
|
163
|
+
"phoneOrTheftAccuracyQualified": False,
|
|
164
|
+
}
|
|
165
|
+
(result_dir / "qualification.json").write_text(json.dumps(report, indent=2) + "\n")
|
|
166
|
+
print(json.dumps(report), flush=True)
|
|
167
|
+
|
|
168
|
+
|
|
169
|
+
if __name__ == "__main__":
|
|
170
|
+
main()
|
|
@@ -10,7 +10,7 @@ name = "trillboards-detector"
|
|
|
10
10
|
# constant, a `labels.py`-only change survives `uv tool install` AND
|
|
11
11
|
# `uv tool install --force`; move the version and a bare `uv tool install`
|
|
12
12
|
# reinstalls. See `stamp_version.py`.
|
|
13
|
-
version = "0.2.0+src.
|
|
13
|
+
version = "0.2.0+src.02d69f63804d"
|
|
14
14
|
description = "On-device object-detector service for the Trillboards BYO-CCTV connector (loopback HTTP, ONNX Runtime)."
|
|
15
15
|
requires-python = ">=3.10"
|
|
16
16
|
|