@camstack/addon-benchmark 0.1.0 → 0.1.2
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/dist/addon-benchmark.css +1 -0
- package/dist/index.js +6 -743
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +5 -723
- package/dist/index.mjs.map +1 -1
- package/dist/page.mjs +34094 -0
- package/package.json +44 -12
- package/dist/index.d.mts +0 -222
- package/dist/index.d.ts +0 -222
package/package.json
CHANGED
|
@@ -1,8 +1,15 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@camstack/addon-benchmark",
|
|
3
|
-
"version": "0.1.
|
|
3
|
+
"version": "0.1.2",
|
|
4
4
|
"description": "Detection addon benchmarking with reference images, accuracy metrics, and distributed execution",
|
|
5
|
-
"keywords": [
|
|
5
|
+
"keywords": [
|
|
6
|
+
"camstack",
|
|
7
|
+
"addon",
|
|
8
|
+
"camstack-addon",
|
|
9
|
+
"benchmark",
|
|
10
|
+
"detection",
|
|
11
|
+
"accuracy"
|
|
12
|
+
],
|
|
6
13
|
"license": "MIT",
|
|
7
14
|
"repository": {
|
|
8
15
|
"type": "git",
|
|
@@ -12,16 +19,25 @@
|
|
|
12
19
|
"module": "./dist/index.mjs",
|
|
13
20
|
"types": "./dist/index.d.ts",
|
|
14
21
|
"exports": {
|
|
15
|
-
".": {
|
|
22
|
+
".": {
|
|
23
|
+
"types": "./dist/index.d.ts",
|
|
24
|
+
"import": "./dist/index.mjs",
|
|
25
|
+
"require": "./dist/index.js"
|
|
26
|
+
},
|
|
27
|
+
"./package.json": "./package.json"
|
|
16
28
|
},
|
|
17
29
|
"camstack": {
|
|
30
|
+
"displayName": "Benchmark",
|
|
18
31
|
"addons": [
|
|
19
32
|
{
|
|
20
33
|
"id": "benchmark",
|
|
21
34
|
"entry": "./dist/index.js",
|
|
22
35
|
"slot": null,
|
|
23
36
|
"capabilities": [
|
|
24
|
-
{
|
|
37
|
+
{
|
|
38
|
+
"name": "addon-pages",
|
|
39
|
+
"mode": "collection"
|
|
40
|
+
}
|
|
25
41
|
],
|
|
26
42
|
"pages": [
|
|
27
43
|
{
|
|
@@ -29,31 +45,47 @@
|
|
|
29
45
|
"label": "Benchmark",
|
|
30
46
|
"icon": "gauge",
|
|
31
47
|
"path": "/addon/benchmark",
|
|
32
|
-
"bundle": "
|
|
33
|
-
"element": "camstack-benchmark"
|
|
48
|
+
"bundle": "page.mjs"
|
|
34
49
|
}
|
|
35
50
|
]
|
|
36
51
|
}
|
|
37
52
|
]
|
|
38
53
|
},
|
|
39
|
-
"files": [
|
|
54
|
+
"files": [
|
|
55
|
+
"dist",
|
|
56
|
+
"reference-images"
|
|
57
|
+
],
|
|
40
58
|
"scripts": {
|
|
41
|
-
"build": "tsup && vite build",
|
|
59
|
+
"build": "tsup --no-dts && vite build",
|
|
42
60
|
"build:server": "tsup",
|
|
43
|
-
"build:
|
|
61
|
+
"build:page": "vite build",
|
|
44
62
|
"dev": "tsup --watch",
|
|
45
|
-
"dev:
|
|
63
|
+
"dev:page": "vite",
|
|
46
64
|
"typecheck": "tsc --noEmit",
|
|
47
65
|
"test": "vitest run",
|
|
48
66
|
"test:watch": "vitest"
|
|
49
67
|
},
|
|
50
|
-
"peerDependencies": {
|
|
51
|
-
|
|
68
|
+
"peerDependencies": {
|
|
69
|
+
"@camstack/types": "^0.1.0",
|
|
70
|
+
"react": ">=18",
|
|
71
|
+
"react-dom": ">=18"
|
|
72
|
+
},
|
|
73
|
+
"dependencies": {
|
|
74
|
+
"sharp": "^0.34.0"
|
|
75
|
+
},
|
|
52
76
|
"devDependencies": {
|
|
53
77
|
"@camstack/types": "*",
|
|
54
78
|
"@camstack/addon-vision": "*",
|
|
79
|
+
"@camstack/ui-library": "*",
|
|
80
|
+
"@tailwindcss/vite": "^4.2.0",
|
|
81
|
+
"@trpc/client": "^11.0.0",
|
|
82
|
+
"@vitejs/plugin-react": "^4.0.0",
|
|
83
|
+
"react": "^19.0.0",
|
|
84
|
+
"react-dom": "^19.0.0",
|
|
85
|
+
"superjson": "^2.0.0",
|
|
55
86
|
"tsup": "^8.0.0",
|
|
56
87
|
"typescript": "~5.9.0",
|
|
88
|
+
"tailwindcss": "^4.2.0",
|
|
57
89
|
"vite": "^6.3.0",
|
|
58
90
|
"vitest": "^3.0.0"
|
|
59
91
|
}
|
package/dist/index.d.mts
DELETED
|
@@ -1,222 +0,0 @@
|
|
|
1
|
-
import { ICamstackAddon, AddonManifest, AddonPageDeclaration, AddonContext, FrameInput, DetectorOutput, GroundTruth, CapabilityProviderMap, BenchmarkConfig, MultiBenchmarkReport, BenchmarkTarget, BenchmarkTargetResult, LatencyStats, SpatialDetection, GroundTruthAnnotation, AccuracyStats, BoundingBox, SystemInfo } from '@camstack/types';
|
|
2
|
-
|
|
3
|
-
type BenchmarkInferenceFactory = (addonId: string, config: Readonly<Record<string, unknown>>) => (frame: FrameInput, cfg: Readonly<Record<string, unknown>>) => Promise<DetectorOutput>;
|
|
4
|
-
interface BenchmarkAddonOptions {
|
|
5
|
-
/** Factory to create an inference function for a given addonId + config */
|
|
6
|
-
readonly inferenceFactory?: BenchmarkInferenceFactory;
|
|
7
|
-
/** Reference images with ground truth for accuracy evaluation */
|
|
8
|
-
readonly referenceImages?: ReadonlyArray<{
|
|
9
|
-
readonly frame: FrameInput;
|
|
10
|
-
readonly groundTruth: GroundTruth;
|
|
11
|
-
}>;
|
|
12
|
-
}
|
|
13
|
-
declare class BenchmarkAddon implements ICamstackAddon {
|
|
14
|
-
readonly id = "benchmark";
|
|
15
|
-
readonly manifest: AddonManifest;
|
|
16
|
-
readonly pages: readonly AddonPageDeclaration[];
|
|
17
|
-
private context;
|
|
18
|
-
private options;
|
|
19
|
-
initialize(ctx: AddonContext, opts?: BenchmarkAddonOptions): Promise<void>;
|
|
20
|
-
shutdown(): Promise<void>;
|
|
21
|
-
getCapabilityProvider<K extends keyof CapabilityProviderMap>(name: K): CapabilityProviderMap[K] | null;
|
|
22
|
-
/**
|
|
23
|
-
* Run a benchmark locally and return a MultiBenchmarkReport.
|
|
24
|
-
*/
|
|
25
|
-
run(config: BenchmarkConfig, onProgress?: (completed: number, total: number, currentTarget: string) => void): Promise<MultiBenchmarkReport>;
|
|
26
|
-
/**
|
|
27
|
-
* Run a distributed benchmark across agents.
|
|
28
|
-
*
|
|
29
|
-
* Stub: distributed execution requires a BenchmarkHub instance bound to
|
|
30
|
-
* live WebSocket connections. Call BenchmarkHub.dispatch() directly from
|
|
31
|
-
* the server transport layer. This method runs locally as a fallback.
|
|
32
|
-
*/
|
|
33
|
-
runDistributed(config: BenchmarkConfig, onProgress?: (completed: number, total: number, currentTarget: string) => void): Promise<MultiBenchmarkReport>;
|
|
34
|
-
private runLocally;
|
|
35
|
-
}
|
|
36
|
-
|
|
37
|
-
interface BenchmarkRunnerOptions {
|
|
38
|
-
/** Function to run inference — provided by the addon that's being benchmarked */
|
|
39
|
-
readonly runInference: (frame: FrameInput, config: Readonly<Record<string, unknown>>) => Promise<DetectorOutput>;
|
|
40
|
-
/** Reference images with ground truth */
|
|
41
|
-
readonly referenceImages: readonly {
|
|
42
|
-
readonly frame: FrameInput;
|
|
43
|
-
readonly groundTruth: GroundTruth;
|
|
44
|
-
}[];
|
|
45
|
-
/** Progress callback */
|
|
46
|
-
readonly onProgress?: (completed: number, total: number, currentTarget: string) => void;
|
|
47
|
-
}
|
|
48
|
-
declare class BenchmarkRunner {
|
|
49
|
-
private readonly options;
|
|
50
|
-
constructor(options: BenchmarkRunnerOptions);
|
|
51
|
-
/** Run inference on a single frame, picking a reference image round-robin if needed */
|
|
52
|
-
private runOnce;
|
|
53
|
-
/** Measure accuracy across all reference images */
|
|
54
|
-
private measureAccuracy;
|
|
55
|
-
/** Run benchmark for a single target configuration */
|
|
56
|
-
runTarget(target: BenchmarkTarget, config: BenchmarkConfig): Promise<BenchmarkTargetResult>;
|
|
57
|
-
/** Run benchmark for all targets defined in the config */
|
|
58
|
-
runAll(config: BenchmarkConfig): Promise<BenchmarkTargetResult[]>;
|
|
59
|
-
}
|
|
60
|
-
|
|
61
|
-
/**
|
|
62
|
-
* Compute latency statistics from an array of timing measurements in milliseconds.
|
|
63
|
-
*/
|
|
64
|
-
declare function computeLatencyStats(timingsMs: readonly number[]): LatencyStats;
|
|
65
|
-
/**
|
|
66
|
-
* Compute frames per second from timing measurements.
|
|
67
|
-
*/
|
|
68
|
-
declare function computeFps(timingsMs: readonly number[]): number;
|
|
69
|
-
|
|
70
|
-
/**
|
|
71
|
-
* Compute Intersection over Union (IoU) between two bounding boxes.
|
|
72
|
-
* Boxes are in {x, y, w, h} format where x, y are top-left corner.
|
|
73
|
-
*/
|
|
74
|
-
declare function iou(pred: BoundingBox, gt: BoundingBox): number;
|
|
75
|
-
/**
|
|
76
|
-
* Compute mAP@50 and per-class precision/recall for a set of predictions vs ground truth.
|
|
77
|
-
*
|
|
78
|
-
* Uses greedy matching (highest-score prediction matched first).
|
|
79
|
-
* Each ground truth can be matched at most once.
|
|
80
|
-
*/
|
|
81
|
-
declare function computeAccuracy(predictions: readonly SpatialDetection[], groundTruth: readonly GroundTruthAnnotation[], iouThreshold?: number): AccuracyStats;
|
|
82
|
-
|
|
83
|
-
/**
|
|
84
|
-
* Collect system hardware and runtime information.
|
|
85
|
-
*/
|
|
86
|
-
declare function collectSystemInfo(): SystemInfo;
|
|
87
|
-
|
|
88
|
-
/**
|
|
89
|
-
* Draw bounding boxes and optional masks on a frame, write result as JPEG.
|
|
90
|
-
*
|
|
91
|
-
* @param frame - Input image frame
|
|
92
|
-
* @param detections - Detections to annotate
|
|
93
|
-
* @param outputPath - Where to save the annotated JPEG
|
|
94
|
-
*/
|
|
95
|
-
declare function annotateImage(frame: FrameInput, detections: readonly SpatialDetection[], outputPath: string): Promise<void>;
|
|
96
|
-
|
|
97
|
-
interface BenchmarkStartMessage {
|
|
98
|
-
readonly type: 'benchmark.start';
|
|
99
|
-
readonly taskId: string;
|
|
100
|
-
readonly config: BenchmarkConfig;
|
|
101
|
-
/** Serialised reference images sent to the agent for deterministic results */
|
|
102
|
-
readonly referenceImages: ReadonlyArray<{
|
|
103
|
-
readonly name: string;
|
|
104
|
-
readonly data: Buffer;
|
|
105
|
-
readonly width: number;
|
|
106
|
-
readonly height: number;
|
|
107
|
-
}>;
|
|
108
|
-
}
|
|
109
|
-
interface BenchmarkCancelMessage {
|
|
110
|
-
readonly type: 'benchmark.cancel';
|
|
111
|
-
readonly taskId: string;
|
|
112
|
-
}
|
|
113
|
-
interface BenchmarkProgressMessage {
|
|
114
|
-
readonly type: 'benchmark.progress';
|
|
115
|
-
readonly taskId: string;
|
|
116
|
-
readonly agentId: string;
|
|
117
|
-
readonly completed: number;
|
|
118
|
-
readonly total: number;
|
|
119
|
-
readonly currentTarget: string;
|
|
120
|
-
}
|
|
121
|
-
interface BenchmarkResultMessage {
|
|
122
|
-
readonly type: 'benchmark.result';
|
|
123
|
-
readonly taskId: string;
|
|
124
|
-
readonly agentId: string;
|
|
125
|
-
readonly systemInfo: SystemInfo;
|
|
126
|
-
readonly results: readonly BenchmarkTargetResult[];
|
|
127
|
-
}
|
|
128
|
-
interface BenchmarkErrorMessage {
|
|
129
|
-
readonly type: 'benchmark.error';
|
|
130
|
-
readonly taskId: string;
|
|
131
|
-
readonly agentId: string;
|
|
132
|
-
readonly error: string;
|
|
133
|
-
}
|
|
134
|
-
interface AgentHelloMessage {
|
|
135
|
-
readonly type: 'agent.hello';
|
|
136
|
-
readonly agentId: string;
|
|
137
|
-
readonly systemInfo: SystemInfo;
|
|
138
|
-
}
|
|
139
|
-
interface HubAckMessage {
|
|
140
|
-
readonly type: 'hub.ack';
|
|
141
|
-
readonly taskId: string;
|
|
142
|
-
readonly agentId: string;
|
|
143
|
-
}
|
|
144
|
-
type BenchmarkMessage = BenchmarkStartMessage | BenchmarkCancelMessage | BenchmarkProgressMessage | BenchmarkResultMessage | BenchmarkErrorMessage | AgentHelloMessage | HubAckMessage;
|
|
145
|
-
|
|
146
|
-
type HubSendFn = (agentId: string, message: BenchmarkMessage) => void;
|
|
147
|
-
interface AgentEntry {
|
|
148
|
-
readonly agentId: string;
|
|
149
|
-
systemInfo?: SystemInfo;
|
|
150
|
-
status: 'idle' | 'running' | 'done' | 'error' | 'disconnected';
|
|
151
|
-
results?: readonly BenchmarkTargetResult[];
|
|
152
|
-
error?: string;
|
|
153
|
-
completedIterations?: number;
|
|
154
|
-
}
|
|
155
|
-
/**
|
|
156
|
-
* BenchmarkHub orchestrates benchmark task distribution to connected agents.
|
|
157
|
-
*
|
|
158
|
-
* Transport (WebSocket) is provided externally via the `send` callback.
|
|
159
|
-
* Call `handleMessage()` for every inbound message from agents.
|
|
160
|
-
*/
|
|
161
|
-
declare class BenchmarkHub {
|
|
162
|
-
private readonly send;
|
|
163
|
-
private readonly agents;
|
|
164
|
-
private activeTaskId;
|
|
165
|
-
private resolveTask;
|
|
166
|
-
private rejectTask;
|
|
167
|
-
private pendingConfig;
|
|
168
|
-
constructor(send: HubSendFn);
|
|
169
|
-
/** Register a connected agent (typically on WS connect + hello message) */
|
|
170
|
-
registerAgent(agentId: string, systemInfo?: SystemInfo): void;
|
|
171
|
-
/** Mark an agent as disconnected */
|
|
172
|
-
disconnectAgent(agentId: string): void;
|
|
173
|
-
/** Handle incoming message from any agent */
|
|
174
|
-
handleMessage(message: BenchmarkMessage): void;
|
|
175
|
-
/**
|
|
176
|
-
* Dispatch a benchmark to a subset of agents.
|
|
177
|
-
* Returns a promise that resolves when all targeted agents have finished.
|
|
178
|
-
*
|
|
179
|
-
* @param config - Benchmark configuration
|
|
180
|
-
* @param agentIds - If empty, dispatches to all connected/idle agents
|
|
181
|
-
* @param referenceImages - Reference image buffers to send to agents
|
|
182
|
-
*/
|
|
183
|
-
dispatch(config: BenchmarkConfig, agentIds: readonly string[], referenceImages?: ReadonlyArray<{
|
|
184
|
-
readonly name: string;
|
|
185
|
-
readonly data: Buffer;
|
|
186
|
-
readonly width: number;
|
|
187
|
-
readonly height: number;
|
|
188
|
-
}>): Promise<MultiBenchmarkReport>;
|
|
189
|
-
private onAgentHello;
|
|
190
|
-
private onProgress;
|
|
191
|
-
private onResult;
|
|
192
|
-
private onError;
|
|
193
|
-
private checkCompletion;
|
|
194
|
-
private buildReport;
|
|
195
|
-
}
|
|
196
|
-
|
|
197
|
-
type AgentSendFn = (message: BenchmarkMessage) => void;
|
|
198
|
-
type InferenceFactory = (addonId: string, config: Readonly<Record<string, unknown>>) => (frame: FrameInput, cfg: Readonly<Record<string, unknown>>) => Promise<DetectorOutput>;
|
|
199
|
-
/**
|
|
200
|
-
* BenchmarkAgent executes benchmark tasks dispatched by the hub.
|
|
201
|
-
*
|
|
202
|
-
* Transport (WebSocket) is provided externally via the `send` callback.
|
|
203
|
-
* Call `handleMessage()` for every inbound message from the hub.
|
|
204
|
-
*/
|
|
205
|
-
declare class BenchmarkAgent {
|
|
206
|
-
private readonly send;
|
|
207
|
-
private readonly inferenceFactory;
|
|
208
|
-
private readonly agentId;
|
|
209
|
-
private readonly systemInfo;
|
|
210
|
-
private cancelRequested;
|
|
211
|
-
constructor(agentId: string, send: AgentSendFn, inferenceFactory: InferenceFactory);
|
|
212
|
-
/** Send hello to the hub — call this on WS connect */
|
|
213
|
-
hello(): void;
|
|
214
|
-
/** Handle incoming message from the hub */
|
|
215
|
-
handleMessage(message: BenchmarkMessage): void;
|
|
216
|
-
private onStart;
|
|
217
|
-
private onCancel;
|
|
218
|
-
/** Returns the current task ID (last started), or null if idle */
|
|
219
|
-
private get activeTaskId();
|
|
220
|
-
}
|
|
221
|
-
|
|
222
|
-
export { type AgentEntry, type AgentHelloMessage, type AgentSendFn, BenchmarkAddon, type BenchmarkAddonOptions, BenchmarkAgent, type BenchmarkCancelMessage, type BenchmarkErrorMessage, BenchmarkHub, type BenchmarkInferenceFactory, type BenchmarkMessage, type BenchmarkProgressMessage, type BenchmarkResultMessage, BenchmarkRunner, type BenchmarkRunnerOptions, type BenchmarkStartMessage, type HubAckMessage, type HubSendFn, type InferenceFactory, annotateImage, collectSystemInfo, computeAccuracy, computeFps, computeLatencyStats, iou };
|
package/dist/index.d.ts
DELETED
|
@@ -1,222 +0,0 @@
|
|
|
1
|
-
import { ICamstackAddon, AddonManifest, AddonPageDeclaration, AddonContext, FrameInput, DetectorOutput, GroundTruth, CapabilityProviderMap, BenchmarkConfig, MultiBenchmarkReport, BenchmarkTarget, BenchmarkTargetResult, LatencyStats, SpatialDetection, GroundTruthAnnotation, AccuracyStats, BoundingBox, SystemInfo } from '@camstack/types';
|
|
2
|
-
|
|
3
|
-
type BenchmarkInferenceFactory = (addonId: string, config: Readonly<Record<string, unknown>>) => (frame: FrameInput, cfg: Readonly<Record<string, unknown>>) => Promise<DetectorOutput>;
|
|
4
|
-
interface BenchmarkAddonOptions {
|
|
5
|
-
/** Factory to create an inference function for a given addonId + config */
|
|
6
|
-
readonly inferenceFactory?: BenchmarkInferenceFactory;
|
|
7
|
-
/** Reference images with ground truth for accuracy evaluation */
|
|
8
|
-
readonly referenceImages?: ReadonlyArray<{
|
|
9
|
-
readonly frame: FrameInput;
|
|
10
|
-
readonly groundTruth: GroundTruth;
|
|
11
|
-
}>;
|
|
12
|
-
}
|
|
13
|
-
declare class BenchmarkAddon implements ICamstackAddon {
|
|
14
|
-
readonly id = "benchmark";
|
|
15
|
-
readonly manifest: AddonManifest;
|
|
16
|
-
readonly pages: readonly AddonPageDeclaration[];
|
|
17
|
-
private context;
|
|
18
|
-
private options;
|
|
19
|
-
initialize(ctx: AddonContext, opts?: BenchmarkAddonOptions): Promise<void>;
|
|
20
|
-
shutdown(): Promise<void>;
|
|
21
|
-
getCapabilityProvider<K extends keyof CapabilityProviderMap>(name: K): CapabilityProviderMap[K] | null;
|
|
22
|
-
/**
|
|
23
|
-
* Run a benchmark locally and return a MultiBenchmarkReport.
|
|
24
|
-
*/
|
|
25
|
-
run(config: BenchmarkConfig, onProgress?: (completed: number, total: number, currentTarget: string) => void): Promise<MultiBenchmarkReport>;
|
|
26
|
-
/**
|
|
27
|
-
* Run a distributed benchmark across agents.
|
|
28
|
-
*
|
|
29
|
-
* Stub: distributed execution requires a BenchmarkHub instance bound to
|
|
30
|
-
* live WebSocket connections. Call BenchmarkHub.dispatch() directly from
|
|
31
|
-
* the server transport layer. This method runs locally as a fallback.
|
|
32
|
-
*/
|
|
33
|
-
runDistributed(config: BenchmarkConfig, onProgress?: (completed: number, total: number, currentTarget: string) => void): Promise<MultiBenchmarkReport>;
|
|
34
|
-
private runLocally;
|
|
35
|
-
}
|
|
36
|
-
|
|
37
|
-
interface BenchmarkRunnerOptions {
|
|
38
|
-
/** Function to run inference — provided by the addon that's being benchmarked */
|
|
39
|
-
readonly runInference: (frame: FrameInput, config: Readonly<Record<string, unknown>>) => Promise<DetectorOutput>;
|
|
40
|
-
/** Reference images with ground truth */
|
|
41
|
-
readonly referenceImages: readonly {
|
|
42
|
-
readonly frame: FrameInput;
|
|
43
|
-
readonly groundTruth: GroundTruth;
|
|
44
|
-
}[];
|
|
45
|
-
/** Progress callback */
|
|
46
|
-
readonly onProgress?: (completed: number, total: number, currentTarget: string) => void;
|
|
47
|
-
}
|
|
48
|
-
declare class BenchmarkRunner {
|
|
49
|
-
private readonly options;
|
|
50
|
-
constructor(options: BenchmarkRunnerOptions);
|
|
51
|
-
/** Run inference on a single frame, picking a reference image round-robin if needed */
|
|
52
|
-
private runOnce;
|
|
53
|
-
/** Measure accuracy across all reference images */
|
|
54
|
-
private measureAccuracy;
|
|
55
|
-
/** Run benchmark for a single target configuration */
|
|
56
|
-
runTarget(target: BenchmarkTarget, config: BenchmarkConfig): Promise<BenchmarkTargetResult>;
|
|
57
|
-
/** Run benchmark for all targets defined in the config */
|
|
58
|
-
runAll(config: BenchmarkConfig): Promise<BenchmarkTargetResult[]>;
|
|
59
|
-
}
|
|
60
|
-
|
|
61
|
-
/**
|
|
62
|
-
* Compute latency statistics from an array of timing measurements in milliseconds.
|
|
63
|
-
*/
|
|
64
|
-
declare function computeLatencyStats(timingsMs: readonly number[]): LatencyStats;
|
|
65
|
-
/**
|
|
66
|
-
* Compute frames per second from timing measurements.
|
|
67
|
-
*/
|
|
68
|
-
declare function computeFps(timingsMs: readonly number[]): number;
|
|
69
|
-
|
|
70
|
-
/**
|
|
71
|
-
* Compute Intersection over Union (IoU) between two bounding boxes.
|
|
72
|
-
* Boxes are in {x, y, w, h} format where x, y are top-left corner.
|
|
73
|
-
*/
|
|
74
|
-
declare function iou(pred: BoundingBox, gt: BoundingBox): number;
|
|
75
|
-
/**
|
|
76
|
-
* Compute mAP@50 and per-class precision/recall for a set of predictions vs ground truth.
|
|
77
|
-
*
|
|
78
|
-
* Uses greedy matching (highest-score prediction matched first).
|
|
79
|
-
* Each ground truth can be matched at most once.
|
|
80
|
-
*/
|
|
81
|
-
declare function computeAccuracy(predictions: readonly SpatialDetection[], groundTruth: readonly GroundTruthAnnotation[], iouThreshold?: number): AccuracyStats;
|
|
82
|
-
|
|
83
|
-
/**
|
|
84
|
-
* Collect system hardware and runtime information.
|
|
85
|
-
*/
|
|
86
|
-
declare function collectSystemInfo(): SystemInfo;
|
|
87
|
-
|
|
88
|
-
/**
|
|
89
|
-
* Draw bounding boxes and optional masks on a frame, write result as JPEG.
|
|
90
|
-
*
|
|
91
|
-
* @param frame - Input image frame
|
|
92
|
-
* @param detections - Detections to annotate
|
|
93
|
-
* @param outputPath - Where to save the annotated JPEG
|
|
94
|
-
*/
|
|
95
|
-
declare function annotateImage(frame: FrameInput, detections: readonly SpatialDetection[], outputPath: string): Promise<void>;
|
|
96
|
-
|
|
97
|
-
interface BenchmarkStartMessage {
|
|
98
|
-
readonly type: 'benchmark.start';
|
|
99
|
-
readonly taskId: string;
|
|
100
|
-
readonly config: BenchmarkConfig;
|
|
101
|
-
/** Serialised reference images sent to the agent for deterministic results */
|
|
102
|
-
readonly referenceImages: ReadonlyArray<{
|
|
103
|
-
readonly name: string;
|
|
104
|
-
readonly data: Buffer;
|
|
105
|
-
readonly width: number;
|
|
106
|
-
readonly height: number;
|
|
107
|
-
}>;
|
|
108
|
-
}
|
|
109
|
-
interface BenchmarkCancelMessage {
|
|
110
|
-
readonly type: 'benchmark.cancel';
|
|
111
|
-
readonly taskId: string;
|
|
112
|
-
}
|
|
113
|
-
interface BenchmarkProgressMessage {
|
|
114
|
-
readonly type: 'benchmark.progress';
|
|
115
|
-
readonly taskId: string;
|
|
116
|
-
readonly agentId: string;
|
|
117
|
-
readonly completed: number;
|
|
118
|
-
readonly total: number;
|
|
119
|
-
readonly currentTarget: string;
|
|
120
|
-
}
|
|
121
|
-
interface BenchmarkResultMessage {
|
|
122
|
-
readonly type: 'benchmark.result';
|
|
123
|
-
readonly taskId: string;
|
|
124
|
-
readonly agentId: string;
|
|
125
|
-
readonly systemInfo: SystemInfo;
|
|
126
|
-
readonly results: readonly BenchmarkTargetResult[];
|
|
127
|
-
}
|
|
128
|
-
interface BenchmarkErrorMessage {
|
|
129
|
-
readonly type: 'benchmark.error';
|
|
130
|
-
readonly taskId: string;
|
|
131
|
-
readonly agentId: string;
|
|
132
|
-
readonly error: string;
|
|
133
|
-
}
|
|
134
|
-
interface AgentHelloMessage {
|
|
135
|
-
readonly type: 'agent.hello';
|
|
136
|
-
readonly agentId: string;
|
|
137
|
-
readonly systemInfo: SystemInfo;
|
|
138
|
-
}
|
|
139
|
-
interface HubAckMessage {
|
|
140
|
-
readonly type: 'hub.ack';
|
|
141
|
-
readonly taskId: string;
|
|
142
|
-
readonly agentId: string;
|
|
143
|
-
}
|
|
144
|
-
type BenchmarkMessage = BenchmarkStartMessage | BenchmarkCancelMessage | BenchmarkProgressMessage | BenchmarkResultMessage | BenchmarkErrorMessage | AgentHelloMessage | HubAckMessage;
|
|
145
|
-
|
|
146
|
-
type HubSendFn = (agentId: string, message: BenchmarkMessage) => void;
|
|
147
|
-
interface AgentEntry {
|
|
148
|
-
readonly agentId: string;
|
|
149
|
-
systemInfo?: SystemInfo;
|
|
150
|
-
status: 'idle' | 'running' | 'done' | 'error' | 'disconnected';
|
|
151
|
-
results?: readonly BenchmarkTargetResult[];
|
|
152
|
-
error?: string;
|
|
153
|
-
completedIterations?: number;
|
|
154
|
-
}
|
|
155
|
-
/**
|
|
156
|
-
* BenchmarkHub orchestrates benchmark task distribution to connected agents.
|
|
157
|
-
*
|
|
158
|
-
* Transport (WebSocket) is provided externally via the `send` callback.
|
|
159
|
-
* Call `handleMessage()` for every inbound message from agents.
|
|
160
|
-
*/
|
|
161
|
-
declare class BenchmarkHub {
|
|
162
|
-
private readonly send;
|
|
163
|
-
private readonly agents;
|
|
164
|
-
private activeTaskId;
|
|
165
|
-
private resolveTask;
|
|
166
|
-
private rejectTask;
|
|
167
|
-
private pendingConfig;
|
|
168
|
-
constructor(send: HubSendFn);
|
|
169
|
-
/** Register a connected agent (typically on WS connect + hello message) */
|
|
170
|
-
registerAgent(agentId: string, systemInfo?: SystemInfo): void;
|
|
171
|
-
/** Mark an agent as disconnected */
|
|
172
|
-
disconnectAgent(agentId: string): void;
|
|
173
|
-
/** Handle incoming message from any agent */
|
|
174
|
-
handleMessage(message: BenchmarkMessage): void;
|
|
175
|
-
/**
|
|
176
|
-
* Dispatch a benchmark to a subset of agents.
|
|
177
|
-
* Returns a promise that resolves when all targeted agents have finished.
|
|
178
|
-
*
|
|
179
|
-
* @param config - Benchmark configuration
|
|
180
|
-
* @param agentIds - If empty, dispatches to all connected/idle agents
|
|
181
|
-
* @param referenceImages - Reference image buffers to send to agents
|
|
182
|
-
*/
|
|
183
|
-
dispatch(config: BenchmarkConfig, agentIds: readonly string[], referenceImages?: ReadonlyArray<{
|
|
184
|
-
readonly name: string;
|
|
185
|
-
readonly data: Buffer;
|
|
186
|
-
readonly width: number;
|
|
187
|
-
readonly height: number;
|
|
188
|
-
}>): Promise<MultiBenchmarkReport>;
|
|
189
|
-
private onAgentHello;
|
|
190
|
-
private onProgress;
|
|
191
|
-
private onResult;
|
|
192
|
-
private onError;
|
|
193
|
-
private checkCompletion;
|
|
194
|
-
private buildReport;
|
|
195
|
-
}
|
|
196
|
-
|
|
197
|
-
type AgentSendFn = (message: BenchmarkMessage) => void;
|
|
198
|
-
type InferenceFactory = (addonId: string, config: Readonly<Record<string, unknown>>) => (frame: FrameInput, cfg: Readonly<Record<string, unknown>>) => Promise<DetectorOutput>;
|
|
199
|
-
/**
|
|
200
|
-
* BenchmarkAgent executes benchmark tasks dispatched by the hub.
|
|
201
|
-
*
|
|
202
|
-
* Transport (WebSocket) is provided externally via the `send` callback.
|
|
203
|
-
* Call `handleMessage()` for every inbound message from the hub.
|
|
204
|
-
*/
|
|
205
|
-
declare class BenchmarkAgent {
|
|
206
|
-
private readonly send;
|
|
207
|
-
private readonly inferenceFactory;
|
|
208
|
-
private readonly agentId;
|
|
209
|
-
private readonly systemInfo;
|
|
210
|
-
private cancelRequested;
|
|
211
|
-
constructor(agentId: string, send: AgentSendFn, inferenceFactory: InferenceFactory);
|
|
212
|
-
/** Send hello to the hub — call this on WS connect */
|
|
213
|
-
hello(): void;
|
|
214
|
-
/** Handle incoming message from the hub */
|
|
215
|
-
handleMessage(message: BenchmarkMessage): void;
|
|
216
|
-
private onStart;
|
|
217
|
-
private onCancel;
|
|
218
|
-
/** Returns the current task ID (last started), or null if idle */
|
|
219
|
-
private get activeTaskId();
|
|
220
|
-
}
|
|
221
|
-
|
|
222
|
-
export { type AgentEntry, type AgentHelloMessage, type AgentSendFn, BenchmarkAddon, type BenchmarkAddonOptions, BenchmarkAgent, type BenchmarkCancelMessage, type BenchmarkErrorMessage, BenchmarkHub, type BenchmarkInferenceFactory, type BenchmarkMessage, type BenchmarkProgressMessage, type BenchmarkResultMessage, BenchmarkRunner, type BenchmarkRunnerOptions, type BenchmarkStartMessage, type HubAckMessage, type HubSendFn, type InferenceFactory, annotateImage, collectSystemInfo, computeAccuracy, computeFps, computeLatencyStats, iou };
|