sd-webui-controlnet icon indicating copy to clipboard operation
sd-webui-controlnet copied to clipboard

Is it possible to disable the control net in Highres.fix process?

Open 105gun opened this issue 2 years ago • 6 comments

I try to use line art to generate colored anime pics. The low resolution output is pretty good, but also out of the origin lines. While in highres process, I believe the control net is trying to fix the picture with origin lines, which may make awful pattens.

Here is an example:

Line art Line Low resolution output 02124-3569111255-1girl,Kuniform,masterpiece,simple background, Highres, just notice these strange red lines in the sky 02125-3569111255-1girl,Kuniform,masterpiece,simple background, 02126-3569111255-1girl,Kuniform,masterpiece,simple background,

I think a button on the UI disabling control net in highres can help to fix this problem.

105gun avatar Feb 15 '23 09:02 105gun

Related: #62

Mikubill avatar Feb 15 '23 09:02 Mikubill

I got a solution. My code is ugly, but I guess it's working. 02191-3719080654-1girl,Kuniform,masterpiece,simple background, 02190-3719080654-1girl,Kuniform,masterpiece,simple background, Add a checkbox QQ截图20230215212431

My method need to modify 2 files, one is ./extensions/sd-webui-controlnet/scripts/controlnet.py And another, is ./modules/processing.py

The first has been uploaded to my repo: https://github.com/105gun/sd-webui-controlnet/blob/Highres-disable/scripts/controlnet.py

While in processing.py, we just call disable_controlnet() in StableDiffusionProcessingTxt2Img/sample/save_intermediate(). This function will be called before Highres.fix.

            # highres hack
            sys.path.append('./extensions/sd-webui-controlnet')
            from scripts.controlnet import disable_controlnet
            sys.path.remove('./extensions/sd-webui-controlnet')
            disable_controlnet()
            # highres hack end

QQ截图20230219112655

I don't know if there is any way to implement similar function without modifying processing.py.

105gun avatar Feb 15 '23 13:02 105gun

Added a trick to improve quality when hires enabled. https://github.com/Mikubill/sd-webui-controlnet/blob/c2eff2c56fa46f5cbcaf827eeddbe1fd2dc65792/scripts/cldm.py#L73-L80 Image generated using your sketch:

Completely Disabled Only Mid-Control Based

Mikubill avatar Feb 15 '23 15:02 Mikubill

When I'm using Hi-res and the Hi-res upscale value is not precisely 1.5, 1.75, 2.0, etc... I'm getting this: RuntimeError: Sizes of tensors must match except in dimension 1. Expected size 28 but got size 27 for tensor number 1 in the list.

younyokel avatar Feb 16 '23 21:02 younyokel

When I'm using Hi-res and the Hi-res upscale value is not precisely 1.5, 1.75, 2.0, etc... I'm getting this: RuntimeError: Sizes of tensors must match except in dimension 1. Expected size 28 but got size 27 for tensor number 1 in the list.

Same thing happening.

Starlento avatar Feb 17 '23 11:02 Starlento

I get a tensor size error any time I have ControlNet enabled and High-res fix on, even if it is exactly 1.5 etc.

entmike avatar Feb 21 '23 01:02 entmike

Hi. This trick no longer works. Leads to an error. Is there a new solution?

WARRIORPSIX avatar Jul 24 '23 10:07 WARRIORPSIX