mirror of
https://git.datalinker.icu/kijai/ComfyUI-KJNodes.git
synced 2025-12-12 22:34:35 +08:00
Add bbox_format option for bbox visualize node
This commit is contained in:
parent
87d0cf42db
commit
2f7300dc54
@ -694,6 +694,7 @@ class BboxVisualize:
|
||||
"images": ("IMAGE",),
|
||||
"bboxes": ("BBOX",),
|
||||
"line_width": ("INT", {"default": 1,"min": 1, "max": 10, "step": 1}),
|
||||
"bbox_format": (["xywh", "xyxy"], {"default": "xywh"}),
|
||||
},
|
||||
}
|
||||
|
||||
@ -706,10 +707,17 @@ Visualizes the specified bbox on the image.
|
||||
|
||||
CATEGORY = "KJNodes/masking"
|
||||
|
||||
def visualizebbox(self, bboxes, images, line_width):
|
||||
def visualizebbox(self, bboxes, images, line_width, bbox_format):
|
||||
image_list = []
|
||||
for image, bbox in zip(images, bboxes):
|
||||
if bbox_format == "xywh":
|
||||
x_min, y_min, width, height = bbox
|
||||
elif bbox_format == "xyxy":
|
||||
x_min, y_min, x_max, y_max = bbox
|
||||
width = x_max - x_min
|
||||
height = y_max - y_min
|
||||
else:
|
||||
raise ValueError(f"Unknown bbox_format: {bbox_format}")
|
||||
|
||||
# Ensure bbox coordinates are integers
|
||||
x_min = int(x_min)
|
||||
@ -753,5 +761,3 @@ Visualizes the specified bbox on the image.
|
||||
image_list.append(img_with_bbox)
|
||||
|
||||
return (torch.cat(image_list, dim=0),)
|
||||
|
||||
return (torch.cat(image_list, dim=0),)
|
||||
Loading…
x
Reference in New Issue
Block a user