fix single element return type

This commit is contained in:
RyanOnTheInside
2025-04-24 18:32:52 -04:00
parent 9a0e97efcb
commit 36cbf8e4ec
2 changed files with 10 additions and 1 deletions
@@ -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)
+4 -1
View File
@@ -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,)