Please remember that the bug report section is not a forum. Before submitting a bug, ensure you have read the FAQ thoroughly. This helps us maintain an efficient bug tracking process. Thank you for your understanding and cooperation. Use the discussion section for anything else.
Describe the bug
Using stable-diffusion-webui-forge face is not swapped and error in the title is shown in the terminal :
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 "/whatever/stable-diffusion-webui-forge/extensions/sd-webui-faceswaplab/scripts/faceswaplab.py", line 201, in postprocess
swp_img = imgutils.apply_mask(swp_img, p, batch_index)
File "/whatever/stable-diffusion-webui-forge/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
To Reproduce
Steps to reproduce the behavior:
install stable-diffusion-webui-forge
install extension
use extension : add an image of any face, enable, check "Swap in generated image",
in "Post-Processing & Advanced Mask Options" select "Codeformer", Upscaler LDSR, check Use improved segmented mask (use pastenet to mask only the face) + Use color corrections + sharpen face,
in "Post-Inpainting (After swapping)" set Denoising strenght; select Inpainting Sampler, select sd model (experimental) "Current"
face is not swapped, error in the title shown in the terminal.
Expected behavior
face is swapped, no error.
Screenshots
none
Desktop (please complete the following information):
**Please remember that the bug report section is not a forum. Before submitting a bug, ensure you have read the FAQ thoroughly. This helps us maintain an efficient bug tracking process. Thank you for your understanding and cooperation. Use the discussion section for anything else.**
**Describe the bug**
Using [stable-diffusion-webui-forge](https://github.com/lllyasviel/stable-diffusion-webui-forge) face is not swapped and error in the title is shown in the terminal :
```
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 "/whatever/stable-diffusion-webui-forge/extensions/sd-webui-faceswaplab/scripts/faceswaplab.py", line 201, in postprocess
swp_img = imgutils.apply_mask(swp_img, p, batch_index)
File "/whatever/stable-diffusion-webui-forge/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
```
**To Reproduce**
Steps to reproduce the behavior:
1. install stable-diffusion-webui-forge
2. install extension
3. use extension : add an image of any face, enable, check "Swap in generated image",
4. in "Post-Processing & Advanced Mask Options" select "Codeformer", Upscaler LDSR, check Use improved segmented mask (use pastenet to mask only the face) + Use color corrections + sharpen face,
5. in "Post-Inpainting (After swapping)" set Denoising strenght; select Inpainting Sampler, select sd model (experimental) "Current"
7. face is not swapped, error in the title shown in the terminal.
**Expected behavior**
face is swapped, no error.
**Screenshots**
none
**Desktop (please complete the following information):**
- OS: Debian 12
- Browser Firefox
- Version 122.0.1
**Additional context**
Works 100% in [stable-diffusion-webui](https://github.com/AUTOMATIC1111/stable-diffusion-webui).
Same here in Automatic1111 [v1.8.0-RC-4-gc7808825](https://github.com/AUTOMATIC1111/stable-diffusion-webui/commit/c7808825b12cc5591012b50d93f27e4bce99ec5c)
i did get this to work by checking swap in source face (blended face) and removing the next checkbox.
https://github.com/lllyasviel/stable-diffusion-webui-forge/issues/274#issuecomment-1974829006
yeah this works but that isnt the problem, i think they are trying to use the other option which switches the face after the generation.
> i did get this to work by checking swap in source face (blended face) and removing the next checkbox.
>
> [lllyasviel/stable-diffusion-webui-forge#274 (comment)](https://github.com/lllyasviel/stable-diffusion-webui-forge/issues/274#issuecomment-1974829006)
yeah this works but that isnt the problem, i think they are trying to use the other option which switches the face after the generation.
Facing the same issue with img2img after recent update today
Traceback (most recent call last): File "D:\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 "D:\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
Facing the same issue with img2img after recent update today
`Traceback (most recent call last):
File "D:\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 "D:\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`
After messing with all the settings over and over again, it only happens when you have "Swap in generated image" ticked in i2i.
I don't know anything about programming so I'm hoping someone or the dev fixes this soon.
After messing with all the settings over and over again, it only happens when you have "Swap in generated image" ticked in i2i.
I don't know anything about programming so I'm hoping someone or the dev fixes this soon.
After messing with all the settings over and over again, it only happens when you have "Swap in generated image" ticked in i2i. I don't know anything about programming so I'm hoping someone or the dev fixes this soon.
yes, you need to check the first option "Swap in source image (blended face)" to make it work, but rendering is a bit different
> After messing with all the settings over and over again, it only happens when you have "Swap in generated image" ticked in i2i. I don't know anything about programming so I'm hoping someone or the dev fixes this soon.
yes, you need to check the first option "Swap in source image (blended face)" to make it work, but rendering is a bit different
After messing with all the settings over and over again, it only happens when you have "Swap in generated image" ticked in i2i. I don't know anything about programming so I'm hoping someone or the dev fixes this soon.
yes, you need to check the first option "Swap in source image (blended face)" to make it work, but rendering is a bit different
Rendering is different but, from what I've noticed, is terribly inaccurate compared to just using the "swap in generated image" tick. A couple days ago it worked fine - now not so much.
In the interim, I've just been using the dedicated faceswaplab tab. My work flow has changed to "finish everything but that" and then just do the rest from there.
> > After messing with all the settings over and over again, it only happens when you have "Swap in generated image" ticked in i2i. I don't know anything about programming so I'm hoping someone or the dev fixes this soon.
>
> yes, you need to check the first option "Swap in source image (blended face)" to make it work, but rendering is a bit different
Rendering is different but, from what I've noticed, is terribly inaccurate compared to just using the "swap in generated image" tick. A couple days ago it worked fine - now not so much.
In the interim, I've just been using the dedicated faceswaplab tab. My work flow has changed to "finish everything but that" and then just do the rest from there.
changes in /whatever/stable-diffusion-webui/extensions/sd-webui-faceswaplab/scripts/faceswaplab_utils/imgutils.py
# img = processing.apply_overlay(img, p.paste_to, batch_index, p.overlay_images)
# if p.color_corrections is not None and batch_index < len(p.color_corrections):
# img = processing.apply_color_correction(
# p.color_corrections[batch_index], img
# )
# return img
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 img
logger.debug("No overlay selected or overlay list is empty.")
Many thanks @antorio looks like it just works!
changes in /whatever/stable-diffusion-webui/extensions/sd-webui-faceswaplab/scripts/faceswaplab_utils/imgutils.py
```
# img = processing.apply_overlay(img, p.paste_to, batch_index, p.overlay_images)
# if p.color_corrections is not None and batch_index < len(p.color_corrections):
# img = processing.apply_color_correction(
# p.color_corrections[batch_index], img
# )
# return img
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 img
logger.debug("No overlay selected or overlay list is empty.")
```
# img = processing.apply_overlay(img, p.paste_to, batch_index, p.overlay_images)
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 img
logger.debug("No overlay selected or overlay list is empty.")
if p.color_corrections is not None and batch_index < len(p.color_corrections):
img = processing.apply_color_correction(
p.color_corrections[batch_index], img
)
return img
Fixed for me in Txt2img also
in imgutils.py check the line ident
and just quote this line :
`# img = processing.apply_overlay(img, p.paste_to, batch_index, p.overlay_images)
`
Your code should look like :
```
# img = processing.apply_overlay(img, p.paste_to, batch_index, p.overlay_images)
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 img
logger.debug("No overlay selected or overlay list is empty.")
if p.color_corrections is not None and batch_index < len(p.color_corrections):
img = processing.apply_color_correction(
p.color_corrections[batch_index], img
)
return img
```
@ncandelier many thanks! Works in txtimg and img2img now.
/whatever/stable-diffusion-webui/extensions/sd-webui-faceswaplab/scripts/faceswaplab_utils/imgutils.py edited and at line 224 code is like this now :
# img = processing.apply_overlay(img, p.paste_to, batch_index, p.overlay_images)
# if p.color_corrections is not None and batch_index < len(p.color_corrections):
# img = processing.apply_color_correction(
# p.color_corrections[batch_index], img
# )
# return img
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 img
logger.debug("No overlay selected or overlay list is empty.")
if p.color_corrections is not None and batch_index < len(p.color_corrections):
img = processing.apply_color_correction(
p.color_corrections[batch_index], img
)
return img
@ncandelier many thanks! Works in txtimg and img2img now.
/whatever/stable-diffusion-webui/extensions/sd-webui-faceswaplab/scripts/faceswaplab_utils/imgutils.py edited and at line 224 code is like this now :
```
# img = processing.apply_overlay(img, p.paste_to, batch_index, p.overlay_images)
# if p.color_corrections is not None and batch_index < len(p.color_corrections):
# img = processing.apply_color_correction(
# p.color_corrections[batch_index], img
# )
# return img
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 img
logger.debug("No overlay selected or overlay list is empty.")
if p.color_corrections is not None and batch_index < len(p.color_corrections):
img = processing.apply_color_correction(
p.color_corrections[batch_index], img
)
return img
```
Hey, I am still having this issue in July 2024 using auto 1111. I just installed a few days ago from the install from URL. Was there ever a definitive solution? I know that it was marked completed, but I still have it.
2024-07-09 23:29:53,819 - 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 "D:\Stable Diffusion\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 "D:\Stable Diffusion\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
It works most of the time in txt2img, but this is a dissapointing bug as img to img with inpainting is useful.
Hey, I am still having this issue in July 2024 using auto 1111. I just installed a few days ago from the install from URL. Was there ever a definitive solution? I know that it was marked completed, but I still have it.
2024-07-09 23:29:53,819 - 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 "D:\Stable Diffusion\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 "D:\Stable Diffusion\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
It works most of the time in txt2img, but this is a dissapointing bug as img to img with inpainting is useful.
use
sd-webui-reactor .. all working fine (same base programmig)
https://github.com/Gourieff/sd-webui-reactor
read my article for even better faces ;)
https://civitai.com/articles/5002/face-swap-with-adetailer-and-reactor
looks like an update changed processing.py (stablediffusionfolder\modules\processing.py) and changed apply_overlay to accept 3 arguments and faceswaplabs hasn't been updated to use the new function in img2img (though it's updated elsewhere).
Rather than going through to see how to set up the args properly I just swapped in the old apply_overlay right under the new one in stablediffusionfolder\modules\processing.py and changed it to apply_overlay_legacy and then in extensions\sd-webui-faceswaplab\scripts\faceswaplab_utils\imgutils.py I modified it to reference the new _legacy function.
Under the apply_overlay function (around line 90, pasted this
`def apply_overlay_legacy(image, paste_loc, index, overlays):
if overlays is None or index >= len(overlays):
return image
overlay = overlays[index]
if paste_loc is not None:
x, y, w, h = paste_loc
base_image = Image.new('RGBA', (overlay.width, overlay.height))
image = images.resize_image(1, image, w, h)
base_image.paste(image, (x, y))
image = base_image
image = image.convert('RGBA')
image.alpha_composite(overlay)
image = image.convert('RGB')
return image`
Then modified extensions\sd-webui-faceswaplab\scripts\faceswaplab_utils\imgutils.py line 224 to this: img = processing.apply_overlay_legacy(img, p.paste_to, batch_index, p.overlay_images)
ymmv but seems to work for me.
looks like an update changed processing.py (stablediffusionfolder\modules\processing.py) and changed apply_overlay to accept 3 arguments and faceswaplabs hasn't been updated to use the new function in img2img (though it's updated elsewhere).
Rather than going through to see how to set up the args properly I just swapped in the old apply_overlay right under the new one in stablediffusionfolder\modules\processing.py and changed it to apply_overlay_legacy and then in extensions\sd-webui-faceswaplab\scripts\faceswaplab_utils\imgutils.py I modified it to reference the new _legacy function.
Under the apply_overlay function (around line 90, pasted this
`def apply_overlay_legacy(image, paste_loc, index, overlays):
if overlays is None or index >= len(overlays):
return image
overlay = overlays[index]
if paste_loc is not None:
x, y, w, h = paste_loc
base_image = Image.new('RGBA', (overlay.width, overlay.height))
image = images.resize_image(1, image, w, h)
base_image.paste(image, (x, y))
image = base_image
image = image.convert('RGBA')
image.alpha_composite(overlay)
image = image.convert('RGB')
return image`
Then modified extensions\sd-webui-faceswaplab\scripts\faceswaplab_utils\imgutils.py line 224 to this:
` img = processing.apply_overlay_legacy(img, p.paste_to, batch_index, p.overlay_images) `
ymmv but seems to work for me.
@JonSingleton solution works; just be careful with the spacing - his code block got broken in the comment.
https://pastebin.com/8EaZvpTr - it should look like this, at least I think so because it works
Blocking a user prevents them from interacting with repositories, such as opening or commenting on pull requests or issues. Learn more about blocking a user.
Please remember that the bug report section is not a forum. Before submitting a bug, ensure you have read the FAQ thoroughly. This helps us maintain an efficient bug tracking process. Thank you for your understanding and cooperation. Use the discussion section for anything else.
Describe the bug
Using stable-diffusion-webui-forge face is not swapped and error in the title is shown in the terminal :
To Reproduce
Steps to reproduce the behavior:
Expected behavior
face is swapped, no error.
Screenshots
none
Desktop (please complete the following information):
Additional context
Works 100% in stable-diffusion-webui.
Same here in Automatic1111 v1.8.0-RC-4-gc7808825
Exactly the same. The only difference is the OS is Win 10 for me
Only happens in img2img for me
issue on stable-diffusion-webui-forge FaceSwapLab support #274
i did get this to work by checking swap in source face (blended face) and removing the next checkbox.
https://github.com/lllyasviel/stable-diffusion-webui-forge/issues/274#issuecomment-1974829006
yeah this works but that isnt the problem, i think they are trying to use the other option which switches the face after the generation.
Facing the same issue with img2img after recent update today
Traceback (most recent call last): File "D:\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 "D:\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 givenAfter messing with all the settings over and over again, it only happens when you have "Swap in generated image" ticked in i2i.
I don't know anything about programming so I'm hoping someone or the dev fixes this soon.
yes, you need to check the first option "Swap in source image (blended face)" to make it work, but rendering is a bit different
Rendering is different but, from what I've noticed, is terribly inaccurate compared to just using the "swap in generated image" tick. A couple days ago it worked fine - now not so much.
In the interim, I've just been using the dedicated faceswaplab tab. My work flow has changed to "finish everything but that" and then just do the rest from there.
Check my alternative solution in another thread of the same topic -> #178
Works for me on a1111 1.8.0
Many thanks @antorio looks like it just works!
changes in /whatever/stable-diffusion-webui/extensions/sd-webui-faceswaplab/scripts/faceswaplab_utils/imgutils.py
fixed for now!
The fix above only works in the img2img tab.
in txt2txt tab faceswaplab is still broken.
Fixed for me in Txt2img also
in imgutils.py check the line ident
and just quote this line :
# img = processing.apply_overlay(img, p.paste_to, batch_index, p.overlay_images)Your code should look like :
for me doesnt work ... after edit the file, same issue ...
hopfully wait for an update ;)
@ncandelier many thanks! Works in txtimg and img2img now.
/whatever/stable-diffusion-webui/extensions/sd-webui-faceswaplab/scripts/faceswaplab_utils/imgutils.py edited and at line 224 code is like this now :
Hey, I am still having this issue in July 2024 using auto 1111. I just installed a few days ago from the install from URL. Was there ever a definitive solution? I know that it was marked completed, but I still have it.
2024-07-09 23:29:53,819 - 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 "D:\Stable Diffusion\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 "D:\Stable Diffusion\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
It works most of the time in txt2img, but this is a dissapointing bug as img to img with inpainting is useful.
use
sd-webui-reactor .. all working fine (same base programmig)
https://github.com/Gourieff/sd-webui-reactor
read my article for even better faces ;)
https://civitai.com/articles/5002/face-swap-with-adetailer-and-reactor
looks like an update changed processing.py (stablediffusionfolder\modules\processing.py) and changed apply_overlay to accept 3 arguments and faceswaplabs hasn't been updated to use the new function in img2img (though it's updated elsewhere).
Rather than going through to see how to set up the args properly I just swapped in the old apply_overlay right under the new one in stablediffusionfolder\modules\processing.py and changed it to apply_overlay_legacy and then in extensions\sd-webui-faceswaplab\scripts\faceswaplab_utils\imgutils.py I modified it to reference the new _legacy function.
Under the apply_overlay function (around line 90, pasted this
`def apply_overlay_legacy(image, paste_loc, index, overlays):
if overlays is None or index >= len(overlays):
return image
Then modified extensions\sd-webui-faceswaplab\scripts\faceswaplab_utils\imgutils.py line 224 to this:
img = processing.apply_overlay_legacy(img, p.paste_to, batch_index, p.overlay_images)ymmv but seems to work for me.
@JonSingleton solution works; just be careful with the spacing - his code block got broken in the comment.
https://pastebin.com/8EaZvpTr - it should look like this, at least I think so because it works