From 36cbf8e4ecba6ba5ffd0cdca8193ff8e6905e89d Mon Sep 17 00:00:00 2001 From: RyanOnTheInside <7623207+ryanontheinside@users.noreply.github.com> Date: Thu, 24 Apr 2025 18:32:52 -0400 Subject: [PATCH] fix single element return type --- .../location_landmark/universal_landmark_nodes.py | 6 ++++++ node_wrappers/utils/misc_nodes.py | 5 ++++- 2 files changed, 10 insertions(+), 1 deletion(-) diff --git a/node_wrappers/mediapipe_vision/location_landmark/universal_landmark_nodes.py b/node_wrappers/mediapipe_vision/location_landmark/universal_landmark_nodes.py index 2ceb8dc..f496bf3 100644 --- a/node_wrappers/mediapipe_vision/location_landmark/universal_landmark_nodes.py +++ b/node_wrappers/mediapipe_vision/location_landmark/universal_landmark_nodes.py @@ -7,6 +7,8 @@ import cv2 import collections import typing # Add typing for Dict hint +#TODO: consider moving base nodes to src + # Assuming types are correctly imported relative to this file's location from ....src.mediapipe_vision.types import ( FACE_LANDMARKS, HAND_LANDMARKS, POSE_LANDMARKS, @@ -123,6 +125,10 @@ class LandmarkPositionBaseNode: pres_coords.append(current_pres) is_valid_list.append(is_valid) + # Check if each list has only one element, if so return single values instead of lists + if len(x_coords) == 1: + return (x_coords[0], y_coords[0], z_coords[0], vis_coords[0], pres_coords[0], is_valid_list[0]) + return (x_coords, y_coords, z_coords, vis_coords, pres_coords, is_valid_list) diff --git a/node_wrappers/utils/misc_nodes.py b/node_wrappers/utils/misc_nodes.py index 68eae01..e724637 100644 --- a/node_wrappers/utils/misc_nodes.py +++ b/node_wrappers/utils/misc_nodes.py @@ -1083,6 +1083,9 @@ class RoundNode: CATEGORY = "utils" def round_value(self, value, decimal_places): - rounded = [round(v, decimal_places) for v in value] + if isinstance(value, (list, tuple, np.ndarray, torch.Tensor)): + rounded = [round(v, decimal_places) for v in value] + else: + rounded = round(value, decimal_places) return (rounded,)