ERROR - Failed to swap face in postprocess method : apply_overlay() takes 3 positional arguments but 4 were given #178
Reference in New Issue
Block a user
Delete Branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Getting this error when doing a basic faceswap: Not sure if there was an update to SD or a1111 but this same action worked a couple days ago.
2024-03-02 11:56:33,232 - FaceSwapLab - INFO - blend all faces together
2024-03-02 11:56:33,267 - FaceSwapLab - INFO - loading face Max.safetensors
2024-03-02 11:56:33,267 - FaceSwapLab - INFO - Int Gender : 0
2024-03-02 11:56:33,267 - FaceSwapLab - INFO - Process face 0
2024-03-02 11:56:33,275 - FaceSwapLab - INFO - Source Gender 0
2024-03-02 11:56:33,275 - FaceSwapLab - INFO - Target faces count : 1
2024-03-02 11:56:33,275 - FaceSwapLab - INFO - swap face 0
2024-03-02 11:56:34,283 - FaceSwapLab - INFO - ********************************************************************************
2024-03-02 11:56:34,323 - FaceSwapLab - INFO - Inswapper
2024-03-02 11:56:34,323 - FaceSwapLab - INFO - ********************************************************************************
2024-03-02 11:56:34,403 - FaceSwapLab - INFO - Finished processing image, return 1 images
2024-03-02 11:56:34,403 - FaceSwapLab - INFO - 1 images swapped
2024-03-02 11:56:34,403 - FaceSwapLab - ERROR - Failed to swap face in postprocess method : apply_overlay() takes 3 positional arguments but 4 were given
Traceback (most recent call last):
File "C:\a1111\stable-diffusion-webui\extensions\sd-webui-faceswaplab\scripts\faceswaplab.py", line 201, in postprocess
swp_img = imgutils.apply_mask(swp_img, p, batch_index)
File "C:\a1111\stable-diffusion-webui\extensions\sd-webui-faceswaplab\scripts\faceswaplab_utils\imgutils.py", line 224, in apply_mask
img = processing.apply_overlay(img, p.paste_to, batch_index, p.overlay_images)
TypeError: apply_overlay() takes 3 positional arguments but 4 were given
I've been messing with the settings since it popped up on me yesterday.
It seems to only occur when you have "Swap in generated image" ticked in i2i.
Massive failure, everyone is waiting for a solution.
There is a malfunction in i2i. If you uncheck:
But in a separate FaceSwapLab tab on the main panel, it works fine, but it's inconvenient.
The error has to do with the updated processing.py modules in a1111.
In your faceswaplab's extension folder, find imgutils.py inside /faceswaplab_utils/ folder
go to line 224 or where it says:
img = processing.apply_overlay(img, p.paste_to, batch_index, p.overlay_images)change it to:
if p.overlay_images and batch_index < len(p.overlay_images):selected_overlay = p.overlay_images[batch_index]img = processing.apply_overlay(img, p.paste_to, selected_overlay)else:return imglogger.debug("No overlay selected or overlay list is empty.")See if it helps.
If anybody has another solution, please share
This solution did not help. It gave an error and turned off the faceswaplab module.
Same. Get this error text
Worth a shot though
antorio's solution works for me.
I had the exactly same issue - After upgrade A1111 to v1.8.0, faecswaplab just throws the fore-mentioned error message and stop working under img2img.
I have manually applied the code changes as Antorio suggested, it works fine on v1.8.0 of A1111.
Antorio, THANKS!
@sanora87 @cMoTp10 ,

make sure you write it in the right python indentation format. Don't just paste it down.
My friend, thank you very much. My problem really was in the indent.
I brought the code back to normal and everything worked out. You really helped me out. I am grateful!

Many thanks @antorio!
i2i works now with that @antorio! Text2image is broke now but I'll survive without it. I don't think I used it much anyways.
Here's that error code if you wanted to see it regardless
Hello,
Facing this issue also in txt2img, hope there will be a fix soon.
Thanks
Thank you all! Took me forever to find this fix but glad it was posted. Hope T2I is fixed soon!
@jet3004 look this issue 171 with the code below it fixed faceswaplab in both txt2img and img2img
/whatever/stable-diffusion-webui/extensions/sd-webui-faceswaplab/scripts/faceswaplab_utils/imgutils.py edited and at line 224 code is like this now :
FWIW, I came here with the same problem - first time user. Then found Reactor does exactly what I need and works. It's available as a direct install from the A1111 extensions menu.
IMO, in context of face similarity with source images, Reactor doesn't render nearly as good as faceswaplab.
@antorio @ncandelier, @jet3004,
The return value of
processing.apply_overlay()differs betweensd-webui:v1.7.0andsd-webui:v1.8.0.Therefore, we need to make the following changes:
Now img2img(inpaint) and txt2img is work.
apply_overlay()function's return value inv1.7.0:apply_overlay()function's return value inv1.8.0:Thank you - this worked for me.
3Q
hi , i have this error .. using latest A1111 v1.9
i already change code from antorio . still not fix
edit : ok working now , i forget to follow python code format .
cant just copy paste , have to follow code format to make it working
Hi There, I have the same problem on Sd v1.9.4. Below is what i have changed. Still having an issue. please help as I dont want to use reactor :)
You're missing a space around the underscore on line 227.