Make GroundedSAMInvocation work with any input image mode (RGB, RGBA, grayscale).

This commit is contained in:
Ryan Dick 2024-07-30 15:55:57 -04:00
parent 918f77bce0
commit 6b10b59abe

View File

@ -60,7 +60,8 @@ class GroundedSAMInvocation(BaseInvocation):
@torch.no_grad()
def invoke(self, context: InvocationContext) -> ImageOutput:
image_pil = context.images.get_pil(self.image.image_name)
# The models expect a 3-channel RGB image.
image_pil = context.images.get_pil(self.image.image_name, mode="RGB")
detections = self._detect(
context=context, image=image_pil, labels=[self.prompt], threshold=self.detection_threshold