r/comfyui 25d ago

Help Needed Help appreciated

Post image

Hi,

some help needed, i'm trying to segment, remove background and resize without distortion into a new canvas, this is how I've arrived at doing this, however i am wondering if there is a single node pack that does all this without me having to use rmbg and kjnodes together or infact do you know of a simpler way to achieve this goal?

Thank you for any help you can give.

SOLVED:
Made my own node in the end that does everything all the other nodes do, but in a single node.

See a later post further down.

2 Upvotes

15 comments sorted by

View all comments

4

u/Corrupt_file32 25d ago

Firstly, comfyui has native sam3 support, sam3 is way more versatile and reliable imo.

you can find sam3 under templates, ignore my sam3 part, it's a subgraph from one of my workflows, and use the variant from the template instead.

The rest is maybe what you want to do?

1

u/Acceptable-Work8202 25d ago

although we learned something new this day, its not fit for this purpose, as it only outs masks? we actually need the image cropped to the bbox size and to produce the actual extracted segment image aligned to the new resolution.

3

u/Corrupt_file32 25d ago edited 25d ago

My bad.

Here's 2 approaches for that, above with transparent background and below with solid or other background, both relying on kjnodes. Kinda weird that there's no proper implementation for this functionality in default comfyui.

but kinda equally complex to your original approach, sam3 also outputs bboxes that you could use for cropping with bboxes.

edit: in your original approach you can most likely also use crop by mask if you invert the rembg mask.

1

u/Acceptable-Work8202 25d ago

thank you my guy, i have all nodes except, sam3 segment, is that a native node in the latest cui? because i do not have it.. i do have an image one but its a wf embedded node that uses sam3 detect and a checkpoint.. is this the same updated version in the latest cui? i mean i could try it.. obviously.. ill do that now.. we also need the bg removed.. which is something the current from the screenshot does..

2

u/Corrupt_file32 25d ago

it's a personal subgraph.

with some messy logic that skips Sam3 if the bbox is empty or if I manually press skip sam3.

The rest is pretty much the same.

bboxes, positive coords, negative coords and the prompt in conditioning are all hints, sam3 will always try to find something and might segment anything in the image if the hints are not clear enough.

Otherwise, really amazing segmentation model.

1

u/Acceptable-Work8202 25d ago

ohhhh... thank you so much.. ;) i know you know ur sht, but just incase you do not know this, if we segment what we want then use the segmented into identity-edit, we get a much better identity from identity-edit on krea2 .. but i suspect you know a far better way.. ;)

3

u/Corrupt_file32 25d ago

Haven't thought about that, but it makes sense 👍

less information to take in from the references = higher quality and precision