Skip to content

Commit b6d5764

Browse files
committed
Fix blinking arrows
1 parent 9492de1 commit b6d5764

File tree

2 files changed

+14
-17
lines changed

2 files changed

+14
-17
lines changed

src/components/features/graphs/knngraph/AxesFilterVectorView.svelte

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -87,6 +87,8 @@
8787
};
8888
});
8989
90+
$: console.log($filters);
91+
9092
unsubscribe = derived([highlightedAxis, classifier], s => s).subscribe(s => {
9193
init();
9294
});
@@ -114,7 +116,9 @@
114116
</div>
115117
{/each}
116118
</div>
119+
117120
{#if $highlightedAxis.length === 1}
121+
<!-- Name and blue arrow -->
118122
<div class="pl-30 flex flex-col justify-around">
119123
{#each $filters as filter, index}
120124
<p class="pl-1" id={`arrowTo${index}`}>{filter.getName()}</p>
@@ -128,7 +132,10 @@
128132
width="20px" />
129133
{/each}
130134
</div>
131-
<div class="flex flex-col justify-around w-12">
135+
136+
<!-- Numbers -->
137+
<div
138+
class="flex flex-col justify-around w-14 overflow-hidden whitespace-nowrap">
132139
{#each liveFilteredAxesData as val, index}
133140
<p style={`color:${StaticConfiguration.graphColors[index]}`}>
134141
{val.toFixed(2)}

src/lib/domain/stores/Classifier.ts

Lines changed: 6 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -22,37 +22,26 @@ import type { Vector } from '../Vector';
2222

2323
type ClassifierData = {
2424
model: ModelData;
25-
filteredInput: {
26-
raw: Vector;
27-
normalized: Vector;
28-
};
2925
};
3026

3127
class Classifier implements Readable<ClassifierData> {
32-
private filteredInput: Writable<{ raw: Vector; normalized: Vector }>;
3328
constructor(
3429
private model: Model,
3530
private filters: Filters,
3631
private gestures: Readable<Gesture[]>,
3732
private confidenceSetter: (gestureId: GestureID, confidence: number) => void,
3833
) {
39-
this.filteredInput = writable({
40-
raw: new BaseVector([]),
41-
normalized: new BaseVector([]),
42-
});
4334
Logger.log('classifier', 'Initialized classifier');
4435
}
4536

4637
public subscribe(
4738
run: Subscriber<ClassifierData>,
4839
invalidate?: ((value?: ClassifierData | undefined) => void) | undefined,
4940
): Unsubscriber {
50-
return derived([this.model, this.filteredInput], stores => {
41+
return derived([this.model], stores => {
5142
const modelStore = stores[0];
52-
const filteredInputStore = stores[1];
5343
return {
5444
model: modelStore,
55-
filteredInput: filteredInputStore,
5645
};
5746
}).subscribe(run, invalidate);
5847
}
@@ -62,10 +51,11 @@ class Classifier implements Readable<ClassifierData> {
6251
*/
6352
public async classify(input: ClassifierInput): Promise<void> {
6453
const filteredInput = new BaseVector(input.getInput(this.filters));
65-
const filteredInputNormalized = new BaseVector(
66-
input.getNormalizedInput(this.filters),
67-
);
68-
this.filteredInput.set({ raw: filteredInput, normalized: filteredInputNormalized });
54+
// Uncommented due to performance issues, caused too many re-renders
55+
// const filteredInputNormalized = new BaseVector(
56+
// input.getNormalizedInput(this.filters),
57+
// );
58+
// this.filteredInput.set({ raw: filteredInput, normalized: filteredInputNormalized });
6959
const predictions = await this.getModel().predict(filteredInput);
7060
predictions.forEach((confidence, index) => {
7161
const gesture = get(this.gestures)[index];

0 commit comments

Comments
 (0)