dr413677671 / PromptGallery-stable-diffusion-webui

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

With open(file_path, "rb") as f: PermissionErorr #25

Closed Susanoo1337 closed 1 year ago

Susanoo1337 commented 1 year ago

When pressing "Show Pics" after generating I get "Error" in the UI and the console pops this:

Traceback (most recent call last):
  File "H:\Stable Diffusion\stable-diffusion-webui-master\venv\lib\site-packages\gradio\routes.py", line 337, in run_predict
    output = await app.get_blocks().process_api(
  File "H:\Stable Diffusion\stable-diffusion-webui-master\venv\lib\site-packages\gradio\blocks.py", line 1018, in process_api
    data = self.postprocess_data(fn_index, result["prediction"], state)
  File "H:\Stable Diffusion\stable-diffusion-webui-master\venv\lib\site-packages\gradio\blocks.py", line 956, in postprocess_data
    prediction_value = block.postprocess(prediction_value)
  File "H:\Stable Diffusion\stable-diffusion-webui-master\venv\lib\site-packages\gradio\components.py", line 3742, in postprocess
    file_path = self.make_temp_copy_if_needed(img)
  File "H:\Stable Diffusion\stable-diffusion-webui-master\venv\lib\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 "H:\Stable Diffusion\stable-diffusion-webui-master\venv\lib\site-packages\gradio\processing_utils.py", line 365, in get_temp_file_path
    file_hash = self.hash_file(file_path)
  File "H:\Stable Diffusion\stable-diffusion-webui-master\venv\lib\site-packages\gradio\processing_utils.py", line 334, in hash_file
    with open(file_path, "rb") as f:
PermissionError: [Errno 13] Permission denied: 'extensions\\PromptGallery-stable-diffusion-webui\\assets\\preview\\Test2\\ponytail 1girl'

I've tried changing the --cors-allow-origins https://localhost:5173 to 127.0.0.1:5173 as well as allowing full control over the extensions folder to all users in Windows. No effect.

dr413677671 commented 1 year ago

Could you check is there a file named "ponytail 1girl" in the folder?

Susanoo1337 commented 1 year ago

No, the files are named 00000-435895048.png through 00003-435895051.png etc.

dr413677671 commented 1 year ago

I checked the codes but could not see the reason. Please upgrade the extension and try again. I added more logging,

Susanoo1337 commented 1 year ago

Updated Webui, updated pytorch, updated xformers, and then updated PromptGallery. This is what I get now.

extensions\PromptGallery-stable-diffusion-webui\assets\preview\Test2\ponytail 1girl
Traceback (most recent call last):
  File "H:\Stable Diffusion\stable-diffusion-webui-master\venv\lib\site-packages\gradio\routes.py", line 337, in run_predict
    output = await app.get_blocks().process_api(
  File "H:\Stable Diffusion\stable-diffusion-webui-master\venv\lib\site-packages\gradio\blocks.py", line 1018, in process_api
    data = self.postprocess_data(fn_index, result["prediction"], state)
  File "H:\Stable Diffusion\stable-diffusion-webui-master\venv\lib\site-packages\gradio\blocks.py", line 956, in postprocess_data
    prediction_value = block.postprocess(prediction_value)
  File "H:\Stable Diffusion\stable-diffusion-webui-master\venv\lib\site-packages\gradio\components.py", line 3742, in postprocess
    file_path = self.make_temp_copy_if_needed(img)
  File "H:\Stable Diffusion\stable-diffusion-webui-master\venv\lib\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 "H:\Stable Diffusion\stable-diffusion-webui-master\venv\lib\site-packages\gradio\processing_utils.py", line 365, in get_temp_file_path
    file_hash = self.hash_file(file_path)
  File "H:\Stable Diffusion\stable-diffusion-webui-master\venv\lib\site-packages\gradio\processing_utils.py", line 334, in hash_file
    with open(file_path, "rb") as f:
PermissionError: [Errno 13] Permission denied: 'extensions\\PromptGallery-stable-diffusion-webui\\assets\\preview\\Test2\\ponytail 1girl'
dr413677671 commented 1 year ago

Could you try clean up preview folder and use this config

image
Susanoo1337 commented 1 year ago

I cleaned up the preview folder and used that config, no change. :< This is what the folder looks like: image

Susanoo1337 commented 1 year ago

Fixed by adding two lines at: https://github.com/dr413677671/PromptGallery-stable-diffusion-webui/blob/f2375cfa241ca2bb473e6422a90c7262cca1eb0e/paste_this_to_webui_scripts_folder/prompt_gallery.py#L116-L119

to:

pg_templates.update(options_section_def(('saving-to-dirs', "Saving to a directory"), {
    "directories_filename_pattern": OptionInfo("", "Directory name pattern", component_args=hide_dirs),
    "directories_max_prompt_words": OptionInfo(8, "Max prompt words for [prompt_words] pattern", gr.Slider, {"minimum": 1, "maximum": 20, "step": 1, **hide_dirs}),
    "save_to_dirs": OptionInfo(False, ""),
    "grid_save_to_dirs": OptionInfo(False, ""),
}))
GoddessFreya13 commented 1 year ago

I am getting this same error even after adding the two lines to the prompt_gallery.py file.

image

image

image

image

Mistborn-First-Era commented 1 year ago

@GoddessFreya13

I was able to fix it by going to the main directory\assets\preview and ensuring that the files are not in sub folders

GoddessFreya13 commented 1 year ago

Thank you for the information. I will test it out and see if it fixed the issue.