Skip to content

Commit 1eb35d5

Browse files
committed
revise sd_model_checkpoint
1 parent 366b4c1 commit 1eb35d5

File tree

2 files changed

+19
-15
lines changed

2 files changed

+19
-15
lines changed

modules/sd_models.py

+13-10
Original file line numberDiff line numberDiff line change
@@ -74,17 +74,20 @@ def __init__(self, sd_model_name, sd_model_hash, sd_model_checkpoint, sd_checkpo
7474
shared.opts.data['sd_model_checkpoint'] = title
7575

7676
checkpoints_list[title] = CheckpointInfo(filename, title, h, short_model_name, config)
77-
77+
7878
sd_model_checkpoint = shared.opts.data['sd_model_checkpoint']
79-
sd_checkpoint_info = checkpoints_list[sd_model_checkpoint]
80-
sd_model_name = checkpoints_list[sd_model_checkpoint].model_name
81-
sd_model_hash = checkpoints_list[sd_model_checkpoint].hash
82-
shared.sd_model = SDModel(
83-
sd_model_name,
84-
sd_model_hash,
85-
sd_model_checkpoint,
86-
sd_checkpoint_info
87-
)
79+
if sd_model_checkpoint:
80+
sd_checkpoint_info = checkpoints_list[sd_model_checkpoint]
81+
sd_model_name = checkpoints_list[sd_model_checkpoint].model_name
82+
sd_model_hash = checkpoints_list[sd_model_checkpoint].hash
83+
shared.sd_model = SDModel(
84+
sd_model_name,
85+
sd_model_hash,
86+
sd_model_checkpoint,
87+
sd_checkpoint_info
88+
)
89+
else:
90+
shared.sd_model = None
8891
else:
8992
model_list = modelloader.load_models(model_path=model_path, command_path=shared.cmd_opts.ckpt_dir, ext_filter=[".ckpt"])
9093

modules/ui.py

+6-5
Original file line numberDiff line numberDiff line change
@@ -2172,14 +2172,15 @@ def user_signup(signup_username, signup_password, signup_email):
21722172
return {
21732173
signup_output: gr.update(value='Signup failed, please check and retry again')
21742174
}
2175-
2175+
21762176
def user_signout():
21772177
shared.username=''
21782178
opts.data = shared.default_options
2179-
for key in sd_models.checkpoints_list:
2180-
if sd_models.checkpoints_list[key].title == opts.data['sd_model_checkpoint']:
2181-
shared.sd_model.sd_model_name = sd_models.checkpoints_list[key].model_name
2182-
break
2179+
if 'sd_model_checkpoint' in opts.data:
2180+
for key in sd_models.checkpoints_list:
2181+
if sd_models.checkpoints_list[key].title == opts.data['sd_model_checkpoint']:
2182+
shared.sd_model.sd_model_name = sd_models.checkpoints_list[key].model_name
2183+
break
21832184

21842185
response = {
21852186
user_login_row : gr.update(visible=False),

0 commit comments

Comments
 (0)