sdwebuiapi icon indicating copy to clipboard operation
sdwebuiapi copied to clipboard

controlnet not work in inpainting task?

Open crazySyaoran opened this issue 1 year ago • 2 comments

I'm trying to use controlnet in the img2img-inpainting task:

unit1 = webuiapi.ControlNetUnit(input_image=img, module='depth', model='control_sd15_depth [fef5e48e]')
result2 = api.img2img(images=[img],
                      prompt="PHOTOREALISTIC, DREAMLIKEART, Masterpiece, best quality, 1 man, closeup of face, <lora:syaoran:1>, 1boy",
                      mask_image=Image.open("examples/ori_img/mask/FsYgWtCXsAIG1zH.png"),
                      steps=25,
                      # seed=5555,
                      cfg_scale=6.5,
                      width=680,
                      height=680,
                      denoising_strength=0.6,
                      controlnet_units=[unit1]
                      )
result2.image.save("output.png")

But seems not wok, and the automatic1111 complains:

Error running process: D:\playground\stable-diffusion-webui\extensions\sd-webui-controlnet\scripts\controlnet.py
Traceback (most recent call last):
  File "D:\playground\stable-diffusion-webui\modules\scripts.py", line 417, in process
    script.process(p, *script_args)
  File "D:\playground\stable-diffusion-webui\extensions\sd-webui-controlnet\scripts\controlnet.py", line 624, in process
    unit = self.parse_remote_call(p, unit, idx)
  File "D:\playground\stable-diffusion-webui\extensions\sd-webui-controlnet\scripts\controlnet.py", line 536, in parse_remote_call
    unit.enabled = selector(p, "control_net_enabled", unit.enabled, idx, strict=True)
AttributeError: 'str' object has no attribute 'enabled'

By the way, if i dont use the controlnet_units, everything works fine:

result2 = api.img2img(images=[img],
                      prompt="PHOTOREALISTIC, DREAMLIKEART, Masterpiece, best quality, 1 man, closeup of face, <lora:syaoran:1>, 1boy",
                      mask_image=Image.open("examples/ori_img/mask/FsYgWtCXsAIG1zH.png"),
                      steps=25,
                      # seed=5555,
                      cfg_scale=6.5,
                      width=680,
                      height=680,
                      denoising_strength=0.6,
                      #controlnet_units=[unit1]
                      )

crazySyaoran avatar Apr 04 '23 14:04 crazySyaoran

Seems that it is caused by the version mismatch between sdwebuiapi and automatic1111. Could you tell me which version of automatic1111 you are using please?

crazySyaoran avatar Apr 05 '23 14:04 crazySyaoran

just try to check the max num of controlnets you set in webui, and set the same num of controlnet units when call the api

JinShiyin avatar Apr 23 '23 10:04 JinShiyin