diff options
author | AnyISalIn <anyisalin@gmail.com> | 2023-08-04 03:43:27 +0000 |
---|---|---|
committer | AnyISalIn <anyisalin@gmail.com> | 2023-08-04 03:43:27 +0000 |
commit | 24f21583cdba2ae6cc51773b956c6ce068d3dfe4 (patch) | |
tree | 9f7a83f96c1f39c486f08cbabe8a6ba4f8639e64 /modules/sd_models.py | |
parent | 09c1be96748584b08b6299024bb7b64bafb09d09 (diff) | |
download | stable-diffusion-webui-gfx803-24f21583cdba2ae6cc51773b956c6ce068d3dfe4.tar.gz stable-diffusion-webui-gfx803-24f21583cdba2ae6cc51773b956c6ce068d3dfe4.tar.bz2 stable-diffusion-webui-gfx803-24f21583cdba2ae6cc51773b956c6ce068d3dfe4.zip |
fix: prevent cache model.state_dict() after model hijack
Signed-off-by: AnyISalIn <anyisalin@gmail.com>
Diffstat (limited to 'modules/sd_models.py')
-rw-r--r-- | modules/sd_models.py | 5 |
1 files changed, 3 insertions, 2 deletions
diff --git a/modules/sd_models.py b/modules/sd_models.py index 1d93d893..ba15b451 100644 --- a/modules/sd_models.py +++ b/modules/sd_models.py @@ -303,12 +303,13 @@ def load_model_weights(model, checkpoint_info: CheckpointInfo, state_dict, timer sd_models_xl.extend_sdxl(model)
model.load_state_dict(state_dict, strict=False)
- del state_dict
timer.record("apply weights to model")
if shared.opts.sd_checkpoint_cache > 0:
# cache newly loaded model
- checkpoints_loaded[checkpoint_info] = model.state_dict().copy()
+ checkpoints_loaded[checkpoint_info] = state_dict
+
+ del state_dict
if shared.cmd_opts.opt_channelslast:
model.to(memory_format=torch.channels_last)
|