From ebd2c48115608f06940ff310a50a7fa07afaa98b Mon Sep 17 00:00:00 2001 From: DepFA <35278260+dfaker@users.noreply.github.com> Date: Thu, 29 Sep 2022 19:08:03 +0100 Subject: [PATCH] return shortest checkpoint title match --- modules/sd_models.py | 12 +----------- 1 file changed, 1 insertion(+), 11 deletions(-) diff --git a/modules/sd_models.py b/modules/sd_models.py index a1e16d82..0e7ed905 100644 --- a/modules/sd_models.py +++ b/modules/sd_models.py @@ -62,19 +62,9 @@ def list_models(): checkpoints_list[title] = CheckpointInfo(filename, title, h, model_name) def get_closet_checkpoint_match(searchString): - checkpointValues = checkpoints_list.values() - - applicable = [info for info in checkpointValues if searchString.upper() == ''.join(info.title.rpartition('.ckpt')[0]).upper()] - - if len(applicable) == 0: - applicable = [info for info in checkpointValues if searchString.upper() == ''.join(info.title.rpartition('.ckpt')[:2]).upper()] - - if len(applicable) == 0: - applicable = [info for info in checkpointValues if searchString in info.title] - + applicable = sorted([info for info in checkpoints_list.values() if searchString in info.title], key = lambda x:len(x.title)) if len(applicable)>0: return applicable[0] - return None def model_hash(filename):