From 23fe53abe57af832f2bebd2b3d8ac2face4527ee Mon Sep 17 00:00:00 2001 From: Alexopus Date: Fri, 25 Apr 2025 13:18:46 +0200 Subject: [PATCH] handle multiple comma-separated model names --- nodes.py | 17 +++++++++++++++-- 1 file changed, 15 insertions(+), 2 deletions(-) diff --git a/nodes.py b/nodes.py index 09de88d..7f35fd1 100644 --- a/nodes.py +++ b/nodes.py @@ -188,6 +188,19 @@ class ImageSaver: prompt=None, extra_pnginfo=None, ): + model_names = [m.strip() for m in modelname.split(',')] + modelname = model_names[0] # Use the first model as the primary one + + # Process additional model names and add to additional_hashes + for additional_model in model_names[1:]: + additional_ckpt_path = full_checkpoint_path_for(additional_model) + if additional_ckpt_path: + additional_modelhash = get_sha256(additional_ckpt_path)[:10] + # Add to additional_hashes in "name:HASH" format + if additional_hashes: + additional_hashes += "," + additional_hashes += f"{additional_model}:{additional_modelhash}" + filename = make_filename(filename, width, height, seed_value, modelname, counter, time_format, sampler_name, steps, cfg, scheduler, denoise, clip_skip) path = make_pathname(path, width, height, seed_value, modelname, counter, time_format, sampler_name, steps, cfg, scheduler, denoise, clip_skip) @@ -241,10 +254,10 @@ class ImageSaver: subfolder = os.path.normpath(path) - result = ",".join(f"{Path(name.split(':')[-1]).stem + ':' if name else ''}{hash}{':' + str(weight) if weight is not None and download_civitai_data else ''}" for name, (_, weight, hash) in ({ modelname: ( ckpt_path, None, modelhash ) } | loras | embeddings | manual_entries).items()) + final_hashes = ",".join(f"{Path(name.split(':')[-1]).stem + ':' if name else ''}{hash}{':' + str(weight) if weight is not None and download_civitai_data else ''}" for name, (_, weight, hash) in ({ modelname: ( ckpt_path, None, modelhash ) } | loras | embeddings | manual_entries).items()) return { - "result": (result, a111_params), + "result": (final_hashes, a111_params), "ui": {"images": map(lambda filename: {"filename": filename, "subfolder": subfolder if subfolder != '.' else '', "type": 'output'}, filenames)}, }