AUTOMATIC1111 / stable-diffusion-webui

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

[Bug]: Disabling "Always save all generated images" causes FileNotFoundError #11368

Closed ChristophHaag closed 1 year ago

ChristophHaag commented 1 year ago

Is there an existing issue for this?

What happened?

On archlinux I ran ./webui.sh from the git repo, disabled "Always save all generated images" and ran into this error.

Steps to reproduce the problem

  1. Disable settings -> Saving images/grids -> Always save all generated images, click apply settings.
  2. Go to txt2image and generate something
  3. Get FileNotFoundError error and no image in the webui

What should have happened?

the webui should display the generated image, just not autosave it.

Commit where the problem happens

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

What Python version are you running on ?

Python 3.11.x (above, no supported yet)

What platforms do you use to access the UI ?

Linux

What device are you running WebUI on?

AMD GPUs (RX 6000 above)

What browsers do you use to access the UI ?

Mozilla Firefox

Command Line Arguments

--medvram

List of extensions

No

Console logs

Traceback (most recent call last):██████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████| 99/99 [00:13<00:00,  7.43it/s]
  File "/mnt/ssd4tb/haagch/stable-diffusion-webui/venv/lib/python3.11/site-packages/gradio/routes.py", line 422, in run_predict
    output = await app.get_blocks().process_api(
             ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/mnt/ssd4tb/haagch/stable-diffusion-webui/venv/lib/python3.11/site-packages/gradio/blocks.py", line 1326, in process_api
    data = self.postprocess_data(fn_index, result["prediction"], state)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/mnt/ssd4tb/haagch/stable-diffusion-webui/venv/lib/python3.11/site-packages/gradio/blocks.py", line 1260, in postprocess_data
    prediction_value = block.postprocess(prediction_value)
                       ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/mnt/ssd4tb/haagch/stable-diffusion-webui/venv/lib/python3.11/site-packages/gradio/components.py", line 4461, in postprocess
    file = self.pil_to_temp_file(img, dir=self.DEFAULT_TEMP_DIR)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/mnt/ssd4tb/haagch/stable-diffusion-webui/modules/ui_tempdir.py", line 55, in save_pil_to_file
    file_obj = tempfile.NamedTemporaryFile(delete=False, suffix=".png", dir=dir)
               ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/lib/python3.11/tempfile.py", line 563, in NamedTemporaryFile
    file = _io.open(dir, mode, buffering=buffering,
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/lib/python3.11/tempfile.py", line 560, in opener
    fd, name = _mkstemp_inner(dir, prefix, suffix, flags, output_type)
               ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/lib/python3.11/tempfile.py", line 256, in _mkstemp_inner
    fd = _os.open(file, flags, 0o600)
         ^^^^^^^^^^^^^^^^^^^^^^^^^^^^
FileNotFoundError: [Errno 2] No such file or directory: '/tmp/gradio/tmpynm8iftf.png'


### Additional information

_No response_
EulOne116 commented 1 year ago

I get same error after updating to 1.3.2

File "G:\sdweb\venv\lib\site-packages\gradio\routes.py", line 422, in run_predict
    output = await app.get_blocks().process_api(
  File "G:\sdweb\venv\lib\site-packages\gradio\blocks.py", line 1326, in process_api
    data = self.postprocess_data(fn_index, result["prediction"], state)
  File "G:\sdweb\venv\lib\site-packages\gradio\blocks.py", line 1260, in postprocess_data
    prediction_value = block.postprocess(prediction_value)
  File "G:\sdweb\venv\lib\site-packages\gradio\components.py", line 4461, in postprocess
    file = self.pil_to_temp_file(img, dir=self.DEFAULT_TEMP_DIR)
  File "G:\sdweb\modules\ui_tempdir.py", line 55, in save_pil_to_file
    file_obj = tempfile.NamedTemporaryFile(delete=False, suffix=".png", dir=dir)
  File "C:\Users\maser\AppData\Local\Programs\Python\Python310\lib\tempfile.py", line 559, in NamedTemporaryFile
    file = _io.open(dir, mode, buffering=buffering,
  File "C:\Users\maser\AppData\Local\Programs\Python\Python310\lib\tempfile.py", line 556, in opener
    fd, name = _mkstemp_inner(dir, prefix, suffix, flags, output_type)
  File "C:\Users\maser\AppData\Local\Programs\Python\Python310\lib\tempfile.py", line 256, in _mkstemp_inner
    fd = _os.open(file, flags, 0o600)
FileNotFoundError: [Errno 2] No such file or directory: 'C:\\Users\\maser\\AppData\\Local\\Temp\\gradio\\tmpvs1u8eq_.png
yoav-epstein commented 1 year ago

on linux it's trying to save the grid file into /tmp/gradio. i have found 2 workarounds: 1) create the directory /tmp/gradio. it has the drawback of getting deleted after a reboot, so i have to recreate it. 2) select a different directory in settings -> saving image/grids (1st choice) -> directory for temporary images (almost last choice). it has the drawback of not deleting the files after a reboot - so you need to clean them manually

catboxanon commented 1 year ago

Closing as stale.