-
Notifications
You must be signed in to change notification settings - Fork 1
/
edgeimpulsejacdac.ts
56 lines (46 loc) · 1.32 KB
/
edgeimpulsejacdac.ts
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
namespace jacdac {
export class EIHost extends MLHost {
model: edgeimpulse.Model
constructor(agg: SensorAggregatorHost) {
super("ei", ModelRunnerModelFormat.EdgeImpulseCompiled, agg);
}
protected invokeModel() {
try {
this.outputs = this.model.invoke(this.agg.samplesBuffer)
} catch (e) {
this.catchHandler(e)
}
}
protected eraseModel() {
this.model = null
binstore.erase()
}
protected transformFirstBlockOfModel(buf: Buffer) {
edgeimpulse.validateAndRewriteModelHeader(buf)
return buf
}
start() {
super.start()
//if (this.model)
// this.model.test()
}
protected loadModelImpl() {
try {
this.model = new edgeimpulse.Model(this.modelBuffer)
} catch (e) {
this.catchHandler(e)
}
}
get arenaBytes() {
return 0
}
get inputShape(): number[] {
return this.model.inputShape
}
get outputShape(): number[] {
return this.model.outputShape
}
}
//% whenUsed
export const eiHost = new EIHost(sensorAggregatorHost)
}