aboutsummaryrefslogtreecommitdiff
path: root/modules
diff options
context:
space:
mode:
authorDepFA <35278260+dfaker@users.noreply.github.com>2022-09-28 22:30:09 +0100
committerAUTOMATIC1111 <16777216c@gmail.com>2022-09-30 07:37:05 +0300
commit642b7e333e2d87a8d3ef0bcb13c257347a9c13ed (patch)
treea02ae5f45f887e47b65425e584a1dfea40612854 /modules
parent190fda38cb7e577a2e1bcbeccf1b29e99addfc74 (diff)
add get_closet_checkpoint_match
Diffstat (limited to 'modules')
-rw-r--r--modules/sd_models.py15
1 files changed, 15 insertions, 0 deletions
diff --git a/modules/sd_models.py b/modules/sd_models.py
index eb21e498..a1e16d82 100644
--- a/modules/sd_models.py
+++ b/modules/sd_models.py
@@ -61,6 +61,21 @@ def list_models():
title, model_name = modeltitle(filename, h)
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]
+
+ if len(applicable)>0:
+ return applicable[0]
+
+ return None
def model_hash(filename):
try: