comfyanonymous / ComfyUI_bitsandbytes_NF4

GNU Affero General Public License v3.0
332 stars 28 forks source link

🙏 Can't load Model without VAE and CLIP #47

Open WanderFox opened 2 months ago

WanderFox commented 2 months ago

In some cases we can use a model that doesn't contain VAE and CLIP. I propose to change code to this:

class CheckpointLoaderNF4:
    @classmethod
    def INPUT_TYPES(cls):
        return {
            "required": {
                "ckpt_name": (folder_paths.get_filename_list("checkpoints"), ),
                "only_model": ("BOOLEAN", {"default": False}),
            }
        }
    RETURN_TYPES = ("MODEL", "CLIP", "VAE")
    FUNCTION = "load_checkpoint"

    CATEGORY = "loaders"

    def load_checkpoint(self, ckpt_name, only_model):
        ckpt_path = folder_paths.get_full_path("checkpoints", ckpt_name)

        if only_model:
            model = comfy.sd.load_diffusion_model(ckpt_path, model_options={"custom_operations": OPS})
            return (model,)
        else:
            out = comfy.sd.load_checkpoint_guess_config(ckpt_path, output_vae=True, output_clip=True, embedding_directory=folder_paths.get_folder_paths("embeddings"), model_options={"custom_operations": OPS})
            return out[:3]