fix(studio): harden runtime integration and dependency defaults

Stabilize studio publish/visualization flow and tighten export behavior while aligning project dependencies with the monorepo runtime expectations.
This commit is contained in:
2026-03-03 17:59:56 +08:00
parent 00fcda4fe3
commit 967a10c10e
7 changed files with 122 additions and 87 deletions
+21 -55
View File
@@ -50,45 +50,24 @@ ImageArray = NDArray[np.uint8]
# COCO-format skeleton connections (17 keypoints)
# Connections are pairs of keypoint indices
SKELETON_CONNECTIONS: list[tuple[int, int]] = [
(0, 1), # nose -> left_eye
(0, 2), # nose -> right_eye
(1, 3), # left_eye -> left_ear
(2, 4), # right_eye -> right_ear
(5, 6), # left_shoulder -> right_shoulder
(5, 7), # left_shoulder -> left_elbow
(7, 9), # left_elbow -> left_wrist
(6, 8), # right_shoulder -> right_elbow
(0, 1), # nose -> left_eye
(0, 2), # nose -> right_eye
(1, 3), # left_eye -> left_ear
(2, 4), # right_eye -> right_ear
(5, 6), # left_shoulder -> right_shoulder
(5, 7), # left_shoulder -> left_elbow
(7, 9), # left_elbow -> left_wrist
(6, 8), # right_shoulder -> right_elbow
(8, 10), # right_elbow -> right_wrist
(11, 12), # left_hip -> right_hip
(11, 12), # left_hip -> right_hip
(5, 11), # left_shoulder -> left_hip
(6, 12), # right_shoulder -> right_hip
(11, 13), # left_hip -> left_knee
(13, 15), # left_knee -> left_ankle
(12, 14), # right_hip -> right_knee
(14, 16), # right_knee -> right_ankle
(11, 13), # left_hip -> left_knee
(13, 15), # left_knee -> left_ankle
(12, 14), # right_hip -> right_knee
(14, 16), # right_knee -> right_ankle
]
# Keypoint names for COCO format (17 keypoints)
KEYPOINT_NAMES: list[str] = [
"nose", "left_eye", "right_eye", "left_ear", "right_ear",
"left_shoulder", "right_shoulder", "left_elbow", "right_elbow",
"left_wrist", "right_wrist", "left_hip", "right_hip",
"left_knee", "right_knee", "left_ankle", "right_ankle"
]
# Joints where angles are typically calculated (for scoliosis/ gait analysis)
ANGLE_JOINTS: list[tuple[int, int, int]] = [
(5, 7, 9), # left_shoulder -> left_elbow -> left_wrist
(6, 8, 10), # right_shoulder -> right_elbow -> right_wrist
(7, 5, 11), # left_elbow -> left_shoulder -> left_hip
(8, 6, 12), # right_elbow -> right_shoulder -> right_hip
(5, 11, 13), # left_shoulder -> left_hip -> left_knee
(6, 12, 14), # right_shoulder -> right_hip -> right_knee
(11, 13, 15),# left_hip -> left_knee -> left_ankle
(12, 14, 16),# right_hip -> right_knee -> right_ankle
]
class OpenCVVisualizer:
def __init__(self) -> None:
@@ -210,7 +189,7 @@ class OpenCVVisualizer:
if pose_data is None:
return
keypoints_obj = pose_data.get('keypoints')
keypoints_obj = pose_data.get("keypoints")
if keypoints_obj is None:
return
@@ -222,7 +201,7 @@ class OpenCVVisualizer:
h, w = frame.shape[:2]
# Get confidence scores if available
confidence_obj = pose_data.get('confidence')
confidence_obj = pose_data.get("confidence")
confidences = (
np.asarray(confidence_obj, dtype=np.float32)
if confidence_obj is not None
@@ -267,7 +246,7 @@ class OpenCVVisualizer:
if pose_data is None:
return
angles_obj = pose_data.get('angles')
angles_obj = pose_data.get("angles")
if angles_obj is None:
return
@@ -467,12 +446,10 @@ class OpenCVVisualizer:
def _prepare_segmentation_view(
self,
mask_raw: ImageArray | None,
_mask_raw: ImageArray | None,
silhouette: NDArray[np.float32] | None,
bbox: BBoxXYXY | None,
_bbox: BBoxXYXY | None,
) -> ImageArray:
_ = mask_raw
_ = bbox
return self._prepare_normalized_view(silhouette)
def _fit_gray_to_display(
@@ -661,20 +638,7 @@ class OpenCVVisualizer:
y_pos = h - 8
y_top = max(0, h - MODE_LABEL_PAD)
_ = cv2.rectangle(
image,
(0, y_top),
(w, h),
COLOR_DARK_GRAY,
-1,
)
_ = cv2.rectangle(
image,
(x_pos - 6, y_pos - text_height - 6),
(x_pos + text_width + 8, y_pos + 6),
COLOR_DARK_GRAY,
-1,
)
_ = cv2.rectangle(image, (0, y_top), (w, h), COLOR_DARK_GRAY, -1)
# Draw text
_ = cv2.putText(
@@ -706,9 +670,11 @@ class OpenCVVisualizer:
Args:
frame: Input frame (H, W, C) uint8
bbox: Bounding box in XYXY format (x1, y1, x2, y2) or None
bbox_mask: Bounding box in mask coordinates (x1, y1, x2, y2) or None
track_id: Tracking ID
mask_raw: Raw binary mask (H, W) uint8 or None
silhouette: Normalized silhouette (64, 44) float32 [0,1] or None
segmentation_input: Windowed silhouette stack for model input visualization
label: Classification label or None
confidence: Classification confidence [0,1] or None
fps: Current FPS