diff options
author | AUTOMATIC <16777216c@gmail.com> | 2023-01-14 15:55:40 +0300 |
---|---|---|
committer | AUTOMATIC <16777216c@gmail.com> | 2023-01-14 15:55:40 +0300 |
commit | 08c6f009a5ee92dd3218a942c08e8337c26352be (patch) | |
tree | a4398b52b1fc3cac9ec9a69e9098996ed18ca11b /modules/sd_models.py | |
parent | febd2b722e80959b89a0e5966a159b4eb430c5a5 (diff) |
load hashes from cache for checkpoints that have them
add checkpoint hash to footer
Diffstat (limited to 'modules/sd_models.py')
-rw-r--r-- | modules/sd_models.py | 9 |
1 files changed, 6 insertions, 3 deletions
diff --git a/modules/sd_models.py b/modules/sd_models.py index 1fe6d11b..e5a0bc63 100644 --- a/modules/sd_models.py +++ b/modules/sd_models.py @@ -44,9 +44,11 @@ class CheckpointInfo: self.title = name
self.model_name = os.path.splitext(name.replace("/", "_").replace("\\", "_"))[0]
self.hash = model_hash(filename)
- self.ids = [self.hash, self.model_name, self.title, f'{name} [{self.hash}]']
- self.shorthash = None
- self.sha256 = None
+
+ self.sha256 = hashes.sha256_from_cache(self.filename, "checkpoint/" + self.title)
+ self.shorthash = self.sha256[0:10] if self.sha256 else None
+
+ self.ids = [self.hash, self.model_name, self.title, f'{name} [{self.hash}]'] + ([self.shorthash, self.sha256] if self.shorthash else [])
def register(self):
checkpoints_list[self.title] = self
@@ -269,6 +271,7 @@ def load_model_weights(model, checkpoint_info: CheckpointInfo, vae_file="auto"): model.sd_model_hash = sd_model_hash
model.sd_model_checkpoint = checkpoint_info.filename
model.sd_checkpoint_info = checkpoint_info
+ shared.opts.data["sd_checkpoint_hash"] = checkpoint_info.sha256
model.logvar = model.logvar.to(devices.device) # fix for training
|