Refactor for skeleton display implementation - #119
Draft
C-Achard wants to merge 8 commits into
Draft
Conversation
5 tasks
Contributor
There was a problem hiding this comment.
Pull request overview
Refactors display and inference APIs and introduces reusable skeleton-rendering foundations for upcoming GUI/model integrations.
Changes:
- Moves display utilities into a dedicated package.
- Extracts shared inference contracts from the DLC processor.
- Adds skeleton metadata, configuration, resolution, and rendering utilities.
Reviewed changes
Copilot reviewed 9 out of 11 changed files in this pull request and generated 2 comments.
Show a summary per file
| File | Description |
|---|---|
tests/utils/test_display.py |
Updates display imports. |
tests/services/test_dlc_processor.py |
Updates inference contract imports. |
dlclivegui/utils/stats.py |
Uses extracted processor statistics type. |
dlclivegui/services/inference/base.py |
Defines shared inference contracts and skeleton metadata. |
dlclivegui/services/inference/__init__.py |
Creates the inference package. |
dlclivegui/services/dlc_processor.py |
Adopts extracted inference contracts. |
dlclivegui/gui/main_window.py |
Uses the relocated display package. |
dlclivegui/display/skeleton.py |
Implements skeleton resolution and rendering. |
dlclivegui/display/display.py |
Houses existing display utilities. |
dlclivegui/display/__init__.py |
Exposes display utility APIs. |
dlclivegui/config.py |
Adds skeleton style configuration. |
💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.
Comment on lines
+241
to
+251
| def draw_skeleton( | ||
| frame: np.ndarray, | ||
| poses: np.ndarray | None, | ||
| skeleton: ResolvedSkeleton, | ||
| style: SkeletonStyle, | ||
| *, | ||
| p_cutoff: float, | ||
| offset: tuple[int, int] = (0, 0), | ||
| scale: tuple[float, float] = (1.0, 1.0), | ||
| keypoint_colors: tuple[BGR, ...] | None = None, | ||
| ) -> SkeletonRenderResult: |
| visible: bool = False | ||
| color_mode: SkeletonColorMode = SkeletonColorMode.SOLID | ||
| color_bgr: BGR = (0, 255, 255) # default if SOLID | ||
| thickness: int = Field(defalt=2, ge=1, le=20) # base thickness in pixels |
C-Achard
force-pushed
the
cy/skeleton-final
branch
from
August 28, 2026 13:10
eb4bbe3 to
c250d90
Compare
Update `SkeletonStyle` to support explicit visibility and clearer naming (`color_mode`, `color_bgr`), and switch numeric styling options to constrained `Field` definitions for validated thickness and gradient step ranges.
Introduce typed skeleton resolution primitives (`SkeletonEdge`, `SkeletonDefinition`, `ResolvedSkeleton`) and a `resolve_skeleton` helper that validates keypoint inputs, detects duplicates/missing names, and raises `SkeletonResolutionError` with clear messages. Also align rendering with renamed style fields (`mode` -> `color_mode`, `color` -> `color_bgr`) so initialization and draw paths use the updated `SkeletonStyle` API, and fix the module path header comment.
Move pose-related enums and dataclasses (PoseBackends, WorkerState, PoseSource, PosePacket, PoseResult) out of `dlc_processor.py` into a new `services/inference/base.py` module and import them back into the processor. This centralizes inference contracts for reuse and extends `PosePacket` with optional skeleton metadata fields (`skeleton_id`, `skeleton_edges`).
Reworks `display/skeleton.py`. It replaces the old `Skeleton` runtime/model loading stack with immutable skeleton definition/resolution dataclasses, adds validated metadata-to-definition construction, and introduces a standalone `draw_skeleton(...)` path that supports both single and multi-individual poses. Rendering now returns a structured `SkeletonRenderResult` with clearer status codes (including no-pose, invalid shape, keypoint mismatch, and gradient color mismatch) and tracks drawn edge count.
Move `ProcessorStats` from `dlc_processor` into `services.inference.base` so it can be imported as a shared inference type, and update dependent imports/tests accordingly. Add a typed `SkeletonPacket` protocol plus `resolve_packet_skeleton()` to consistently resolve packet-provided skeleton metadata into a `ResolvedSkeleton` only when required fields are present.
C-Achard
force-pushed
the
cy/skeleton-final
branch
from
August 28, 2026 13:35
c250d90 to
f63f14d
Compare
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.
Brings back the skeleton display implementation from #60, and refactors:
to be more flexible and accommodate upcoming implementations of skeleton display in #120 and POET model in #121