Skip to content

Commit f5cfdcf

Browse files
feat: Add BoundingBox Primitive Node
1 parent b583276 commit f5cfdcf

File tree

1 file changed

+21
-3
lines changed

1 file changed

+21
-3
lines changed

invokeai/app/invocations/primitives.py

Lines changed: 21 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -485,9 +485,27 @@ class BoundingBoxOutput(BaseInvocationOutput):
485485
class BoundingBoxCollectionOutput(BaseInvocationOutput):
486486
"""Base class for nodes that output a collection of bounding boxes"""
487487

488-
collection: list[BoundingBoxField] = OutputField(
489-
description="The output bounding boxes.",
490-
)
488+
collection: list[BoundingBoxField] = OutputField(description="The output bounding boxes.", title="Bounding Boxes")
489+
490+
491+
@invocation(
492+
"bounding_box",
493+
title="Bounding Box",
494+
tags=["primitives", "segmentation", "collection", "bounding box"],
495+
category="primitives",
496+
version="1.0.0",
497+
)
498+
class BoundingBoxInvocation(BaseInvocation):
499+
"""Create a bounding box manually by supplying box coordinates"""
500+
501+
x_min: int = InputField(default=0, description="x-coordinate of the bounding box's top left vertex", title="X1")
502+
y_min: int = InputField(default=0, description="y-coordinate of the bounding box's top left vertex", title="Y1")
503+
x_max: int = InputField(default=0, description="x-coordinate of the bounding box's bottom right vertex", title="X2")
504+
y_max: int = InputField(default=0, description="y-coordinate of the bounding box's bottom right vertex", title="Y2")
505+
506+
def invoke(self, context: InvocationContext) -> BoundingBoxOutput:
507+
bounding_box = BoundingBoxField(x_min=self.x_min, y_min=self.y_min, x_max=self.x_max, y_max=self.y_max)
508+
return BoundingBoxOutput(bounding_box=bounding_box)
491509

492510

493511
# endregion

0 commit comments

Comments
 (0)