comfyui_segment_anything icon indicating copy to clipboard operation
comfyui_segment_anything copied to clipboard

Masking with GroundingDinoSAMSegment not working properly on Mac

Open minifisk opened this issue 1 year ago • 4 comments

I've set up a workflow to get the mask for the floor in a room, and given GroundingDino the prompt "floor" but it don't seem to do the masking correctly at all. I have tried this on two separate Mac's, both being M1 Macs. I've confirmed that this don't happen on PC.

Skärmavbild 2023-11-08 kl  21 42 16

I've also tried changing the threshold, and if I run it on the default "0.3" I get the following error:

Error occurred when executing GroundingDinoSAMSegment (segment anything):

cannot unpack non-iterable NoneType object

File "/Users/Alexander/Documents/AI/ComfyUI3/ComfyUI/execution.py", line 153, in recursive_execute
output_data, output_ui = get_output_data(obj, input_data_all)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/Users/Alexander/Documents/AI/ComfyUI3/ComfyUI/execution.py", line 83, in get_output_data
return_values = map_node_over_list(obj, input_data_all, obj.FUNCTION, allow_interrupt=True)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/Users/Alexander/Documents/AI/ComfyUI3/ComfyUI/execution.py", line 76, in map_node_over_list
results.append(getattr(obj, func)(**slice_dict(input_data_all, i)))
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/Users/Alexander/Documents/AI/ComfyUI3/ComfyUI/custom_nodes/comfyui_segment_anything/node.py", line 305, in main
(images, masks) = sam_segment(

Please let me know how to fix this, highly dependent on it working locally.

minifisk avatar Nov 08 '23 20:11 minifisk

Some better error checking would be nice throughout the node. I will try to add some more and submit a PR. For instance, if you try to detect something that the model does not find in the image, you will get an error, rather than just an empty mask.

ttulttul avatar Nov 10 '23 19:11 ttulttul

@ttulttul do you maybe want to join my try to push this repo to dinov2 i would setup a new fork where we can try this. but yesterday i accedently deleted the whole project ^sic so i should start all over again. but on the other hand we can declutter this code.

@minifisk your threshold is very low imagine it is the "box_threshold" of the detector. so it will try to detect every kind of floor, maybe rising the threshold will help

i will put a PR later today where i have renamed this value and also added device selector and also multimask

automasking will happen later until i have figured out how to use it with HQ models

dnl13 avatar Nov 11 '23 20:11 dnl13

@ttulttul do you maybe want to join my try to push this repo to dinov2 i would setup a new fork where we can try this. but yesterday i accedently deleted the whole project ^sic so i should start all over again. but on the other hand we can declutter this code.

Sounds good! Send me your fork.

ttulttul avatar Nov 11 '23 23:11 ttulttul

Hi Alessandro, I've started following Daniel's fork and I'll see where I can contribute there. Thank you!

On Sun, Nov 12, 2023 at 1:18 AM Alessandro Perilli @.***> wrote:

@ttulttul https://github.com/ttulttul

Daniel's Segment Anything fork: https://github.com/dnl13/comfyui_segment_anything

Dinov2 WIP implementation: https://github.com/dnl13/ComfyUI-dnl13-seg

— Reply to this email directly, view it on GitHub https://github.com/storyicon/comfyui_segment_anything/issues/14#issuecomment-1807067017, or unsubscribe https://github.com/notifications/unsubscribe-auth/AAGQHRMZNKK4OJHTZHDMBB3YECH67AVCNFSM6AAAAAA7DPG7LSVHI2DSMVQWIX3LMV43OSLTON2WKQ3PNVWWK3TUHMYTQMBXGA3DOMBRG4 . You are receiving this because you were mentioned.Message ID: @.***>

ttulttul avatar Nov 13 '23 18:11 ttulttul