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

add option not to run img2img when using initial image of img2img tab

Open ddPn08 opened this issue 2 years ago • 11 comments

In the img2img tab, added an option not to process img2img when obtaining the input image of ControlNet from the initial image of img2img. This enables ControlNet batch processing.

#61 #74

ddPn08 avatar Feb 16 '23 13:02 ddPn08

Might just be me, but I'm getting an error testing this: Traceback (most recent call last): File "C:\stable-diffusion-webui\modules\call_queue.py", line 56, in f res = list(func(*args, **kwargs)) File "C:\stable-diffusion-webui\modules\call_queue.py", line 37, in f res = func(*args, **kwargs) File "C:\stable-diffusion-webui\modules\img2img.py", line 163, in img2img process_batch(p, img2img_batch_input_dir, img2img_batch_output_dir, img2img_batch_inpaint_mask_dir, args) File "C:\stable-diffusion-webui\modules\img2img.py", line 76, in process_batch processed_image.save(os.path.join(output_dir, filename)) AttributeError: 'numpy.ndarray' object has no attribute 'save'

image

greyphilosophy avatar Feb 16 '23 17:02 greyphilosophy

I'm not seeing the option. Pulled to latest.

Capture

FizzleDorf avatar Feb 16 '23 18:02 FizzleDorf

@greyphilosophy You have to enable "control_net_no_detectmap" in the settings tab.

ddPn08 avatar Feb 16 '23 23:02 ddPn08

@FizzleDorf It is displayed only in the img2img tab. Also, since this is a pull request, the latest version of this repository does not reflect this change.

ddPn08 avatar Feb 16 '23 23:02 ddPn08

@greyphilosophy You have to enable "control_net_no_detectmap" in the settings tab.

Thanks, that was the problem. Is it possible for the script to set it for me and then revert it when it is finished? Or validate that I have the setting correct? Or give me an error message when it fails informing me of the missing setting? Or worst case, a tooltip on the checkbox that tells me it needs that setting enabled? Because right now it's both critical and hard to discover, which isn't a good combination.

greyphilosophy avatar Feb 17 '23 03:02 greyphilosophy

@greyphilosophy Yes, I wish I could, but unfortunately I couldn't figure out how to tell if it's batch processing or not. I'll think of another way.

ddPn08 avatar Feb 17 '23 03:02 ddPn08

@ddPn08 I just retested on a different computer using the main branch and the problem exists there too, so it's not your issue. I've conducted manual testing, and this PR, in my opinion, is working as designed and improves the quality of the extension.

Unfortunately I don't know python so I can't do a code review as well

greyphilosophy avatar Feb 17 '23 06:02 greyphilosophy

@ddPn08 Yes, I wish I could, but unfortunately I couldn't figure out how to tell if it's batch processing or not. I'll think of another way.

Just letting you know that HEAD of main should contain code that allows to detect whether img2img batch tab was last selected. You can use this variable to test whether the batch tab was last active in img2img.

Edit: ah nevermind, does not look related to this PR.

ljleb avatar Feb 17 '23 10:02 ljleb

@ljleb understood. It certainly seems unnecessary in this PR. But I didn't know this method. I learned a lot.

ddPn08 avatar Feb 17 '23 13:02 ddPn08

Looks good but maybe we should consider put this checkbox to batch tab only - for specific use (batch txt2img process).

Mikubill avatar Feb 17 '23 14:02 Mikubill

@Mikubill understood. But I can't think of a way to update the UI on tab change. . . (due to my lack of skill;) Instead, how about adding items such as "Do not execute img2img during Batch process" on the "Settings" tab?

ddPn08 avatar Feb 17 '23 14:02 ddPn08

At the risk of saying something irrelevant again: you could update the checkbox so that it disappears in other tabs than img2img batch by setting the visible attribute to True or False, depending on whether the tab is active or not. See the Img2ImgTabTracker class for img2img tab creation/selection hooks.

Another approach could be to just add the checkbox directly inside the img2img batch tab.

Just a couple ideas, wonder if there's a better way to do this.

ljleb avatar Feb 18 '23 01:02 ljleb

Doesn't the checkbox work in other img2img modes too though? I'm not sure it needs to be restricted to just batch mode

greyphilosophy avatar Feb 18 '23 02:02 greyphilosophy