easier load_args function, and shorter too
parent
ab8650a32c
commit
58c7889eda
|
|
@ -10,43 +10,26 @@ import logging
|
||||||
def get_keys_to_exclude():
|
def get_keys_to_exclude():
|
||||||
return ["n_batch", "seed_enable_extras", "save_samples", "display_samples", "show_sample_per_step", "filename_format", "from_img2img_instead_of_link", "scale", "subseed", "subseed_strength", "C", "f", "init_latent", "init_sample", "init_c", "noise_mask", "seed_internal", "perlin_w", "perlin_h", "mp4_path", "image_path", "output_format","render_steps","path_name_modifier"]
|
return ["n_batch", "seed_enable_extras", "save_samples", "display_samples", "show_sample_per_step", "filename_format", "from_img2img_instead_of_link", "scale", "subseed", "subseed_strength", "C", "f", "init_latent", "init_sample", "init_c", "noise_mask", "seed_internal", "perlin_w", "perlin_h", "mp4_path", "image_path", "output_format","render_steps","path_name_modifier"]
|
||||||
|
|
||||||
def load_args(args_dict,anim_args_dict, parseq_args_dict, loop_args_dict, controlnet_args_dict, custom_settings_file, root):
|
def load_args(args_dict, anim_args_dict, parseq_args_dict, loop_args_dict, controlnet_args_dict, custom_settings_file, root):
|
||||||
print(f"reading custom settings from {custom_settings_file}")
|
print(f"reading custom settings from {custom_settings_file}")
|
||||||
if not os.path.isfile(custom_settings_file):
|
if not os.path.isfile(custom_settings_file):
|
||||||
print('The custom settings file does not exist. The in-notebook settings will be used instead')
|
print('Custom settings file does not exist. Using in-notebook settings.')
|
||||||
else:
|
return
|
||||||
with open(custom_settings_file, "r") as f:
|
with open(custom_settings_file, "r") as f:
|
||||||
jdata = json.loads(f.read())
|
jdata = json.loads(f.read())
|
||||||
handle_deprecated_settings(jdata)
|
handle_deprecated_settings(jdata)
|
||||||
root.animation_prompts = jdata["prompts"]
|
root.animation_prompts = jdata.get("prompts", root.animation_prompts)
|
||||||
if "animation_prompts_positive" in jdata:
|
if "animation_prompts_positive" in jdata:
|
||||||
root.animation_prompts_positive = jdata["animation_prompts_positive"]
|
root.animation_prompts_positive = jdata["animation_prompts_positive"]
|
||||||
if "animation_prompts_negative" in jdata:
|
if "animation_prompts_negative" in jdata:
|
||||||
root.animation_prompts_negative = jdata["animation_prompts_negative"]
|
root.animation_prompts_negative = jdata["animation_prompts_negative"]
|
||||||
for i, k in enumerate(args_dict):
|
for dicts in [args_dict, anim_args_dict, parseq_args_dict, loop_args_dict]:
|
||||||
|
for k, v in dicts.items():
|
||||||
if k in jdata:
|
if k in jdata:
|
||||||
args_dict[k] = jdata[k]
|
dicts[k] = jdata[k]
|
||||||
else:
|
else:
|
||||||
print(f"key {k} doesn't exist in the custom settings data! using the default value of {args_dict[k]}")
|
print(f"Key {k} doesn't exist in the custom settings data! Using default value of {v}")
|
||||||
for i, k in enumerate(anim_args_dict):
|
print(args_dict, anim_args_dict, parseq_args_dict, loop_args_dict)
|
||||||
if k in jdata:
|
|
||||||
anim_args_dict[k] = jdata[k]
|
|
||||||
else:
|
|
||||||
print(f"key {k} doesn't exist in the custom settings data! using the default value of {anim_args_dict[k]}")
|
|
||||||
for i, k in enumerate(parseq_args_dict):
|
|
||||||
if k in jdata:
|
|
||||||
parseq_args_dict[k] = jdata[k]
|
|
||||||
else:
|
|
||||||
print(f"key {k} doesn't exist in the custom settings data! using the default value of {parseq_args_dict[k]}")
|
|
||||||
for i, k in enumerate(loop_args_dict):
|
|
||||||
if k in jdata:
|
|
||||||
loop_args_dict[k] = jdata[k]
|
|
||||||
else:
|
|
||||||
print(f"key {k} doesn't exist in the custom settings data! using the default value of {loop_args_dict[k]}")
|
|
||||||
print(args_dict)
|
|
||||||
print(anim_args_dict)
|
|
||||||
print(parseq_args_dict)
|
|
||||||
print(loop_args_dict)
|
|
||||||
|
|
||||||
def save_settings_from_animation_run(args, anim_args, parseq_args, loop_args, controlnet_args, video_args, root):
|
def save_settings_from_animation_run(args, anim_args, parseq_args, loop_args, controlnet_args, video_args, root):
|
||||||
args.__dict__["prompts"] = root.animation_prompts
|
args.__dict__["prompts"] = root.animation_prompts
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue