feat(vit): in-pipeline live orientation auto-detect#45
Merged
Conversation
On the first batch with >=64 finite scan positions, PtychoViTInferenceOp runs ptychoml.autodetect_orientation once (forward-physics sweep of the 8 D4 candidates against the engine's baked probe) and sets ImagePreprocessorOp. dp_orient in place. ImagePreprocessorOp buffers pre-D4 frames for the sweep (_autodetect_buf, capped 256), cleared when done. Engines without a baked probe keep the configured dp_orient (logged, sweep disabled). Position convention (reproduces #37, coupled change): - PointProcessorOp default now writes col 0 = slow axis (INENC3/y_range), col 1 = fast axis (INENC2/x_range) — the hxn_to_vit convention. New position_swap_xy config (default false); set true to revert to the legacy fast->col0 assignment. - SaveViTResult canvas ranges swap to match: x_range_um=abs(param.y_range) (slow->width), y_range_um=abs(param.x_range). (This is the half deferred from H4b; columns + ranges must move together to stay consistent.) - The sweep feeds autodetect_orientation col 0 = x (fast), so positions are swapped back via ptychoml.remap_positions(swap_xy=True) — verified identical to #37's inline [[1,0]]. Reuses the merged ptychoml pieces (autodetect_orientation, remap_positions); no algorithm reimplemented. This is compose+runtime Holoscan behavior exercised by real runs; the reusable bits are ptychoml-tested and the column/ range/swap convention is audited for consistency. Suite passes (90, modulo the 2 pre-existing TILED smoke imports). H5b of the #37 decomposition (final feature PR; H6 is scripts + infra). Co-authored-by: Himanshu Goel <4122621+himanshugoel2797@users.noreply.github.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
H5b of the #37 decomposition — the live in-pipeline orientation auto-detect (final feature PR; H6 is scripts + infra). Builds on the ptychoml pieces merged in #13.
What
On the first batch with ≥64 finite scan positions,
PtychoViTInferenceOprunsptychoml.autodetect_orientationonce — a forward-physics sweep of the 8 D4 candidates against the engine's baked probe — and setsImagePreprocessorOp.dp_orientin place.ImagePreprocessorOpbuffers pre-D4 frames for the sweep (_autodetect_buf, capped 256), cleared when done. Engines without a baked probe keep the configureddp_orient(logged, sweep disabled) — so this is a no-op unless the engine was exported with--probe.Position convention (reproduces #37 — coupled change, confirmed)
This is the half deferred from H4b; columns + ranges must move together:
PointProcessorOpdefault now writes col 0 = slow axis (INENC3/y_range), col 1 = fast (INENC2/x_range) — thehxn_to_vitconvention. Newposition_swap_xyconfig (defaultfalse);truereverts to the legacy fast→col0 assignment (main's old behavior).SaveViTResultcanvas ranges swap to match:x_range_um=abs(param.y_range)(slow→width),y_range_um=abs(param.x_range).autodetect_orientationcol 0 = x (fast), so positions are swapped back viaptychoml.remap_positions(swap_xy=True)— verified identical to Enhance image processing and orientation detection in holoptycho #37's inline[[1,0]].ptychoml reuse
autodetect_orientation+remap_positionsare consumed from ptychoml — no algorithm reimplemented. (spatially_diverse_samplefrom #13 is used by the H5a CLI, not this path — the live buffer uses first-N-buffered frames.)Testing
This is compose+runtime Holoscan behavior (the
ptycho_holo/vit_inferencesmoke imports already fail on a missingTILED_BASE_URL, beforecompose), so it's not unit-testable in CI without fighting the infra. Safety net: it faithfully reproduces #37, the reusable bits are ptychoml-tested, theremap_positions(swap_xy=True)substitution is verified bit-identical to #37, and the column/range/swap convention is audited for internal consistency. No regression:position_swap_xy=truerestores the prior column convention.