glucauze / sd-webui-faceswaplab

Extended faceswap extension for StableDiffusion web-ui with multiple faceswaps, inpainting, checkpoints, ....
https://glucauze.github.io/sd-webui-faceswaplab/
GNU Affero General Public License v3.0
715 stars 92 forks source link

'NoneType' object is not iterable (Inpainting automatic dev version) #77

Closed discordinated closed 11 months ago

discordinated commented 11 months ago

Describe the bug Faceswaplab breaks when I enable either preinpainting or postinpainting. With either (or both) enabled Faceswaplab errors with a 'NoneType' object is not iterable error.

Automatic1111 version: v1.6.0-RC-21-gc0f9821c  •  python: 3.10.10  •  torch: 2.0.1

FSL settings

Screenshot 2023-08-28 at 22 21 25 Screenshot 2023-08-28 at 22 24 37

The error:

2023-08-28 22:28:53,169 - FaceSwapLab - INFO - Try to use model : /Users/s/stable-diffusion-webui/models/faceswaplab/inswapper_128.onnx
2023-08-28 22:28:53,451 - FaceSwapLab - INFO - blend all faces together
2023-08-28 22:28:53,451 - FaceSwapLab - INFO - loading face test.safetensors
2023-08-28 22:28:53,451 - FaceSwapLab - INFO - Process face 0
2023-08-28 22:28:53,455 - FaceSwapLab - INFO - Source Gender 0
2023-08-28 22:28:53,455 - FaceSwapLab - INFO - Target faces count : 1
2023-08-28 22:28:53,456 - FaceSwapLab - INFO - swap face 0
2023-08-28 22:28:54,638 - FaceSwapLab - INFO - ********************************************************************************
2023-08-28 22:28:54,638 - FaceSwapLab - INFO - Inswapper
2023-08-28 22:28:54,640 - FaceSwapLab - INFO - Upscale with LDSR scale = 4
Loading model from /Users/s/stable-diffusion-webui/models/LDSR/model.ckpt
LatentDiffusionV1: Running in eps-prediction mode
Keeping EMAs of 308.
Applying attention optimization: sub-quadratic... done.
Down sample rate is 1 from 4 / 4 (Not downsampling)
Plotting: Switched to EMA weights
Sampling with eta = 1.0; steps: 200
Data shape for DDIM sampling is (1, 3, 128, 128), eta 1.0
Running DDIM Sampling with 200 timesteps
DDIM Sampler: 100%|███████████████████████████| 200/200 [00:16<00:00, 12.32it/s]
Plotting: Restored training weights
2023-08-28 22:29:30,160 - FaceSwapLab - INFO - Restore face with CodeFormer
2023-08-28 22:29:31,010 - FaceSwapLab - INFO - sharpen
2023-08-28 22:29:31,013 - FaceSwapLab - INFO - color correction
2023-08-28 22:29:31,155 - FaceSwapLab - INFO - improved_mask
2023-08-28 22:29:31,388 - FaceSwapLab - INFO - ********************************************************************************
2023-08-28 22:29:31,474 - FaceSwapLab - INFO - Inpainting face
Sampler : DPM++ 2M Karras
inpainting_denoising_strength : 0.2
inpainting_steps : 20

2023-08-28 22:29:31,474 - FaceSwapLab - INFO - send faces to image to image
2023-08-28 22:29:31,517 - FaceSwapLab - INFO - Denoising prompt : Portrait of a woman, natural skin
2023-08-28 22:29:31,517 - FaceSwapLab - INFO - Denoising strenght : 0.2
2023-08-28 22:29:31,542 - FaceSwapLab - ERROR - Failed to apply inpainting to face : 'NoneType' object is not iterable
Traceback (most recent call last):
  File "/Users/s/stable-diffusion-webui/extensions/sd-webui-faceswaplab/scripts/faceswaplab_inpainting/i2i_pp.py", line 86, in img2img_diffusion
    i2i_processed = processing.process_images(i2i_p)
  File "/Users/s/stable-diffusion-webui/modules/processing.py", line 732, in process_images
    res = process_images_inner(p)
  File "/Users/s/stable-diffusion-webui/extensions/sd-webui-controlnet/scripts/batch_hijack.py", line 42, in processing_process_images_hijack
    return getattr(processing, '__controlnet_original_process_images_inner')(p, *args, **kwargs)
  File "/Users/s/stable-diffusion-webui/modules/processing.py", line 803, in process_images_inner
    p.init(p.all_prompts, p.all_seeds, p.all_subseeds)
  File "/Users/s/stable-diffusion-webui/modules/processing.py", line 1447, in init
    for img in self.init_images:
TypeError: 'NoneType' object is not iterable
2023-08-28 22:29:31,543 - FaceSwapLab - ERROR - Failed to swap face in postprocess method : 'NoneType' object is not iterable
Traceback (most recent call last):
  File "/Users/s/stable-diffusion-webui/extensions/sd-webui-faceswaplab/scripts/faceswaplab.py", line 187, in postprocess
    swapped_images = swapper.process_images_units(
  File "/Users/s/stable-diffusion-webui/extensions/sd-webui-faceswaplab/scripts/faceswaplab_swapping/swapper.py", line 832, in process_images_units
    swapped = process_image_unit(model, units[0], image, info, force_blend)
  File "/Users/s/stable-diffusion-webui/extensions/sd-webui-faceswaplab/scripts/faceswaplab_swapping/swapper.py", line 752, in process_image_unit
    result.image = img2img_diffusion(
  File "/Users/s/stable-diffusion-webui/extensions/sd-webui-faceswaplab/scripts/faceswaplab_inpainting/i2i_pp.py", line 100, in img2img_diffusion
    raise e
  File "/Users/s/stable-diffusion-webui/extensions/sd-webui-faceswaplab/scripts/faceswaplab_inpainting/i2i_pp.py", line 86, in img2img_diffusion
    i2i_processed = processing.process_images(i2i_p)
  File "/Users/s/stable-diffusion-webui/modules/processing.py", line 732, in process_images
    res = process_images_inner(p)
  File "/Users/s/stable-diffusion-webui/extensions/sd-webui-controlnet/scripts/batch_hijack.py", line 42, in processing_process_images_hijack
    return getattr(processing, '__controlnet_original_process_images_inner')(p, *args, **kwargs)
  File "/Users/s/stable-diffusion-webui/modules/processing.py", line 803, in process_images_inner
    p.init(p.all_prompts, p.all_seeds, p.all_subseeds)
  File "/Users/s/stable-diffusion-webui/modules/processing.py", line 1447, in init
    for img in self.init_images:
TypeError: 'NoneType' object is not iterable

List of extensions:

Stable-Diffusion-Webui-Civitai-Helper
a1111-sd-webui-tagcomplete
adetailer
embedding-inspector
multidiffusion-upscaler-for-automatic1111
sd-civitai-browser-plus
sd-dynamic-prompts
sd-extension-system-info
sd-webui-agent-scheduler
sd-webui-aspect-ratio-helper
sd-webui-controlnet
sd-webui-faceswaplab
sd-webui-llul
sd-webui-supermerger
sd_delete_button
stable-diffusion-webui-embedding-editor
stable-diffusion-webui-embedding-merge
stable-diffusion-webui-images-browser
stable-diffusion-webui-model-toolkit
stable-diffusion-webui-wildcards
ultimate-upscale-for-automatic1111

Expected behavior Faceswaplab to do pre or post inpainting as expected.

Additional context It used to work but has randomly broken and I can't work out why. I've tried reinstallation of FSL and automatic1111 but the problem persists. The rest of Automatic1111 and other extensions work as expected. Have also tried removing ControlNet, due to seeing it's name in the error, but that made no difference.

glucauze commented 11 months ago

It seems that the image is not found. That's weird. The only change i have made on i2i_pp.py are the commented lines starting from line 69 :

https://github.com/glucauze/sd-webui-faceswaplab/blob/main/scripts/faceswaplab_inpainting/i2i_pp.py#L69

But it should not have an impact on that aspect. You can still try uncommenting them.

Do you remember when it starts not working ? Did you try a previous release : https://github.com/glucauze/sd-webui-faceswaplab/releases ?

It's working on my side.

discordinated commented 11 months ago

I rolled back automatic to master and it works again. Something in the dev branch / release candidate is causing the issue.

glucauze commented 11 months ago

Ok thanks for your feedback. I found a way to fix it in dev but i need to ckeck it is working in current version.