Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix Looker Classifications handing #5322

Merged
merged 9 commits into from
Jan 3, 2025
Merged
Show file tree
Hide file tree
Changes from 4 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 13 additions & 7 deletions app/packages/looker/src/lookers/abstract.ts
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,9 @@ import { Events } from "../elements/base";
import { COMMON_SHORTCUTS, LookerElement } from "../elements/common";
import { ClassificationsOverlay, loadOverlays } from "../overlays";
import { CONTAINS, LabelMask, Overlay } from "../overlays/base";
import DetectionOverlay from "../overlays/detection";
import HeatmapOverlay from "../overlays/heatmap";
import SegmentationOverlay from "../overlays/segmentation";
import processOverlays from "../processOverlays";
import {
BaseState,
Expand Down Expand Up @@ -528,10 +531,13 @@ export abstract class AbstractLooker<
for (const overlay of this.pluckedOverlays ?? []) {
let overlayData: LabelMask = null;

if ("mask" in overlay.label) {
overlayData = overlay.label.mask as LabelMask;
} else if ("map" in overlay.label) {
overlayData = overlay.label.map as LabelMask;
if (
overlay instanceof DetectionOverlay ||
overlay instanceof SegmentationOverlay
) {
overlayData = overlay.label.mask;
} else if (overlay instanceof HeatmapOverlay) {
overlayData = overlay.label.map;
}

const buffer = overlayData?.data?.buffer;
Expand All @@ -546,9 +552,9 @@ export abstract class AbstractLooker<
if (buffer.detached) {
// most likely sample is already being processed, skip update
return;
} else {
arrayBuffers.push(buffer);
}

arrayBuffers.push(buffer);
benjaminpkane marked this conversation as resolved.
Show resolved Hide resolved
} else if (buffer.byteLength) {
// hope we don't run into this edge case (old browser)
// sometimes detached buffers have bytelength > 0
Expand Down Expand Up @@ -743,7 +749,7 @@ export abstract class AbstractLooker<

protected cleanOverlays() {
for (const overlay of this.sampleOverlays ?? []) {
overlay.cleanup();
overlay.cleanup?.();
}
}

Expand Down
4 changes: 2 additions & 2 deletions app/packages/looker/tsconfig.json
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
{
"compilerOptions": {
"target": "ES2023",
"target": "ES2024",
"module": "ES2022",
"lib": ["ES2023", "DOM", "DOM.Iterable"],
"lib": ["ES2024", "DOM", "DOM.Iterable"],
"moduleResolution": "Node",
"sourceMap": true,
"resolveJsonModule": true,
Expand Down
15 changes: 13 additions & 2 deletions app/packages/state/src/utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -57,15 +57,26 @@ export const stringifyObj = (obj) => {
);
};

export const filterView = (stages) =>
export const filterView = (stages: State.Stage[]) =>
JSON.stringify(
stages.map(({ kwargs, _cls }) => ({
kwargs: kwargs.filter((ka) => !ka[0].startsWith("_")),
_cls,
}))
);

export const viewsAreEqual = (viewOne, viewTwo) => {
export const viewsAreEqual = (
viewOne?: string | State.Stage[],
viewTwo?: string | State.Stage[]
) => {
if (viewOne === viewTwo) {
return true;
}

if (!Array.isArray(viewOne) || !Array.isArray(viewTwo)) {
return false;
}

return filterView(viewOne) === filterView(viewTwo);
};

Expand Down
Loading