Skip to content

Add setting to disable ControlNet in highres fix pass #1832

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Jul 26, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions scripts/controlnet.py
Original file line number Diff line number Diff line change
Expand Up @@ -1033,6 +1033,8 @@ def on_ui_settings():
1, "Model cache size (requires restart)", gr.Slider, {"minimum": 1, "maximum": 5, "step": 1}, section=section))
shared.opts.add_option("control_net_inpaint_blur_sigma", shared.OptionInfo(
7, "ControlNet inpainting Gaussian blur sigma", gr.Slider, {"minimum": 0, "maximum": 64, "step": 1}, section=section))
shared.opts.add_option("control_net_no_high_res_fix", shared.OptionInfo(
False, "Do not apply ControlNet during highres fix", gr.Checkbox, {"interactive": True}, section=section))
shared.opts.add_option("control_net_no_detectmap", shared.OptionInfo(
False, "Do not append detectmap to output", gr.Checkbox, {"interactive": True}, section=section))
shared.opts.add_option("control_net_detectmap_autosaving", shared.OptionInfo(
Expand Down
13 changes: 12 additions & 1 deletion scripts/hook.py
Original file line number Diff line number Diff line change
Expand Up @@ -387,6 +387,8 @@ def forward(self, x, timesteps=None, context=None, **kwargs):
param.used_hint_cond_latent = None
param.used_hint_inpaint_hijack = None

no_high_res_control = is_in_high_res_fix and shared.opts.data.get("control_net_no_high_res_fix", False)

# Convert control image to latent
for param in outer.control_params:
if param.used_hint_cond_latent is not None:
Expand All @@ -399,6 +401,9 @@ def forward(self, x, timesteps=None, context=None, **kwargs):

# handle prompt token control
for param in outer.control_params:
if no_high_res_control:
continue

if param.guidance_stopped:
continue

Expand All @@ -414,6 +419,9 @@ def forward(self, x, timesteps=None, context=None, **kwargs):

# handle ControlNet / T2I_Adapter
for param in outer.control_params:
if no_high_res_control:
continue

if param.guidance_stopped:
continue

Expand Down Expand Up @@ -524,6 +532,9 @@ def forward(self, x, timesteps=None, context=None, **kwargs):

# Handle attention and AdaIn control
for param in outer.control_params:
if no_high_res_control:
continue

if param.guidance_stopped:
continue

Expand Down Expand Up @@ -605,7 +616,7 @@ def forward(self, x, timesteps=None, context=None, **kwargs):
continue

k = int(param.preprocessor['threshold_a'])
if is_in_high_res_fix:
if is_in_high_res_fix and not no_high_res_control:
k *= 2

# Inpaint hijack
Expand Down