Repository: stable-diffusion-webui
Issue: [Bug]: face restoration error
Labels: bug-report

### Checklist

- [X] The issue exists after disabling all extensions
- [X] The issue exists on a clean installation of webui
- [ ] The issue is caused by an extension, but I believe it is caused by a bug in the webui
- [x] The issue exists in the current version of the webui
- [ ] The issue has not been reported before recently
- [ ] The issue has been reported before but has not been fixed yet

### What happened?

the only images being saved are those before face restoration

### Steps to reproduce the problem

1. Set face restoration to gfpgan
2. tick Save a copy of image before doing face restoration.
3. run xyz plot

### What should have happened?

save both images one without face restoration and one with it 

### What browsers do you use to access the UI ?

Microsoft Edge

### Sysinfo

[sysinfo-2024-02-08-10-30.json](https://github.com/AUTOMATIC1111/stable-diffusion-webui/files/14207795/sysinfo-2024-02-08-10-30.json)


### Console logs

```Shell
Already up to date.
venv "C:\StableDiffusion\stable-diffusion-webui\venv\Scripts\Python.exe"
Python 3.10.6 (tags/v3.10.6:9c7b4bd, Aug  1 2022, 21:53:49) [MSC v.1932 64 bit (AMD64)]
Version: v1.7.0
Commit hash: cf2772fab0af5573da775e7437e6acdca424f26e
Launching Web UI with arguments: --xformers --theme dark --autolaunch
Style database not found: C:\StableDiffusion\stable-diffusion-webui\styles.csv
ControlNet preprocessor location: C:\StableDiffusion\stable-diffusion-webui\extensions\sd-webui-controlnet\annotator\downloads
2024-02-08 10:58:08,157 - ControlNet - INFO - ControlNet v1.1.440
2024-02-08 10:58:08,260 - ControlNet - INFO - ControlNet v1.1.440
Loading weights [1718b5bb2d] from C:\StableDiffusion\stable-diffusion-webui\models\Stable-diffusion\albedobaseXL_v21.safetensors
2024-02-08 10:58:08,540 - ControlNet - INFO - ControlNet UI callback registered.
Running on local URL:  http://127.0.0.1:7860

To create a public link, set `share=True` in `launch()`.
Startup time: 15.0s (prepare environment: 4.3s, import torch: 3.4s, import gradio: 2.2s, setup paths: 1.8s, initialize shared: 0.2s, other imports: 1.2s, setup codeformer: 0.2s, load scripts: 0.9s, create ui: 0.4s, gradio launch: 0.4s).
Creating model from config: C:\StableDiffusion\stable-diffusion-webui\repositories\generative-models\configs\inference\sd_xl_base.yaml
Applying attention optimization: xformers... done.
Model loaded in 11.7s (load weights from disk: 1.3s, create model: 0.8s, apply weights to model: 8.8s, move model to device: 0.1s, load textual inversion embeddings: 0.1s, calculate empty prompt: 0.4s).
2024-02-08 11:01:06,806 - ControlNet - INFO - Preview Resolution = 512
Applied providers: ['CPUExecutionProvider'], with options: {'CPUExecutionProvider': {}}
find model: C:\StableDiffusion\stable-diffusion-webui\extensions\sd-webui-controlnet\annotator\downloads\insightface\models\antelopev2\1k3d68.onnx landmark_3d_68 ['None', 3, 192, 192] 0.0 1.0
Applied providers: ['CPUExecutionProvider'], with options: {'CPUExecutionProvider': {}}
find model: C:\StableDiffusion\stable-diffusion-webui\extensions\sd-webui-controlnet\annotator\downloads\insightface\models\antelopev2\2d106det.onnx landmark_2d_106 ['None', 3, 192, 192] 0.0 1.0
Applied providers: ['CPUExecutionProvider'], with options: {'CPUExecutionProvider': {}}
find model: C:\StableDiffusion\stable-diffusion-webui\extensions\sd-webui-controlnet\annotator\downloads\insightface\models\antelopev2\genderage.onnx genderage ['None', 3, 96, 96] 0.0 1.0
Applied providers: ['CPUExecutionProvider'], with options: {'CPUExecutionProvider': {}}
find model: C:\StableDiffusion\stable-diffusion-webui\extensions\sd-webui-controlnet\annotator\downloads\insightface\models\antelopev2\glintr100.onnx recognition ['None', 3, 112, 112] 127.5 127.5
Applied providers: ['CPUExecutionProvider'], with options: {'CPUExecutionProvider': {}}
find model: C:\StableDiffusion\stable-diffusion-webui\extensions\sd-webui-controlnet\annotator\downloads\insightface\models\antelopev2\scrfd_10g_bnkps.onnx detection [1, 3, '?', '?'] 127.5 128.0
set det-size: (640, 640)
C:\StableDiffusion\stable-diffusion-webui\venv\lib\site-packages\insightface\utils\transform.py:68: FutureWarning: `rcond` parameter will change to the default of machine precision times ``max(M, N)`` where M and N are the input matrix dimensions.
To use the future default and silence this warning we advise to pass `rcond=None`, to keep using the old, explicitly pass `rcond=-1`.
  P = np.linalg.lstsq(X_homo, Y)[0].T # Affine matrix. 3 x 4
2024-02-08 11:01:56,176 - ControlNet - INFO - Preview Resolution = 512
C:\StableDiffusion\stable-diffusion-webui\venv\lib\site-packages\insightface\utils\transform.py:68: FutureWarning: `rcond` parameter will change to the default of machine precision times ``max(M, N)`` where M and N are the input matrix dimensions.
To use the future default and silence this warning we advise to pass `rcond=None`, to keep using the old, explicitly pass `rcond=-1`.
  P = np.linalg.lstsq(X_homo, Y)[0].T # Affine matrix. 3 x 4
2024-02-08 11:02:01,405 - ControlNet - INFO - Preview Resolution = 2048
C:\StableDiffusion\stable-diffusion-webui\venv\lib\site-packages\insightface\utils\transform.py:68: FutureWarning: `rcond` parameter will change to the default of machine precision times ``max(M, N)`` where M and N are the input matrix dimensions.
To use the future default and silence this warning we advise to pass `rcond=None`, to keep using the old, explicitly pass `rcond=-1`.
  P = np.linalg.lstsq(X_homo, Y)[0].T # Affine matrix. 3 x 4
2024-02-08 11:03:19,941 - ControlNet - INFO - Preview Resolution = 512
2024-02-08 11:03:50,150 - ControlNet - INFO - Preview Resolution = 2048
X/Y/Z plot will create 1320 images on 11 30x4 grids. (Total steps to process: 26400)
                                  2024-02-08 11:06:18,490 - ControlNet - INFO - unit_separate = False, style_align = Falsetal progress: 0it [00:00, ?it/s]
2024-02-08 11:06:18,926 - ControlNet - INFO - Loading model: ip-adapter_instant_id_sdxl [eb2d3ec0]
2024-02-08 11:06:19,598 - ControlNet - INFO - Loaded state_dict from [C:\StableDiffusion\stable-diffusion-webui\models\ControlNet\ip-adapter_instant_id_sdxl.bin]
2024-02-08 11:06:21,481 - ControlNet - INFO - ControlNet model ip-adapter_instant_id_sdxl [eb2d3ec0](ControlModelType.IPAdapter) loaded.
2024-02-08 11:06:21,584 - ControlNet - INFO - Using preprocessor: instant_id_face_embedding
2024-02-08 11:06:21,584 - ControlNet - INFO - preprocessor resolution = 2048
C:\StableDiffusion\stable-diffusion-webui\venv\lib\site-packages\insightface\utils\transform.py:68: FutureWarning: `rcond` parameter will change to the default of machine precision times ``max(M, N)`` where M and N are the input matrix dimensions.
To use the future default and silence this warning we advise to pass `rcond=None`, to keep using the old, explicitly pass `rcond=-1`.
  P = np.linalg.lstsq(X_homo, Y)[0].T # Affine matrix. 3 x 4
2024-02-08 11:06:22,654 - ControlNet - INFO - Loading model: OpenPoseXL2 [f4251cb4]
2024-02-08 11:06:22,826 - ControlNet - INFO - Loaded state_dict from [C:\StableDiffusion\stable-diffusion-webui\models\ControlNet\OpenPoseXL2.safetensors]
2024-02-08 11:06:22,833 - ControlNet - INFO - controlnet_sdxl_config
2024-02-08 11:06:29,260 - ControlNet - INFO - ControlNet model OpenPoseXL2 [f4251cb4](ControlModelType.ControlNet) loaded.
2024-02-08 11:06:29,539 - ControlNet - INFO - Using preprocessor: openpose_full
2024-02-08 11:06:29,539 - ControlNet - INFO - preprocessor resolution = 2048
2024-02-08 11:06:40,421 - ControlNet - INFO - ControlNet Hooked - Time = 21.941341400146484
100%|██████████████████████████████████████████████████████████████████████████████████| 20/20 [00:07<00:00,  2.84it/s]
generating image for xyz plot: ValueError                                         | 20/26400 [00:29<2:15:30,  3.24it/s]
Traceback (most recent call last):
  File "C:\StableDiffusion\stable-diffusion-webui\scripts\xyz_grid.py", line 701, in cell
    res = process_images(pc)
  File "C:\StableDiffusion\stable-diffusion-webui\modules\processing.py", line 734, in process_images
    res = process_images_inner(p)
  File "C:\StableDiffusion\stable-diffusion-webui\extensions\sd-webui-controlnet\scripts\batch_hijack.py", line 41, in processing_process_images_hijack
    return getattr(processing, '__controlnet_original_process_images_inner')(p, *args, **kwargs)
  File "C:\StableDiffusion\stable-diffusion-webui\modules\processing.py", line 916, in process_images_inner
    x_sample = modules.face_restoration.restore_faces(x_sample)
  File "C:\StableDiffusion\stable-diffusion-webui\modules\face_restoration.py", line 19, in restore_faces
    return face_restorer.restore(np_image)
  File "C:\StableDiffusion\stable-diffusion-webui\modules\gfpgan_model.py", line 121, in restore
    return gfpgan_fix_faces(np_image)
  File "C:\StableDiffusion\stable-diffusion-webui\modules\gfpgan_model.py", line 60, in gfpgan_fix_faces
    model = gfpgann()
  File "C:\StableDiffusion\stable-diffusion-webui\modules\gfpgan_model.py", line 38, in gfpgann
    latest_file = max(gfp_models, key=os.path.getctime)
ValueError: max() arg is an empty sequence

2024-02-08 11:06:48,381 - ControlNet - INFO - unit_separate = False, style_align = False
2024-02-08 11:06:48,476 - ControlNet - INFO - Loading model from cache: ip-adapter_instant_id_sdxl [eb2d3ec0]
2024-02-08 11:06:48,496 - ControlNet - INFO - Using preprocessor: instant_id_face_embedding
2024-02-08 11:06:48,496 - ControlNet - INFO - preprocessor resolution = 2048
2024-02-08 11:06:48,547 - ControlNet - INFO - Loading model from cache: OpenPoseXL2 [f4251cb4]
2024-02-08 11:06:48,547 - ControlNet - INFO - Using preprocessor: openpose_full
2024-02-08 11:06:48,547 - ControlNet - INFO - preprocessor resolution = 2048
2024-02-08 11:06:48,790 - ControlNet - INFO - ControlNet Hooked - Time = 0.4149341583251953
100%|██████████████████████████████████████████████████████████████████████████████████| 20/20 [00:11<00:00,  1.68it/s]
generating image for xyz plot: ValueError                                         | 40/26400 [00:42<4:26:39,  1.65it/s]
Traceback (most recent call last):
  File "C:\StableDiffusion\stable-diffusion-webui\scripts\xyz_grid.py", line 701, in cell
    res = process_images(pc)
  File "C:\StableDiffusion\stable-diffusion-webui\modules\processing.py", line 734, in process_images
    res = process_images_inner(p)
  File "C:\StableDiffusion\stable-diffusion-webui\extensions\sd-webui-controlnet\scripts\batch_hijack.py", line 41, in processing_process_images_hijack
    return getattr(processing, '__controlnet_original_process_images_inner')(p, *args, **kwargs)
  File "C:\StableDiffusion\stable-diffusion-webui\modules\processing.py", line 916, in process_images_inner
    x_sample = modules.face_restoration.restore_faces(x_sample)
  File "C:\StableDiffusion\stable-diffusion-webui\modules\face_restoration.py", line 19, in restore_faces
    return face_restorer.restore(np_image)
  File "C:\StableDiffusion\stable-diffusion-webui\modules\gfpgan_model.py", line 121, in restore
    return gfpgan_fix_faces(np_image)
  File "C:\StableDiffusion\stable-diffusion-webui\modules\gfpgan_model.py", line 60, in gfpgan_fix_faces
    model = gfpgann()
  File "C:\StableDiffusion\stable-diffusion-webui\modules\gfpgan_model.py", line 38, in gfpgann
    latest_file = max(gfp_models, key=os.path.getctime)
ValueError: max() arg is an empty sequence

2024-02-08 11:07:01,569 - ControlNet - INFO - unit_separate = False, style_align = False
2024-02-08 11:07:01,579 - ControlNet - INFO - Loading model from cache: ip-adapter_instant_id_sdxl [eb2d3ec0]
2024-02-08 11:07:01,605 - ControlNet - INFO - Using preprocessor: instant_id_face_embedding
2024-02-08 11:07:01,605 - ControlNet - INFO - preprocessor resolution = 2048
2024-02-08 11:07:01,650 - ControlNet - INFO - Loading model from cache: OpenPoseXL2 [f4251cb4]
2024-02-08 11:07:01,655 - ControlNet - INFO - Using preprocessor: openpose_full
2024-02-08 11:07:01,655 - ControlNet - INFO - preprocessor resolution = 2048
2024-02-08 11:07:01,905 - ControlNet - INFO - ControlNet Hooked - Time = 0.33661890029907227
100%|██████████████████████████████████████████████████████████████████████████████████| 20/20 [00:06<00:00,  3.29it/s]
generating image for xyz plot: ValueError                                         | 60/26400 [00:49<2:11:03,  3.35it/s]
Traceback (most recent call last):
  File "C:\StableDiffusion\stable-diffusion-webui\scripts\xyz_grid.py", line 701, in cell
    res = process_images(pc)
  File "C:\StableDiffusion\stable-diffusion-webui\modules\processing.py", line 734, in process_images
    res = process_images_inner(p)
  File "C:\StableDiffusion\stable-diffusion-webui\extensions\sd-webui-controlnet\scripts\batch_hijack.py", line 41, in processing_process_images_hijack
    return getattr(processing, '__controlnet_original_process_images_inner')(p, *args, **kwargs)
  File "C:\StableDiffusion\stable-diffusion-webui\modules\processing.py", line 916, in process_images_inner
    x_sample = modules.face_restoration.restore_faces(x_sample)
  File "C:\StableDiffusion\stable-diffusion-webui\modules\face_restoration.py", line 19, in restore_faces
    return face_restorer.restore(np_image)
  File "C:\StableDiffusion\stable-diffusion-webui\modules\gfpgan_model.py", line 121, in restore
    return gfpgan_fix_faces(np_image)
  File "C:\StableDiffusion\stable-diffusion-webui\modules\gfpgan_model.py", line 60, in gfpgan_fix_faces
    model = gfpgann()
  File "C:\StableDiffusion\stable-diffusion-webui\modules\gfpgan_model.py", line 38, in gfpgann
    latest_file = max(gfp_models, key=os.path.getctime)
ValueError: max() arg is an empty sequence
```


### Additional information

_No response_