An option for troubleshooting

main
a2569875 2023-04-23 20:05:17 +08:00
parent 5c48f9057a
commit 192f351663
1 changed files with 14 additions and 5 deletions

View File

@ -40,10 +40,18 @@ class ComposableLoraScript(scripts.Script):
opt_uc_diffusion_model = gr.Checkbox(value=False, label="Use Lora in uc diffusion model") opt_uc_diffusion_model = gr.Checkbox(value=False, label="Use Lora in uc diffusion model")
opt_plot_lora_weight = gr.Checkbox(value=False, label="Plot the LoRA weight in all steps") opt_plot_lora_weight = gr.Checkbox(value=False, label="Plot the LoRA weight in all steps")
opt_single_no_uc = gr.Checkbox(value=False, label="Don't use LoRA in uc if there're no subprompts") opt_single_no_uc = gr.Checkbox(value=False, label="Don't use LoRA in uc if there're no subprompts")
unload_ext = gr.Checkbox(value=False, label="Unload (If you got a corrupted image, try uncheck [Enabled] and checking this option and generate an image without LoRA, and then turn off this option.)")
def enabled_changed(opt_enabled: bool, opt_unload_ext: bool):
if opt_enabled:
unload_ext.interactive=False
return False
else:
unload_ext.interactive=True
return opt_unload_ext
enabled.change(enabled_changed, inputs=[enabled, unload_ext], outputs=[unload_ext])
return [enabled, opt_composable_with_step, opt_uc_text_model_encoder, opt_uc_diffusion_model, opt_plot_lora_weight, opt_single_no_uc, unload_ext]
return [enabled, opt_composable_with_step, opt_uc_text_model_encoder, opt_uc_diffusion_model, opt_plot_lora_weight, opt_single_no_uc] def process(self, p: StableDiffusionProcessing, enabled: bool, opt_composable_with_step: bool, opt_uc_text_model_encoder: bool, opt_uc_diffusion_model: bool, opt_plot_lora_weight: bool, opt_single_no_uc: bool, unload_ext : bool):
def process(self, p: StableDiffusionProcessing, enabled: bool, opt_composable_with_step: bool, opt_uc_text_model_encoder: bool, opt_uc_diffusion_model: bool, opt_plot_lora_weight: bool, opt_single_no_uc: bool):
composable_lora.enabled = enabled composable_lora.enabled = enabled
composable_lora.opt_uc_text_model_encoder = opt_uc_text_model_encoder composable_lora.opt_uc_text_model_encoder = opt_uc_text_model_encoder
composable_lora.opt_uc_diffusion_model = opt_uc_diffusion_model composable_lora.opt_uc_diffusion_model = opt_uc_diffusion_model
@ -57,6 +65,7 @@ class ComposableLoraScript(scripts.Script):
composable_lora.backup_lora_Linear_forward = torch.nn.Linear.forward composable_lora.backup_lora_Linear_forward = torch.nn.Linear.forward
composable_lora.backup_lora_Conv2d_forward = torch.nn.Conv2d.forward composable_lora.backup_lora_Conv2d_forward = torch.nn.Conv2d.forward
if (composable_lora.should_reload() or (torch.nn.Linear.forward != composable_lora.lora_Linear_forward)): if (composable_lora.should_reload() or (torch.nn.Linear.forward != composable_lora.lora_Linear_forward)):
if enabled or not unload_ext:
torch.nn.Linear.forward = composable_lora.lora_Linear_forward torch.nn.Linear.forward = composable_lora.lora_Linear_forward
torch.nn.Conv2d.forward = composable_lora.lora_Conv2d_forward torch.nn.Conv2d.forward = composable_lora.lora_Conv2d_forward