Repository: stable-diffusion-webui
Issue: [Bug]: Image generation fails after one image is generated
Labels: asking-for-help-with-local-system-issues,platform:mac

### Is there an existing issue for this?

- [X] I have searched the existing issues and checked the recent builds/commits

### What happened?

Currently running macOS and Brave browser. After generating the first image this appears beneath it URLError: <urlopen error [SSL: CERTIFICATE_VERIFY_FAILED] certificate verify failed: unable to get local issuer certificate (_ssl.c:997)> and where the image is supposed to be displayed displays a grey image icon. Originally I believed it was something to do with my python copy so I reinstalled that but still no luck. After a bit of googling I found that I need to run a certain file in my python 3.11 folder however even after running it I still am getting the same error. The issue is new previously it was fine.

### Steps to reproduce the problem

1. Open the WebUi
2. Press generate image
3. Set amount of images to 2
4. Wait for first image to generate
5. Second image fails to generate


### What should have happened?

The second image should generate.

### Commit where the problem happens

https://github.com/AUTOMATIC1111/stable-diffusion-webui/commit/89f9faa63388756314e8a1d96cf86bf5e0663045

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

MacOS

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

Brave

### Command Line Arguments

```Shell
No
```


### List of extensions

No

### Console logs

```Shell
Last login: Tue May 16 12:25:36 on ttys000
HOME=/Users/User
LANG=en_US.UTF-8
LOGNAME=User
OLDPWD=/Users/User
PATH=/Library/Frameworks/Python.framework/Versions/3.11/bin:/usr/local/bin:/System/Cryptexes/App/usr/bin:/usr/bin:/bin:/usr/sbin:/sbin:/var/run/com.apple.security.cryptexd/codex.system/bootstrap/usr/local/bin:/var/run/com.apple.security.cryptexd/codex.system/bootstrap/usr/bin:/var/run/com.apple.security.cryptexd/codex.system/bootstrap/usr/appleinternal/bin
PWD=/Users/User
SHELL=/bin/zsh
SHLVL=1
SSH_AUTH_SOCK=/private/tmp/com.apple.launchd.ufW1fNwdpH/Listeners
TERM=xterm-256color
TERM_PROGRAM=Apple_Terminal
TERM_PROGRAM_VERSION=447
TERM_SESSION_ID=4F1A9475-C651-4185-8E5A-3C912EE993AA
TMPDIR=/var/folders/bb/kw1tyny91vx_vftpyp31fclw0000gn/T/
USER=User
XPC_FLAGS=0x0
XPC_SERVICE_NAME=0
__CFBundleIdentifier=com.apple.Terminal
/Users/User/.zshrc:3: unmatched "
User@User-MacBook-Pro ~ % cd applications
User@User-MacBook-Pro applications % cd python-1.11
cd: no such file or directory: python-1.11
User@User-MacBook-Pro applications % /Applications/Python-3.11/Install\ Certificates.command
 -- pip install --upgrade certifi
Requirement already satisfied: certifi in /Library/Frameworks/Python.framework/Versions/3.11/lib/python3.11/site-packages (2023.5.7)
 -- removing any existing file or link
 -- creating symlink to certifi certificate bundle
 -- setting permissions
 -- update complete
User@User-MacBook-Pro applications % cd
User@User-MacBook-Pro ~ % cd stable-diffusion-webui
User@User-MacBook-Pro stable-diffusion-webui % ./webui.sh

################################################################
Install script for stable-diffusion + Web UI
Tested on Debian 11 (Bullseye)
################################################################

################################################################
Running on User user
################################################################

################################################################
Repo already cloned, using it as install directory
################################################################

################################################################
Create and activate python venv
################################################################

################################################################
Launching launch.py...
################################################################
Python 3.10.10 (v3.10.10:aad5f6a891, Feb  7 2023, 08:47:40) [Clang 13.0.0 (clang-1300.0.29.30)]
Version: v1.2.1
Commit hash: 89f9faa63388756314e8a1d96cf86bf5e0663045
Installing requirements
Launching Web UI with arguments: --skip-torch-cuda-test --upcast-sampling --no-half-vae --use-cpu interrogate
No module 'xformers'. Proceeding without it.
Warning: caught exception 'Torch not compiled with CUDA enabled', memory monitor disabled
==============================================================================
You are running torch 1.12.1.
The program is tested to work with torch 2.0.0.
To reinstall the desired version, run with commandline flag --reinstall-torch.
Beware that this will cause a lot of large files to be downloaded, as well as
there are reports of issues with training tab on the latest version.

Use --skip-version-check commandline argument to disable this check.
==============================================================================
reading lora /Users/User/stable-diffusion-webui/models/Lora/liyuuLora_liyuuV1.safetensors: AssertionError
Traceback (most recent call last):
  File "/Users/User/stable-diffusion-webui/extensions-builtin/Lora/lora.py", line 84, in __init__
    self.metadata = sd_models.read_metadata_from_safetensors(filename)
  File "/Users/User/stable-diffusion-webui/modules/sd_models.py", line 232, in read_metadata_from_safetensors
    assert metadata_len > 2 and json_start in (b'{"', b"{'"), f"{filename} is not a safetensors file"
AssertionError: /Users/User/stable-diffusion-webui/models/Lora/liyuuLora_liyuuV1.safetensors is not a safetensors file

Loading weights [d319cb2188] from /Users/User/stable-diffusion-webui/models/Stable-diffusion/babes_20.safetensors
Creating model from config: /Users/User/stable-diffusion-webui/configs/v1-inference.yaml
LatentDiffusion: Running in eps-prediction mode
Running on local URL:  http://127.0.0.1:7860

To create a public link, set `share=True` in `launch()`.
Startup time: 10.3s (import torch: 2.5s, import gradio: 1.8s, import ldm: 0.8s, other imports: 2.7s, setup codeformer: 0.3s, load scripts: 0.9s, create ui: 1.1s, gradio launch: 0.2s).
DiffusionWrapper has 859.52 M params.
Loading VAE weights specified in settings: /Users/User/stable-diffusion-webui/models/VAE/vae-ft-mse-840000-ema-pruned.ckpt
Applying cross attention optimization (InvokeAI).
Textual inversion embeddings loaded(0): 
Model loaded in 24.0s (load weights from disk: 0.7s, create model: 1.2s, apply weights to model: 14.7s, apply half(): 4.0s, load VAE: 1.9s, move model to device: 1.3s, load textual inversion embeddings: 0.2s).
/Users/User/stable-diffusion-webui/venv/lib/python3.10/site-packages/torch/amp/autocast_mode.py:198: UserWarning: User provided device_type of 'cuda', but CUDA is not available. Disabling
  warnings.warn('User provided device_type of \'cuda\', but CUDA is not available. Disabling')
/Users/User/stable-diffusion-webui/venv/lib/python3.10/site-packages/transformers/models/clip/modeling_clip.py:736: UserWarning: The operator 'aten::index.Tensor' is not currently supported on the MPS backend and will fall back to run on the CPU. This may have performance implications. (Triggered internally at  /Users/runner/work/pytorch/pytorch/pytorch/aten/src/ATen/mps/MPSFallback.mm:11.)
  pooled_output = last_hidden_state[
100%|████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████| 40/40 [05:43<00:00,  8.59s/it]
/Users/User/stable-diffusion-webui/venv/lib/python3.10/site-packages/torchvision/models/_utils.py:208: UserWarning: The parameter 'pretrained' is deprecated since 0.13 and will be removed in 0.15, please use 'weights' instead.
  warnings.warn(
/Users/User/stable-diffusion-webui/venv/lib/python3.10/site-packages/torchvision/models/_utils.py:223: UserWarning: Arguments other than a weight enum or `None` for 'weights' are deprecated since 0.13 and will be removed in 0.15. The current behavior is equivalent to passing `weights=None`.
  warnings.warn(msg)
Downloading: "https://github.com/xinntao/facexlib/releases/download/v0.1.0/detection_Resnet50_Final.pth" to /Users/User/stable-diffusion-webui/models/GFPGAN/detection_Resnet50_Final.pth

Error completing request
Arguments: ('task(v4jv06x7mkj3drg)', 'woman, solo, dj, blonde hair, white eyes, detailed face, Egyptian jewelry,\n([Margot Robbie|Scarlett Johansson|Amber Heard]:0.8), (arosen style :0.9),\nmasterpiece, professional, high quality, beautiful, amazing, vintage, Behance, black lingerie,\nphotoshoot, 4k, realistic, detailed background, astonishing, real life, by Howard Pyle, by Joaqun Sorolla,', 'naked, nipples, tattoo, bad anatomy, bad hands, text, error, missing fingers, extra digit, extra ears, fewer digits, cropped, worst quality, low quality, normal quality, jpeg artifacts, signature, watermark, username, blurry, out of focus, ugly, old, deformed, amateur drawing, odd, fat, morphing, black and white, monocolored, lowres, bad anatomy, bad hands, text, error, missing fingers, extra digit, extra ears, fewer digits, cropped, worst quality, low quality, normal quality, jpeg artifacts, signature, watermark, username, blurry, out of focus, censorship, ugly, old, deformed, amateur drawing', [], 40, 0, True, False, 1, 1, 6, -1.0, -1.0, 0, 0, 0, False, 952, 720, False, 0.7, 2, 'Latent', 0, 0, 0, ['ENSD: 31337'], 0, False, False, 'positive', 'comma', 0, False, False, '', 1, '', [], 0, '', [], 0, '', [], True, False, False, False, 0) {}
Traceback (most recent call last):
  File "/Library/Frameworks/Python.framework/Versions/3.10/lib/python3.10/urllib/request.py", line 1348, in do_open
    h.request(req.get_method(), req.selector, req.data, headers,
  File "/Library/Frameworks/Python.framework/Versions/3.10/lib/python3.10/http/client.py", line 1282, in request
    self._send_request(method, url, body, headers, encode_chunked)
  File "/Library/Frameworks/Python.framework/Versions/3.10/lib/python3.10/http/client.py", line 1328, in _send_request
    self.endheaders(body, encode_chunked=encode_chunked)
  File "/Library/Frameworks/Python.framework/Versions/3.10/lib/python3.10/http/client.py", line 1277, in endheaders
    self._send_output(message_body, encode_chunked=encode_chunked)
  File "/Library/Frameworks/Python.framework/Versions/3.10/lib/python3.10/http/client.py", line 1037, in _send_output
    self.send(msg)
  File "/Library/Frameworks/Python.framework/Versions/3.10/lib/python3.10/http/client.py", line 975, in send
    self.connect()
  File "/Library/Frameworks/Python.framework/Versions/3.10/lib/python3.10/http/client.py", line 1454, in connect
    self.sock = self._context.wrap_socket(self.sock,
  File "/Library/Frameworks/Python.framework/Versions/3.10/lib/python3.10/ssl.py", line 513, in wrap_socket
    return self.sslsocket_class._create(
  File "/Library/Frameworks/Python.framework/Versions/3.10/lib/python3.10/ssl.py", line 1071, in _create
    self.do_handshake()
  File "/Library/Frameworks/Python.framework/Versions/3.10/lib/python3.10/ssl.py", line 1342, in do_handshake
    self._sslobj.do_handshake()
ssl.SSLCertVerificationError: [SSL: CERTIFICATE_VERIFY_FAILED] certificate verify failed: unable to get local issuer certificate (_ssl.c:997)

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/Users/User/stable-diffusion-webui/modules/call_queue.py", line 57, in f
    res = list(func(*args, **kwargs))
  File "/Users/User/stable-diffusion-webui/modules/call_queue.py", line 37, in f
    res = func(*args, **kwargs)
  File "/Users/User/stable-diffusion-webui/modules/txt2img.py", line 56, in txt2img
    processed = process_images(p)
  File "/Users/User/stable-diffusion-webui/modules/processing.py", line 526, in process_images
    res = process_images_inner(p)
  File "/Users/User/stable-diffusion-webui/modules/processing.py", line 711, in process_images_inner
    x_sample = modules.face_restoration.restore_faces(x_sample)
  File "/Users/User/stable-diffusion-webui/modules/face_restoration.py", line 19, in restore_faces
    return face_restorer.restore(np_image)
  File "/Users/User/stable-diffusion-webui/modules/gfpgan_model.py", line 111, in restore
    return gfpgan_fix_faces(np_image)
  File "/Users/User/stable-diffusion-webui/modules/gfpgan_model.py", line 53, in gfpgan_fix_faces
    model = gfpgann()
  File "/Users/User/stable-diffusion-webui/modules/gfpgan_model.py", line 40, in gfpgann
    model = gfpgan_constructor(model_path=model_file, upscale=1, arch='clean', channel_multiplier=2, bg_upsampler=None, device=devices.device_gfpgan)
  File "/Users/User/stable-diffusion-webui/venv/lib/python3.10/site-packages/gfpgan/utils.py", line 79, in __init__
    self.face_helper = FaceRestoreHelper(
  File "/Users/User/stable-diffusion-webui/venv/lib/python3.10/site-packages/facexlib/utils/face_restoration_helper.py", line 99, in __init__
    self.face_det = init_detection_model(det_model, half=False, device=self.device, model_rootpath=model_rootpath)
  File "/Users/User/stable-diffusion-webui/venv/lib/python3.10/site-packages/facexlib/detection/__init__.py", line 18, in init_detection_model
    model_path = load_file_from_url(
  File "/Users/User/stable-diffusion-webui/modules/gfpgan_model.py", line 94, in facex_load_file_from_url
    return facex_load_file_from_url_orig(**dict(kwargs, save_dir=model_path, model_dir=None))
  File "/Users/User/stable-diffusion-webui/venv/lib/python3.10/site-packages/facexlib/utils/misc.py", line 77, in load_file_from_url
    download_url_to_file(url, cached_file, hash_prefix=None, progress=progress)
  File "/Users/User/stable-diffusion-webui/venv/lib/python3.10/site-packages/torch/hub.py", line 593, in download_url_to_file
    u = urlopen(req)
  File "/Library/Frameworks/Python.framework/Versions/3.10/lib/python3.10/urllib/request.py", line 216, in urlopen
    return opener.open(url, data, timeout)
  File "/Library/Frameworks/Python.framework/Versions/3.10/lib/python3.10/urllib/request.py", line 519, in open
    response = self._open(req, data)
  File "/Library/Frameworks/Python.framework/Versions/3.10/lib/python3.10/urllib/request.py", line 536, in _open
    result = self._call_chain(self.handle_open, protocol, protocol +
  File "/Library/Frameworks/Python.framework/Versions/3.10/lib/python3.10/urllib/request.py", line 496, in _call_chain
    result = func(*args)
  File "/Library/Frameworks/Python.framework/Versions/3.10/lib/python3.10/urllib/request.py", line 1391, in https_open
    return self.do_open(http.client.HTTPSConnection, req,
  File "/Library/Frameworks/Python.framework/Versions/3.10/lib/python3.10/urllib/request.py", line 1351, in do_open
    raise URLError(err)
urllib.error.URLError: <urlopen error [SSL: CERTIFICATE_VERIFY_FAILED] certificate verify failed: unable to get local issuer certificate (_ssl.c:997)>
```


### Additional information

I have replaced my user name with User for anonymity reasons.