Skip to content

Commit

Permalink
XY grid correctly re-assignes model when config changes
Browse files Browse the repository at this point in the history
  • Loading branch information
random-thoughtss committed Oct 20, 2022
1 parent 708c3a7 commit 49533ee
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 3 deletions.
6 changes: 3 additions & 3 deletions modules/sd_models.py
Original file line number Diff line number Diff line change
Expand Up @@ -204,9 +204,9 @@ def load_model_weights(model, checkpoint_info):
model.sd_checkpoint_info = checkpoint_info


def load_model():
def load_model(checkpoint_info=None):
from modules import lowvram, sd_hijack
checkpoint_info = select_checkpoint()
checkpoint_info = checkpoint_info or select_checkpoint()

if checkpoint_info.config != shared.cmd_opts.config:
print(f"Loading config from: {checkpoint_info.config}")
Expand Down Expand Up @@ -249,7 +249,7 @@ def reload_model_weights(sd_model, info=None):

if sd_model.sd_checkpoint_info.config != checkpoint_info.config or should_hijack_inpainting(checkpoint_info) != should_hijack_inpainting(sd_model.sd_checkpoint_info):
checkpoints_loaded.clear()
shared.sd_model = load_model()
shared.sd_model = load_model(checkpoint_info)
return shared.sd_model

if shared.cmd_opts.lowvram or shared.cmd_opts.medvram:
Expand Down
1 change: 1 addition & 0 deletions scripts/xy_grid.py
Original file line number Diff line number Diff line change
Expand Up @@ -89,6 +89,7 @@ def apply_checkpoint(p, x, xs):
if info is None:
raise RuntimeError(f"Unknown checkpoint: {x}")
modules.sd_models.reload_model_weights(shared.sd_model, info)
p.sd_model = shared.sd_model


def confirm_checkpoints(p, xs):
Expand Down

0 comments on commit 49533ee

Please sign in to comment.