comfyanonymous / ComfyUI

The most powerful and modular diffusion model GUI, api and backend with a graph/nodes interface.
https://www.comfy.org/
GNU General Public License v3.0
55.21k stars 5.83k forks source link

Add "none" option for LoRA loader/related #626

Open space-nuko opened 1 year ago

space-nuko commented 1 year ago

It would be nice to have a None option for the LoRA loader that makes it act like a passthrough.

comfyanonymous commented 1 year ago

Setting the strengths to zero will also do that.

space-nuko commented 1 year ago

Well also there could be the case where the user has no LoRAs. Does the node work with no LoRAs to pick from?

WASasquatch commented 1 year ago

Setting the strengths to zero will also do that.

That's also two clicks and num pads plus enter away, or fiddling with precision of the incremental buttons via holding down or numerous clicks. That's a lot of work over just two clicks to select a none. If none just pass the model/clip as it came in.

fractal-fumbler commented 1 year ago

Setting the strengths to zero will also do that.

That's also two clicks and num pads plus enter away, or fiddling with precision of the incremental buttons via holding down or numerous clicks. That's a lot of work over just two clicks to select a none. If none just pass the model/clip as it came in.

i've also found out that clicking LMB on the field line and while holding LMB moving right or left changes value in field

tho i agree that none for LoRA is easier to choose and more intuitive than setting strength to zero

upd: LoRA's strength can be set to -10, so LMB isn't an option

brknsoul commented 1 year ago

Select the Lora Loader and hit Ctrl+B to bypass it.

WASasquatch commented 1 year ago

Select the Lora Loader and hit Ctrl+B to bypass it.

It's not sufficient for the API is it? You may just want to be passing LORAs as a filename from paths.

StephanGocht commented 1 year ago

It's not sufficient for the API is it? You may just want to be passing LORAs as a filename from paths.

Indeed, setting the LORA to none would be convenient for API use. However it isn't too difficult to skip/bypass nodes programmatically (where prompt contains the loaded API json file):

import copy

def input_is_from_node(value, node_id):
    return isinstance(value, list) \
        and len(value) == 2 \
        and value[0] == node_id

def bypass_node(prompt, bypassed_node_id):
    prompt = copy.deepcopy(prompt)
    bypassed_node = prompt[bypassed_node_id]
    del prompt[bypassed_node_id]

    for node in prompt.values():
        for key, value in node['inputs'].items():
            if input_is_from_node(value, bypassed_node_id):
                node['inputs'][key] = bypassed_node['inputs'][key]

    return prompt