AUTOMATIC1111 / stable-diffusion-webui

Stable Diffusion web UI
GNU Affero General Public License v3.0
140.34k stars 26.56k forks source link

[Bug]: 403 Forbidden: images not appearing in browser after completion #13133

Closed rugabunda closed 1 year ago

rugabunda commented 1 year ago

Is there an existing issue for this?

What happened?

Been happening since I first installed sdui, happens in every single browser. When generating images, preview works, but after the image is complete the browser is unable to retrieve the image. Happens in txt2img, img2img, extras...

image

In waterfox, I'm seeing a 'forbidden' error in developer tools,

GET http://127.0.0.1:7860/file=D:/#AI\Stable-Diffusion-WebUI\stable-diffusion-webui\outputs\txt2img-images\2023-09-07\00017-CFG7-Euler a.png [HTTP/1.1 403 Forbidden 2ms]

2023-09-07 12_18_26

In Yandex:

image

In Edge:

image

Using the same browsers, this error does not occur in InvokeAI's gui. I am able to browse sdui images fine with 'image browser' extension, and 'infinite image browsing' extension, but not the built in image browser.

It always happens upon load... but eventually, after generating perhaps a few hundred images, the problem will go away, seemingly randomly.

Ive disabled all browser extensions that could potentially interfere with the UI, and the antivirus in testing. Also cleared pip cache and reinstalled all requirements.

Steps to reproduce the problem

  1. Generate image

What should have happened?

Image should be viewable in the browser on the right

Sysinfo

sysinfo-2023-09-07-19-32.txt

What browsers do you use to access the UI ?

Mozilla Firefox, Google Chrome, Microsoft Edge, Other

Console logs

(env) d:\#AI\Stable-Diffusion-WebUI\stable-diffusion-webui>webui-user.bat
'#' is not recognized as an internal or external command,
operable program or batch file.
venv "d:\#AI\Stable-Diffusion-WebUI\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.6.0
Commit hash: 5ef669de080814067961f28357256e8fe27544f4
Checking ReActor requirements... Ok
Launching Web UI with arguments: --xformers --xformers-flash-attention --opt-sdp-attention --no-half-vae --no-download-sd-model --skip-torch-cuda-test
Civitai Helper: Get Custom Model Folder
Civitai Helper: Load setting from: D:\#AI\Stable-Diffusion-WebUI\stable-diffusion-webui\extensions\Stable-Diffusion-Webui-Civitai-Helper\setting.json
Civitai Helper: No setting file, use default
Tag Autocomplete: Could not locate model-keyword extension, Lora trigger word completion will be limited to those added through the extra networks menu.
[-] ADetailer initialized. version: 23.8.1, num models: 9
2023-09-07 12:16:22,491 - ControlNet - INFO - ControlNet v1.1.408
ControlNet preprocessor location: D:\#AI\Stable-Diffusion-WebUI\stable-diffusion-webui\extensions\sd-webui-controlnet\annotator\downloads
2023-09-07 12:16:22,596 - ControlNet - INFO - ControlNet v1.1.408
12:16:24 - ReActor - STATUS - Running v0.4.1
Loading weights [e6bb9ea85b] from D:\#AI\Stable-Diffusion-WebUI\stable-diffusion-webui\models\Stable-diffusion\sd_xl_base_1.0_0.9vae.safetensors
Creating model from config: D:\#AI\Stable-Diffusion-WebUI\stable-diffusion-webui\repositories\generative-models\configs\inference\sd_xl_base.yaml
Running on local URL:  http://127.0.0.1:7860

To create a public link, set `share=True` in `launch()`.
Startup time: 21.2s (prepare environment: 2.3s, import torch: 5.0s, import gradio: 1.4s, setup paths: 1.2s, initialize shared: 0.3s, other imports: 1.0s, setup codeformer: 0.2s, load scripts: 5.7s, create ui: 1.6s, gradio launch: 0.3s, app_started_callback: 2.3s).
Applying attention optimization: xformers... done.
Model loaded in 11.1s (load weights from disk: 1.1s, create model: 0.4s, apply weights to model: 7.8s, move model to device: 0.1s, calculate empty prompt: 1.5s).
100%|██████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████| 20/20 [00:02<00:00,  9.12it/s]
Total progress: 100%|██████████████████████████████████████████████████████████████████████████████████████████████████████████████████████| 20/20 [00:02<00:00,  9.64it/s]
100%|██████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████| 20/20 [00:02<00:00,  8.28it/s]
Total progress: 100%|██████████████████████████████████████████████████████████████████████████████████████████████████████████████████████| 20/20 [00:02<00:00,  8.98it/s]
100%|██████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████| 20/20 [00:02<00:00,  8.38it/s]
Total progress: 100%|██████████████████████████████████████████████████████████████████████████████████████████████████████████████████████| 20/20 [00:02<00:00,  8.87it/s]
100%|██████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████| 20/20 [00:02<00:00,  8.63it/s]
100%|██████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████| 20/20 [00:02<00:00,  9.24it/s]
100%|██████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████| 20/20 [00:02<00:00,  9.39it/s]
100%|██████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████| 20/20 [00:02<00:00,  9.36it/s]
100%|██████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████| 20/20 [00:02<00:00,  9.60it/s]
100%|██████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████| 20/20 [00:02<00:00,  9.69it/s]
100%|██████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████| 20/20 [00:02<00:00,  9.66it/s]
100%|██████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████| 20/20 [00:02<00:00,  9.56it/s]
100%|██████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████| 20/20 [00:02<00:00,  9.54it/s]
100%|██████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████| 20/20 [00:02<00:00,  9.45it/s]
100%|██████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████| 20/20 [00:02<00:00,  9.36it/s]
100%|██████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████| 20/20 [00:02<00:00,  9.45it/s]
100%|██████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████| 20/20 [00:02<00:00,  9.56it/s]
100%|██████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████| 20/20 [00:02<00:00,  9.58it/s]
100%|██████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████| 20/20 [00:02<00:00,  9.47it/s]
Total progress: 100%|████████████████████████████████████████████████████████████████████████████████████████████████████████████████████| 300/300 [00:35<00:00,  8.44it/s]
100%|██████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████| 20/20 [00:02<00:00,  8.44it/s]
100%|██████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████| 20/20 [00:02<00:00,  9.03it/s]
100%|██████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████| 20/20 [00:02<00:00,  9.27it/s]
100%|██████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████| 20/20 [00:02<00:00,  9.16it/s]
100%|██████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████| 20/20 [00:02<00:00,  9.51it/s]
100%|██████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████| 20/20 [00:02<00:00,  9.08it/s]
100%|██████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████| 20/20 [00:02<00:00,  9.32it/s]
Total progress: 100%|████████████████████████████████████████████████████████████████████████████████████████████████████████████████████| 140/140 [00:16<00:00,  8.31it/s]
100%|██████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████| 20/20 [00:02<00:00,  8.75it/s]
100%|██████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████| 20/20 [00:02<00:00,  8.87it/s]
100%|██████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████| 20/20 [00:02<00:00,  9.38it/s]
100%|██████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████| 20/20 [00:02<00:00,  8.85it/s]
100%|██████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████| 20/20 [00:02<00:00,  9.48it/s]
100%|██████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████| 20/20 [00:02<00:00,  9.25it/s]
100%|██████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████| 20/20 [00:02<00:00,  9.43it/s]
Total progress: 100%|████████████████████████████████████████████████████████████████████████████████████████████████████████████████████| 140/140 [00:16<00:00,  8.36it/s]
100%|██████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████| 20/20 [00:02<00:00,  7.87it/s]
Total progress: 100%|██████████████████████████████████████████████████████████████████████████████████████████████████████████████████████| 20/20 [00:02<00:00,  8.49it/s]
100%|██████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████| 20/20 [00:02<00:00,  9.09it/s]
Total progress: 100%|██████████████████████████████████████████████████████████████████████████████████████████████████████████████████████| 20/20 [00:02<00:00,  9.61it/s]
Total progress: 100%|██████████████████████████████████████████████████████████████████████████████████████████████████████████████████████| 20/20 [00:02<00:00, 10.50it/s]

Additional information

Used A1111.Web.UI.Autoinstaller.v1.7.0.exe initially to install the app. Installed under D:\#AI\Stable-Diffusion-WebUI\stable-diffusion-webui

Nerogante commented 1 year ago

Try to avoid long folder names (even not that long), also try to avoid unconventional characters, like #. Then it's easier to start pinpointing the problem. Maybe the long path and the # are the problem. For example my SD folder is just "C:\SD-1.6" or "C:\stable-diffusion-webui-1.5.2"

rugabunda commented 1 year ago

Try to avoid long folder names (even not that long), also try to avoid unconventional characters, like #. Then it's easier to start pinpointing the problem. Maybe the long path and the # are the problem. For example my SD folder is just "C:\SD-1.6" or "C:\stable-diffusion-webui-1.5.2"

I have considered those two things; when moving the folders, stable diffusion cannot find the files. How to accomplish a change of directory simply without a complete fresh install? Edit: seems reinstalling venv does the trick, (no delete necessary)

rugabunda commented 1 year ago

Just to test, I will do a fresh install in a new folder, and see what happens.

rugabunda commented 1 year ago

I created a fresh install in D:\SD, and image browser worked. I renamed the folder to D:\#SD and the image browser had a hernia. Same problem. So it appears either sdui's image browser or the browser itself is not configured to handle certain characters under certain circumstances. I'm not sure which is confused. But I do know extension based image browsers work fine, InvokeAI worked fine also under the same #AI\ directory as well. It also randomly works after a while in SDUI too so... a bit confusing.

I assume that if InvokeAI works, and it does, then so can this with the appropriate commit, esp if its not an upstream problem.

rugabunda commented 1 year ago

Yeah, moving my primary sdui folder to a path without the # character is a successful work around. The other 403 forbidden errors disappeared along with it.

Nem-z commented 1 year ago

I have the exact same issue since 1.6.0 no problem on the 1.5.2 and previous version (on Windows). Tried different browsers (Vivaldi / Edge / Firefox). I tried to move my A1111 folder to the root of my SSD and I still have the error 403 (with current and a fresh installation). Pictures are generating fine and I can find them in the destination folder though.

Nerogante commented 1 year ago

I have the exact same issue since 1.6.0 no problem on the 1.5.2 and previous version. Tried different browsers (Vivaldi / Edge / Firefox). I tried to move my A1111 folder to the root of my SSD and I still have the error 403 (with current and a fresh installation). Pictures are generating fine and I can find them in the destination folder though.

You could post logs from browser and SD console like OP did

Nem-z commented 1 year ago

I found why in my case. I saved the generated pic in a folder named .temp outside the A1111 install folder (but still on the same SSD) and renaming it in temp and changing my settings accordingly solved the issue.

I didn't thought that the WebUI loaded the file directly from the destination folder and thought it was in some sort of cache on the same folder as the installation.

It solved my issue for now.

But this is still a regression from the 1.5.2 and older version.

zopieux commented 1 year ago

For anyone wondering why SD is suddenly broken: the gradio package decided that if assets are in a path that contains a dotted name (such as /whatever/.local/stable-diffusion-webui/javascript/x.js) then it's a "secret file" and refuses to serve it, hence all the 403 errors. You need to clone the code in a path that has no . prefixed directory at all. This is terrible design (it should only care about paths starting from the project root) but nothing SD can do about it, that's a gradio behavior.