GithubHelp home page GithubHelp logo

Failed to swap face in postprocess method : apply_overlay() takes 3 positional arguments but 4 were given about sd-webui-faceswaplab HOT 17 CLOSED

ali0une avatar ali0une commented on June 11, 2024 4
Failed to swap face in postprocess method : apply_overlay() takes 3 positional arguments but 4 were given

from sd-webui-faceswaplab.

Comments (17)

buzzz3d avatar buzzz3d commented on June 11, 2024 5

Only happens in img2img for me

from sd-webui-faceswaplab.

aarony1993 avatar aarony1993 commented on June 11, 2024 3

Same here in Automatic1111 v1.8.0-RC-4-gc7808825

from sd-webui-faceswaplab.

ncandelier avatar ncandelier commented on June 11, 2024 3

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

from sd-webui-faceswaplab.

ali0une avatar ali0une commented on June 11, 2024 2

issue on stable-diffusion-webui-forge FaceSwapLab support #274

from sd-webui-faceswaplab.

ali0une avatar ali0une commented on June 11, 2024 2

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.")

from sd-webui-faceswaplab.

ali0une avatar ali0une commented on June 11, 2024 2

@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

from sd-webui-faceswaplab.

sanora87 avatar sanora87 commented on June 11, 2024 1

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.

from sd-webui-faceswaplab.

antorio avatar antorio commented on June 11, 2024 1

Check my alternative solution in another thread of the same topic -> #178
Works for me on a1111 1.8.0

from sd-webui-faceswaplab.

DDanDee avatar DDanDee commented on June 11, 2024

Exactly the same. The only difference is the OS is Win 10 for me

from sd-webui-faceswaplab.

AI-Ilikeit avatar AI-Ilikeit commented on June 11, 2024

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)

from sd-webui-faceswaplab.

ChrisTello avatar ChrisTello commented on June 11, 2024

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)

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.

from sd-webui-faceswaplab.

ncandelier avatar ncandelier commented on June 11, 2024

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

from sd-webui-faceswaplab.

sanora87 avatar sanora87 commented on June 11, 2024

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.

from sd-webui-faceswaplab.

ncandelier avatar ncandelier commented on June 11, 2024

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

from sd-webui-faceswaplab.

ali0une avatar ali0une commented on June 11, 2024

fixed for now!

from sd-webui-faceswaplab.

ali0une avatar ali0une commented on June 11, 2024

The fix above only works in the img2img tab.
in txt2txt tab faceswaplab is still broken.

2024-03-10 09:13:42,621 - FaceSwapLab - INFO - Try to use model : /whatever/stable-diffusion-webui/models/faceswaplab/inswapper_128.onnx
2024-03-10 09:13:42,624 - FaceSwapLab - INFO - Load analysis model det_size=(640, 640), det_thresh=0.5, providers = ['CPUExecutionProvider'], will take some time. (> 30s)
Loading (640, 640) analysis model (first time is slow): 100%|████████████████████████████████████| 1/1 [00:00<00:00,  2.78model/s]
2024-03-10 09:13:42,984 - FaceSwapLab - INFO - ("Applied providers: ['CPUExecutionProvider'], with options: "
 "{'CPUExecutionProvider': {}}\n"
 'find model: '
 '/whatever/stable-diffusion-webui/models/faceswaplab/analysers/models/buffalo_l/1k3d68.onnx '
 "landmark_3d_68 ['None', 3, 192, 192] 0.0 1.0\n"
 "Applied providers: ['CPUExecutionProvider'], with options: "
 "{'CPUExecutionProvider': {}}\n"
 'find model: '
 '/whatever/stable-diffusion-webui/models/faceswaplab/analysers/models/buffalo_l/2d106det.onnx '
 "landmark_2d_106 ['None', 3, 192, 192] 0.0 1.0\n"
 "Applied providers: ['CPUExecutionProvider'], with options: "
 "{'CPUExecutionProvider': {}}\n"
 'find model: '
 '/whatever/stable-diffusion-webui/models/faceswaplab/analysers/models/buffalo_l/det_10g.onnx '
 "detection [1, 3, '?', '?'] 127.5 128.0\n"
 "Applied providers: ['CPUExecutionProvider'], with options: "
 "{'CPUExecutionProvider': {}}\n"
 'find model: '
 '/whatever/stable-diffusion-webui/models/faceswaplab/analysers/models/buffalo_l/genderage.onnx '
 "genderage ['None', 3, 96, 96] 0.0 1.0\n"
 "Applied providers: ['CPUExecutionProvider'], with options: "
 "{'CPUExecutionProvider': {}}\n"
 'find model: '
 '/whatever/stable-diffusion-webui/models/faceswaplab/analysers/models/buffalo_l/w600k_r50.onnx '
 "recognition ['None', 3, 112, 112] 127.5 127.5\n"
 'set det-size: (640, 640)\n')
2024-03-10 09:13:43,183 - FaceSwapLab - INFO - blend all faces together
2024-03-10 09:13:43,393 - FaceSwapLab - INFO - Int Gender : 0
2024-03-10 09:13:43,393 - FaceSwapLab - INFO - Process face 0
2024-03-10 09:13:43,394 - FaceSwapLab - INFO - Source Gender 0
Loading swap model: 100%|████████████████████████████████████████████████████████████████████████| 1/1 [00:00<00:00,  2.09model/s]
2024-03-10 09:13:43,874 - FaceSwapLab - INFO - ("Applied providers: ['CPUExecutionProvider'], with options: "
 "{'CPUExecutionProvider': {}}\n"
 'inswapper-shape: [1, 3, 128, 128]\n')
2024-03-10 09:13:43,874 - FaceSwapLab - INFO - Target faces count : 1
2024-03-10 09:13:43,874 - FaceSwapLab - INFO - swap face 0
2024-03-10 09:13:44,327 - FaceSwapLab - INFO - ********************************************************************************
2024-03-10 09:13:44,327 - FaceSwapLab - INFO - Inswapper
2024-03-10 09:13:44,329 - FaceSwapLab - INFO - Upscale with LDSR scale = 4
Loading model from /whatever/stable-diffusion-webui/models/LDSR/model.ckpt
LatentDiffusionV1: Running in eps-prediction mode
Keeping EMAs of 308.
Applying attention optimization: xformers... done.
Down sample rate is 1 from 4 / 4 (Not downsampling)
Plotting: Switched to EMA weights
Sampling with eta = 1.0; steps: 100
Data shape for DDIM sampling is (1, 3, 128, 128), eta 1.0
Running DDIM Sampling with 100 timesteps
DDIM Sampler: 100%|█████████████████████████████████████████████████████████████████████████████| 100/100 [00:05<00:00, 19.56it/s]
Plotting: Restored training weights
2024-03-10 09:13:53,058 - FaceSwapLab - INFO - Restore face with CodeFormer
2024-03-10 09:13:54,377 - FaceSwapLab - INFO - sharpen
2024-03-10 09:13:54,378 - FaceSwapLab - INFO - color correction
2024-03-10 09:13:54,566 - FaceSwapLab - INFO - improved_mask
2024-03-10 09:13:54,821 - FaceSwapLab - INFO - ********************************************************************************
2024-03-10 09:13:54,844 - FaceSwapLab - INFO - Inpainting face
Sampler : DPM++ 3M SDE Karras
inpainting_denoising_strength : 0.16
inpainting_steps : 32

2024-03-10 09:13:54,844 - FaceSwapLab - INFO - send faces to image to image
2024-03-10 09:13:54,859 - FaceSwapLab - INFO - Denoising prompt : Portrait of a woman
2024-03-10 09:13:54,859 - FaceSwapLab - INFO - Denoising strenght : 0.16
100%|███████████████████████████████████████████████████████████████████████████████████████████████| 6/6 [00:04<00:00,  1.21it/s]
2024-03-10 09:14:02,567 - FaceSwapLab - INFO - Finished processing image, return 1 images                                         
2024-03-10 09:14:02,567 - FaceSwapLab - INFO - 1 images swapped
2024-03-10 09:14:02,567 - FaceSwapLab - INFO - Add swp image to processed
Total progress: 38it [00:44,  1.17s/it]
Traceback (most recent call last):s/it]
  File "/whatever/stable-diffusion-webui/venv/lib/python3.10/site-packages/gradio/routes.py", line 488, in run_predict
    output = await app.get_blocks().process_api(
  File "/whatever/stable-diffusion-webui/venv/lib/python3.10/site-packages/gradio/blocks.py", line 1434, in process_api
    data = self.postprocess_data(fn_index, result["prediction"], state)
  File "/whatever/stable-diffusion-webui/venv/lib/python3.10/site-packages/gradio/blocks.py", line 1335, in postprocess_data
    prediction_value = block.postprocess(prediction_value)
  File "/whatever/stable-diffusion-webui/venv/lib/python3.10/site-packages/gradio/components/gallery.py", line 205, in postprocess
    raise ValueError(f"Cannot process type as image: {type(img)}")
ValueError: Cannot process type as image: <class 'NoneType'>

from sd-webui-faceswaplab.

kalle07 avatar kalle07 commented on June 11, 2024

for me doesnt work ... after edit the file, same issue ...
hopfully wait for an update ;)

from sd-webui-faceswaplab.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.