dr413677671 / PromptGallery-stable-diffusion-webui

A prompt cookbook worked as stable-diffusion-webui extenstions.
Apache License 2.0
153 stars 16 forks source link

IsADirectoryError when pressing 'Show pics' button #26

Closed h-sahin closed 1 year ago

h-sahin commented 1 year ago

I was following the tutorial and trying to generate previews for the included presets. I selected the script and added the avatars.yaml and tags.yaml, generated the images, pressed on 'QC scan' and selected one of the prompts. When I tried to display the generated images by pressing 'Show pics' the field that is supposed to show the images only shows 'Error' in red.

The traceback in the terminal is:

Traceback (most recent call last):
  File "/data/apps/stable-diffusion-webui/venv/lib/python3.10/site-packages/gradio/routes.py", line 337, in run_predict
    output = await app.get_blocks().process_api(
  File "/data/apps/stable-diffusion-webui/venv/lib/python3.10/site-packages/gradio/blocks.py", line 1018, in process_api
    data = self.postprocess_data(fn_index, result["prediction"], state)
  File "/data/apps/stable-diffusion-webui/venv/lib/python3.10/site-packages/gradio/blocks.py", line 956, in postprocess_data
    prediction_value = block.postprocess(prediction_value)
  File "/data/apps/stable-diffusion-webui/venv/lib/python3.10/site-packages/gradio/components.py", line 3742, in postprocess
    file_path = self.make_temp_copy_if_needed(img)
  File "/data/apps/stable-diffusion-webui/venv/lib/python3.10/site-packages/gradio/processing_utils.py", line 379, in make_temp_copy_if_needed
    temp_file_path = self.get_temp_file_path(file_path)
  File "/data/apps/stable-diffusion-webui/venv/lib/python3.10/site-packages/gradio/processing_utils.py", line 365, in get_temp_file_path
    file_hash = self.hash_file(file_path)
  File "/data/apps/stable-diffusion-webui/venv/lib/python3.10/site-packages/gradio/processing_utils.py", line 334, in hash_file
    with open(file_path, "rb") as f:
IsADirectoryError: [Errno 21] Is a directory: 'extensions/PromptGallery-stable-diffusion-webui/assets/preview/General_fire_high_res/flowing fire portrait focus on face complex extremely'

In the folder assets\preview all the images are there but it fails to display them for some reason.

dr413677671 commented 1 year ago

Could you try upgrade the extension, clean up preview folder and try use this config:

image
h-sahin commented 1 year ago

Could you try upgrade the extension

As I said, I'm already on the latest commit (the one from 2 weeks ago), or did you forgot to push an update?

I've double checked and these settings are already how I have the WebUI configured. I've also tested the extension on a fresh install of the WebUI, but nothing changed.

I think the problem is, that the images get saved in a subdirectory:

But the code does not check for the files inside the subfolders and instead tries to access the folder as if it were a file. If for example I replace these lines: https://github.com/dr413677671/PromptGallery-stable-diffusion-webui/blob/f2375cfa241ca2bb473e6422a90c7262cca1eb0e/paste_this_to_webui_scripts_folder/prompt_gallery.py#L507-L509

With:

for file in files:
    images = os.listdir(os.path.join(root, folder, file))
    qc_dict[folder] = [os.path.join(root, folder, file, image) for image in images]

I can successfully view the generated pictures in the UI when pressing "Show pics", but then it fails when I click on one of the images and press "Select". I'm not sure if it's intended to generate subfolders inside "3dCG", "cartoon" etc.?

I haven't had much time to debug further, but if I find out anything else I will comment here.

h-sahin commented 1 year ago

Ok, I found out what caused the issue. Seems like this extension is not compatible with the setting "Save images to a subdirectory".

Is it possible to control this setting from your script? Maybe disable during the generation and re-enable it afterwards? Couldn't find anything about that in the WebUI docs, thought outpath_samples would be enough to control the folder.

Mistborn-First-Era commented 1 year ago

same issue. Would really like to not have to change this setting manually every time I want to generate images.

dr413677671 commented 1 year ago

Fixed. Save to subdir should be automatically disabled now.

dr413677671 commented 1 year ago

Close, please reopen if happen again