storyicon / comfyui_segment_anything

Based on GroundingDino and SAM, use semantic strings to segment any element in an image. The comfyui version of sd-webui-segment-anything.
Apache License 2.0
675 stars 78 forks source link

How to merge multiple masks generated using multiple prompts? #33

Open JIAWENee opened 9 months ago

JIAWENee commented 9 months ago

I use the prompt word (human. cup) to obtain the mask of the person holding the cup, but GroundingDino outputs the masks of the person and the cup separately. How to merge these two masks together and output a mixed mask?

JIAWENee commented 9 months ago

The mask example is as follows:

Original drawing: OIP

Output segmentation results: ComfyUI_temp_mcldb_00004_ ComfyUI_temp_mcldb_00005_

nomadoor commented 9 months ago

スクリーンショット 2023-12-18 005140 SAM_MaskComposite.json

JIAWENee commented 9 months ago

スクリーンショット 2023-12-18 005140 SAM_MaskComposite.json

  • 出于某种原因,当我使用句点 (.) 而不是逗号 (,) 时它起作用。
  • 如果它不起作用,则为每个单词创建一个掩码并将掩码与 MaskComposite 节点组合在一起是可靠的。

Thank you for your answer. I already know that using the symbol (.) can separate two masks.

However, when using this symbol to separate two words, ComfyUI outputs two separate masks and cannot merge them. I hope these two masks can be merged into one image, and their relative positions will be the same as the original image. Is there a solution to this situation?

This is my workflow: image image

The situation I want (from someone else's example, but I don't know how to set it up): image

bihailantian655 commented 9 months ago

スクリーンショット 2023-12-18 005140 SAM_MaskComposite.json

  • For some reason, it worked when I used a period (.) instead of a comma (,).
  • If it doesn’t work, it’s reliable to create a mask for each word and combine the masks with the MaskComposite node.

not working for me (.) and (, ) get the same result ,only 1 pic {8515C784-79DD-4604-B4E3-FE7CD0697FFE}