|
import os |
|
import comfy.sd |
|
from nodes import * |
|
from folder_paths import * |
|
import random |
|
import os |
|
if __name__ == os.path.splitext(os.path.basename(__file__))[0] : |
|
from ConsoleColor import print, console, ccolor |
|
from mypath import * |
|
else: |
|
from .ConsoleColor import print, console, ccolor |
|
from .mypath import * |
|
|
|
|
|
|
|
|
|
class CheckpointLoaderSimpleText: |
|
@classmethod |
|
def INPUT_TYPES(s): |
|
t_checkpoints=folder_paths.get_filename_list("checkpoints") |
|
|
|
return { |
|
"required": { |
|
"ckpt_name": ( |
|
"STRING", { |
|
"multiline": False, |
|
"default": random.choice(t_checkpoints) |
|
} |
|
), |
|
} |
|
} |
|
RETURN_TYPES = ("MODEL", "CLIP", "VAE") |
|
FUNCTION = "load_checkpoint" |
|
|
|
CATEGORY = "loaders" |
|
|
|
def load_checkpoint(self, ckpt_name, output_vae=True, output_clip=True): |
|
print(f"[{ccolor}]ckpt_name : [/{ccolor}]", ckpt_name) |
|
ckpt_path=folder_paths.get_full_path("checkpoints", ckpt_name) |
|
if ckpt_path is None: |
|
ckpt_path=getFullPath(ckpt_name,"checkpoints") |
|
print(f"[{ccolor}]ckpt_path : [/{ccolor}]", ckpt_path) |
|
try: |
|
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 |
|
except Exception as e: |
|
console.print_exception() |
|
return |
|
|
|
|
|
|
|
|
|
|