aboutsummaryrefslogtreecommitdiff
path: root/modules
diff options
context:
space:
mode:
authorAUTOMATIC1111 <16777216c@gmail.com>2023-08-30 08:54:31 +0300
committerAUTOMATIC1111 <16777216c@gmail.com>2023-08-30 08:54:41 +0300
commit503bd3fc0fa934cf2bbafdebfc02c1860bc1b8d5 (patch)
treeefd3414c5fa0ee5ccd54bf5bb6c34e96dfe3731f /modules
parent9e7de49fc5931a5d3070b6917e49ea070528c05a (diff)
keep order in list of checkpoints when loading model that doesn't have a checksum
Diffstat (limited to 'modules')
-rw-r--r--modules/sd_models.py22
1 files changed, 21 insertions, 1 deletions
diff --git a/modules/sd_models.py b/modules/sd_models.py
index 547e93c4..930d0bee 100644
--- a/modules/sd_models.py
+++ b/modules/sd_models.py
@@ -27,6 +27,24 @@ checkpoint_alisases = checkpoint_aliases # for compatibility with old name
checkpoints_loaded = collections.OrderedDict()
+def replace_key(d, key, new_key, value):
+ keys = list(d.keys())
+
+ d[new_key] = value
+
+ if key not in keys:
+ return d
+
+ index = keys.index(key)
+ keys[index] = new_key
+
+ new_d = {k: d[k] for k in keys}
+
+ d.clear()
+ d.update(new_d)
+ return d
+
+
class CheckpointInfo:
def __init__(self, filename):
self.filename = filename
@@ -91,9 +109,11 @@ class CheckpointInfo:
if self.shorthash not in self.ids:
self.ids += [self.shorthash, self.sha256, f'{self.name} [{self.shorthash}]', f'{self.name_for_extra} [{self.shorthash}]']
- checkpoints_list.pop(self.title, None)
+ old_title = self.title
self.title = f'{self.name} [{self.shorthash}]'
self.short_title = f'{self.name_for_extra} [{self.shorthash}]'
+
+ replace_key(checkpoints_list, old_title, self.title, self)
self.register()
return self.shorthash