stable-diffusion-webui icon indicating copy to clipboard operation
stable-diffusion-webui copied to clipboard

[Bug]: streamlit cannot write images to disk, as encoding of filename fails

Open cstueckrath opened this issue 4 years ago • 3 comments

What happened?

If I clone dev from scratch into a new structure and just run streamlit, an image is produced but not saved. Encoding of "Int" fails.

Version

0.0.1 (Default)

What browsers are you seeing the problem on?

Chrome

Where are you running the webui?

Linux

Custom settings

No response

Relevant log output

AttributeError: 'int' object has no attribute 'encode'
Traceback:
File "/home/cstueckrath/anaconda3/envs/lsd/lib/python3.8/site-packages/streamlit/runtime/scriptrunner/script_runner.py", line 556, in _run_script
    exec(code, module.__dict__)
File "/home/cstueckrath/rocm/stable-diffusion-webui/scripts/webui_streamlit.py", line 2514, in <module>
    layout()
File "/home/cstueckrath/rocm/stable-diffusion-webui/scripts/webui_streamlit.py", line 2152, in layout
    output_images, seed, info, stats = txt2img(prompt, st.session_state.sampling_steps, sampler_name, RealESRGAN_model, batch_count, 1,
File "/home/cstueckrath/anaconda3/envs/lsd/lib/python3.8/site-packages/decorator.py", line 232, in fun
    return caller(func, *(extras + args), **kw)
File "/home/cstueckrath/anaconda3/envs/lsd/lib/python3.8/site-packages/retry/api.py", line 73, in retry_decorator
    return __retry_internal(partial(f, *args, **kwargs), exceptions, tries, delay, max_delay, backoff, jitter,
File "/home/cstueckrath/anaconda3/envs/lsd/lib/python3.8/site-packages/retry/api.py", line 33, in __retry_internal
    return f()
File "/home/cstueckrath/rocm/stable-diffusion-webui/scripts/webui_streamlit.py", line 1659, in txt2img
    output_images, seed, info, stats = process_images(
File "/home/cstueckrath/rocm/stable-diffusion-webui/scripts/webui_streamlit.py", line 1262, in process_images
    save_sample(image, sample_path_i, filename, jpg_sample, prompts, seeds, width, height, steps, cfg_scale,
File "/home/cstueckrath/rocm/stable-diffusion-webui/scripts/webui_streamlit.py", line 872, in save_sample
    mdata.add_text(key, metadata[key])
File "/home/cstueckrath/anaconda3/envs/lsd/lib/python3.8/site-packages/PIL/PngImagePlugin.py", line 341, in add_text
    value = value.encode("latin-1", "strict")

Code of Conduct

  • [X] I agree to follow this project's Code of Conduct

cstueckrath avatar Sep 12 '22 06:09 cstueckrath

Fixed on #1045

ZeroCool940711 avatar Sep 12 '22 07:09 ZeroCool940711

There still seems to be an issue with generated folders, though.

My Example prompt: "hyper detailed full body image of a Westworld cyborg, played by Evan Rachel Wood, Westworld, 8k, bokeh, Canon"

Folder Names: hyper-deta, hyper-detailed-, hyper-detai

cstueckrath avatar Sep 12 '22 08:09 cstueckrath

That's probably because the output path is too long, if it's longer than 220 characters it is reduced so it's less than that or otherwise Windows has problem with it and you won't be able to open the info files or have problem opening the images, to avoid that I made it so the folder name is reduced in length and sanitized to not content any character that is not allowed on Windows, not sure if the same happens on Linux but I do need to improve that a bit.

ZeroCool940711 avatar Sep 12 '22 09:09 ZeroCool940711