ComfyUI-Custom-Scripts icon indicating copy to clipboard operation
ComfyUI-Custom-Scripts copied to clipboard

Add ckpt_name output to checkpoint loader.

Open nDman opened this issue 2 years ago • 5 comments

Please add ckpt_name output to checkpoint loader then we can use it in file name output, thanks.

Edit: If you go to add this in future please make it to report just file name without extension or any other info, thank you so much.

nDman avatar Dec 28 '23 20:12 nDman

Seems like I asked for something similar in #150. After reviewing the code, I think that this is actually the wrong place to ask. This repo basically patches the upstream CheckpointLoaderSimple

I learned this by modifying this: https://github.com/comfyanonymous/ComfyUI/blob/master/nodes.py#L520

class CheckpointLoaderSimple:
    @classmethod
    def INPUT_TYPES(s):
        return {"required": { "ckpt_name": (folder_paths.get_filename_list("checkpoints"), ),
                             }}
    RETURN_TYPES = ("MODEL", "CLIP", "VAE", "CKPT_NAME")
    FUNCTION = "load_checkpoint"

    CATEGORY = "loaders"

    def load_checkpoint(self, ckpt_name, output_vae=True, output_clip=True):
        ckpt_path = folder_paths.get_full_path("checkpoints", ckpt_name)
        out = comfy.sd.load_checkpoint_guess_config(
            ckpt_path,
            output_vae=True,
            output_clip=True,
            embedding_directory=folder_paths.get_folder_paths("embeddings"))
        return out[:3] + [ckpt_name]

ghostsquad avatar Jan 17 '24 03:01 ghostsquad

This could be fixed on my end, however when I get time my aim is to remove my checkpoint/lora loader nodes and enable the features on the standard nodes via settings.

pythongosssss avatar Jan 17 '24 19:01 pythongosssss

@pythongosssss I filed an upstream PR for this. Do you have the ability to approve/merge that?

ghostsquad avatar Jan 17 '24 20:01 ghostsquad

No I dont, I think there could be a more general solution - maybe the ability to "convert" (not actually convert but add) widgets as outputs like you can with inputs

pythongosssss avatar Jan 17 '24 20:01 pythongosssss

I like generalized approaches! Still need to balance short term/long term goals. For now, I'm just trying to get the checkpoint name out of the loader node so I can pass it to something else.

ghostsquad avatar Jan 18 '24 00:01 ghostsquad