Mikubill / sd-webui-controlnet

WebUI extension for ControlNet
GNU General Public License v3.0
17.13k stars 1.97k forks source link

If "Skip img2img processing when using img2img initial image" is enabled and Batch img2img is executed, an error occurs. #182

Closed toyxyz closed 1 year ago

toyxyz commented 1 year ago

If "Skip img2img processing when using img2img initial image" is enabled and Batch img2img is executed, an error occurs.

If I disable that option there is no problem.

image

Error completing request:20,  5.63it/s]
Arguments: ('task(7yr4b1mfufzb3sd)', 5, 'masterpiece, best quality, 1girl, solo, stair, indoor, window, concrete, trash can, trash, can, gas tank, blue sky, white cloud, sniper rifle, cable, looking at viewer,', '(worst quality, low quality:1.4), watermark, artist name,', [], None, None, None, None, None, None, None, 20, 15, 4, 0, 0, False, False, 1, 1, 7, 1.5, 0.75, 1972617717.0, -1.0, 0, 0, 0, False, 768, 512, 0, 0, 32, 0, 'D:\\Desktop\\testmocap_01\\dsdsd', 'D:\\Desktop\\testmocap_01\\dsdsd\\dd', '', [], 0, 0, 0, 0, 0, 0.25, False, 7, 100, 'Constant', 0, 'Constant', 0, 4, False, False, 'LoRA', 'None', 0, 0, 'LoRA', 'None', 0, 0, 'LoRA', 'None', 0, 0, 'LoRA', 'None', 0, 0, 'LoRA', 'None', 0, 0, 'Refresh models', True, 'none', 'control_sd15_openpose [fef5e48e]', 1, None, False, 'Scale to Fit (Inner Fit)', False, False, 64, 64, 64, 1, 0.5, 0.5, 0.5, 0.5, 0.5, 0.5, 0.5, 0.5, 0.5, 0.5, 0.5, 0.5, 0.5, 0.5, 0.5, 0.5, 0.5, 0.5, 0.5, 0.5, 0.5, 0.5, 0.5, 0.5, 0.5, 0.5, 0.5, [], False, True, 'Denoised', 1.0, 0.0, 0.0, True, 'gif', 'h264', 2.0, 0.0, 0.0, False, 0.0, True, True, False, '', False, False, False, False, 'Auto', 0.5, 1, False, False, 1, False, '<ul>\n<li><code>CFG Scale</code> should be 2 or lower.</li>\n</ul>\n', True, True, '', '', True, 50, True, 1, 0, False, 1, 0, '#000000', True, False, 0, 256, 0, None, '', 0.2, 0.1, 1, 1, False, True, True, False, False, False, False, 4, 1, 4, 0.09, True, 1, 0, 7, False, False, 'Show/Hide AlphaCanvas', 384, 'Update Outpainting Size', 8, '<p style="margin-bottom:0.75em">Recommended settings: Sampling Steps: 80-100, Sampler: Euler a, Denoising strength: 0.8</p>', 128, 8, ['left', 'right', 'up', 'down'], 1, 0.05, 128, 4, 0, ['left', 'right', 'up', 'down'], False, False, 'positive', 'comma', 0, False, False, '', '<p style="margin-bottom:0.75em">Will upscale the image by the selected scale factor; use width and height sliders to set tile size</p>', 64, 0, 2, 'Positive', 0, ', ', True, 32, 1, '', 0, '', 0, '', True, False, False, False, 0, False, None, True, None, None, False, True, True, True, 0, 0, 384, 384, False, False, True, True, True, False, True, 1, False, False, 2.5, 4, 0, False, 0, 1, False, False, 'u2net', False, False, False, False, 0, 1, 384, 384, True, False, True, True, True, False, 1, True, 3, False, 3, False, 3, 1, '<p style="margin-bottom:0.75em">Will upscale the image depending on the selected target size type</p>', 512, 0, 8, 32, 64, 0.35, 32, 0, True, 2, False, 8, 0, 0, 2048, 2048, 2) {}
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'
Mikubill commented 1 year ago

Seems like batch tab handler issue.

anyway, Do not append detectmap option should help I think

ljleb commented 1 year ago

I tested the code all over again. When the checkbox Skip img2img processing when using img2img initial image is selected, the line:

is_img2img = issubclass(type(p), StableDiffusionProcessingImg2Img)

returns false because the class became StableDiffusionProcessingTxt2Img instead. Not a batch tab handler issue in this case, but it is code I wrote 😅.

We need to forward the is_img2img bool from the ui() script function instead I think, unless there is a better way to determine whether we are in a img2img ui tab or not.

The issue was introduced in the commit that introduces the checkbox: de32133d9d9d28bbb2b5dedfef131e715195a7c0. It may have been overlooked to test the code after fast-forwarding from main.