asagi4 / comfyui-prompt-control

ComfyUI nodes for prompt editing and LoRA control
GNU General Public License v3.0
165 stars 14 forks source link

[FR] Custom mask support #44

Closed SRagy closed 4 weeks ago

SRagy commented 1 month ago

Describe what's missing A way to use nonrectangular masks.

Additional context I know it might seem slightly against the ethos of the extension, however, it would be convenient to be able to feed custom masks (e.g. hand drawn ones) into a node. Unless I'm missing something, the existing syntax limits to rectangular masks and specification is a touch clunky. If masks were taken as input, then they could be activated within the text [perhaps with a syntax like (MASK:mask1)]

This would provide a similar functionality to Automatic1111's regional prompter extension's custom masks option.

asagi4 commented 1 month ago

That's not a terrible idea. it should be pretty easy to implement a ScheduleToCondMasked node with that functionality.

asagi4 commented 1 month ago

I added an experimental implementation.

It's very lightly tested so I'm not documenting it yet, but please give it a try. Just use PCScheduleAddMasks to attach masks to the prompt schedule object and then in the prompt use IMASK(index, weight, combineop) to refer to them. (the defaults are 0, 1.0, multiply if not specified). The mask indexing starts from 0.

The node allows adding up to 4 masks in one go (they're all optional), but you can use it as many times as you need; it'll just extend the mask list.

SRagy commented 1 month ago

That was super fast, thanks! I will get back to you as soon as I've had a chance to test it, which will be some time in the next two days.