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

Increase maximum depth for quick-select to 16 #8021

Merged
merged 8 commits into from
Aug 26, 2024
Merged
Show file tree
Hide file tree
Changes from 7 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
1 change: 1 addition & 0 deletions CHANGELOG.unreleased.md
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,7 @@ For upgrade instructions, please check the [migration guide](MIGRATIONS.released
- The overall performance was improved (especially for the segments tab). [#7958](https://github.com/scalableminds/webknossos/pull/7958)
- The performance for the skeleton tab was improved. [#7989](https://github.com/scalableminds/webknossos/pull/7989)
- Upgraded ant icons to version 5.4. [#8007](https://github.com/scalableminds/webknossos/pull/8007)
- Increased maximum depth for ai-based quick select from 5 to 16. [#8021](https://github.com/scalableminds/webknossos/pull/8021)

### Fixed
- Fixed a bug that allowed the default newly created bounding box to appear outside the dataset. In case the whole bounding box would be outside it is created regardless. [#7892](https://github.com/scalableminds/webknossos/pull/7892)
Expand Down
4 changes: 3 additions & 1 deletion app/controllers/DatasetController.scala
Original file line number Diff line number Diff line change
Expand Up @@ -418,7 +418,9 @@ class DatasetController @Inject()(userService: UserService,
datastoreClient <- datasetService.clientFor(dataset)(GlobalAccessContext)
targetMagSelectedBbox: BoundingBox = request.body.surroundingBoundingBox / request.body.mag
_ <- bool2Fox(targetMagSelectedBbox.size.sorted.z <= 1024 && targetMagSelectedBbox.size.sorted.y <= 1024) ?~> s"Target-mag selected bbox must be smaller than 1024×1024×depth (or transposed), got ${targetMagSelectedBbox.size}"
_ <- bool2Fox(targetMagSelectedBbox.size.sorted.x <= 12) ?~> s"Target-mag selected bbox depth must be at most 12"
// The maximum depth of 16 also needs to be adapted in the front-end
// (at the time of writing, in MAX_DEPTH_FOR_SAM in quick_select_settings.tsx).
_ <- bool2Fox(targetMagSelectedBbox.size.sorted.x <= 16) ?~> s"Target-mag selected bbox depth must be at most 16"
philippotto marked this conversation as resolved.
Show resolved Hide resolved
_ <- bool2Fox(targetMagSelectedBbox.size.sorted.z == targetMagSelectedBbox.size.sorted.y) ?~> s"Target-mag selected bbox must equally sized long edges, got ${targetMagSelectedBbox.size}"
_ <- Fox.runIf(request.body.interactionType == SAMInteractionType.BOUNDING_BOX)(
bool2Fox(request.body.selectionTopLeftX.isDefined &&
Expand Down
13 changes: 9 additions & 4 deletions frontend/javascripts/oxalis/model/sagas/quick_select_ml_saga.ts
Original file line number Diff line number Diff line change
Expand Up @@ -257,17 +257,22 @@ export default function* performQuickSelect(
const userBoxRelativeToMaskInMag = userBoxInMag.offset(V3.negate(maskBoxInMag.min));

let wOffset = 0;
const currentEstimationInputForBBoxEstimation = {
min: userBoxRelativeToMaskInMag.getMinUV(activeViewport),
max: userBoxRelativeToMaskInMag.getMaxUV(activeViewport),
};
for (const mask of masks) {
const targetW = alignedUserBoxMag1.min[thirdDim] + labeledResolution[thirdDim] * wOffset;

const { min: minUV, max: maxUV } = estimateBBoxInMask(
mask,
{
min: userBoxRelativeToMaskInMag.getMinUV(activeViewport),
max: userBoxRelativeToMaskInMag.getMaxUV(activeViewport),
},
currentEstimationInputForBBoxEstimation,
MAXIMUM_PADDING_ERROR,
);
// Use the estimated bbox as input for the next iteration so that
// moving segments don't "exit" the used bbox at the some point in W.
currentEstimationInputForBBoxEstimation.min = minUV;
currentEstimationInputForBBoxEstimation.max = maxUV;

// Span a bbox from the estimated values (relative to the mask)
// and move it by the mask's min position to achieve a global
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,10 @@ import features from "features";
import FastTooltip from "components/fast_tooltip";
import { QuestionCircleOutlined } from "@ant-design/icons";

// The maximum depth of 16 also needs to be adapted in the back-end
// (at the time of writing, in segmentAnythingMask in DatasetController.scala).
const MAX_DEPTH_FOR_SAM = 16;

const OPTIONS_WITH_DISABLED = [
{ label: "Dark Segment", value: "dark" },
{ label: "Light Segment", value: "light" },
Expand Down Expand Up @@ -73,7 +77,7 @@ export function AiQuickSelectControls() {
label="Prediction Depth"
min={1}
value={quickSelectConfig.predictionDepth || 1}
max={5}
max={MAX_DEPTH_FOR_SAM}
step={1}
onChange={onChangePredictionDepth}
/>
Expand Down