mirror of
https://git.datalinker.icu/kijai/ComfyUI-KJNodes.git
synced 2026-05-29 04:47:06 +08:00
SplineEditor: Return only first spline length when using multiple splines
This commit is contained in:
parent
987b9a28e4
commit
557edbae16
@ -262,6 +262,8 @@ output types:
|
|||||||
# If not nested, treat as a single list of coordinates
|
# If not nested, treat as a single list of coordinates
|
||||||
coordinate_sets = [coordinates]
|
coordinate_sets = [coordinates]
|
||||||
|
|
||||||
|
first_spline = coordinate_sets[0] if coordinate_sets else []
|
||||||
|
|
||||||
# Process each set of coordinates
|
# Process each set of coordinates
|
||||||
for coord_set in coordinate_sets:
|
for coord_set in coordinate_sets:
|
||||||
normalized = []
|
normalized = []
|
||||||
@ -293,14 +295,17 @@ output types:
|
|||||||
# Create a color map for grayscale intensities
|
# Create a color map for grayscale intensities
|
||||||
color_map = lambda y: torch.full((mask_height, mask_width, 3), y, dtype=torch.float32)
|
color_map = lambda y: torch.full((mask_height, mask_width, 3), y, dtype=torch.float32)
|
||||||
|
|
||||||
# Create image tensors for each normalized y value
|
# Create a color map for grayscale intensities (from first spline only)
|
||||||
mask_tensors = [color_map(y) for y in all_normalized_y_values]
|
color_map = lambda y: torch.full((mask_height, mask_width, 3), y, dtype=torch.float32)
|
||||||
|
mask_tensors = [color_map(y) for y in normalized_y_values]
|
||||||
masks_out = torch.stack(mask_tensors)
|
masks_out = torch.stack(mask_tensors)
|
||||||
masks_out = masks_out.repeat(repeat_output, 1, 1, 1)
|
masks_out = masks_out.repeat(repeat_output, 1, 1, 1)
|
||||||
masks_out = masks_out.mean(dim=-1)
|
masks_out = masks_out.mean(dim=-1)
|
||||||
|
|
||||||
|
single_spline_count = len(first_spline)
|
||||||
|
|
||||||
if bg_image is None:
|
if bg_image is None:
|
||||||
return (masks_out, json.dumps(coordinates if len(coordinates) > 1 else coordinates[0]), out_floats, len(out_floats), json.dumps(all_normalized))
|
return (masks_out, json.dumps(coordinates if len(coordinates) > 1 else coordinates[0]), out_floats, single_spline_count, json.dumps(all_normalized))
|
||||||
else:
|
else:
|
||||||
transform = transforms.ToPILImage()
|
transform = transforms.ToPILImage()
|
||||||
image = transform(bg_image[0].permute(2, 0, 1))
|
image = transform(bg_image[0].permute(2, 0, 1))
|
||||||
@ -313,7 +318,7 @@ output types:
|
|||||||
|
|
||||||
return {
|
return {
|
||||||
"ui": {"bg_image": [img_base64]},
|
"ui": {"bg_image": [img_base64]},
|
||||||
"result": (masks_out, json.dumps(coordinates if len(coordinates) > 1 else coordinates[0]), out_floats, len(out_floats), json.dumps(all_normalized))
|
"result": (masks_out, json.dumps(coordinates if len(coordinates) > 1 else coordinates[0]), out_floats, single_spline_count, json.dumps(all_normalized))
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user