AlUlkesh / stable-diffusion-webui-images-browser

an images browse for stable-diffusion-webui
622 stars 111 forks source link

Unable to remove custom directory #145

Open horribleCodes opened 1 year ago

horribleCodes commented 1 year ago

Whenever I try to remove a custom directory, I get an error and my changes to the "Others" tab are lost. I select a directory from the Saved Directories-Dropdown menu, click Remove from saved directories, and the UI turns into this:

image

And the following error appears in the command log:

Traceback (most recent call last):
  File "C:\Users\stable-diffusion-webui\venv\lib\site-packages\gradio\routes.py", line 394, in run_predict
    output = await app.get_blocks().process_api(
  File "C:\Users\stable-diffusion-webui\venv\lib\site-packages\gradio\blocks.py", line 1075, in process_api
    result = await self.call_function(
  File "C:\Users\stable-diffusion-webui\venv\lib\site-packages\gradio\blocks.py", line 884, in call_function
    prediction = await anyio.to_thread.run_sync(
  File "C:\Users\stable-diffusion-webui\venv\lib\site-packages\anyio\to_thread.py", line 31, in run_sync
    return await get_asynclib().run_sync_in_worker_thread(
  File "C:\Users\stable-diffusion-webui\venv\lib\site-packages\anyio\_backends\_asyncio.py", line 937, in run_sync_in_worker_thread
    return await future
  File "C:\Users\stable-diffusion-webui\venv\lib\site-packages\anyio\_backends\_asyncio.py", line 867, in run
    result = context.run(func, *args)
  File "C:\Users\stable-diffusion-webui\modules\ui_extensions.py", line 25, in apply_and_restart
    check_access()
  File "C:\Users\stable-diffusion-webui\modules\ui_extensions.py", line 21, in check_access
    assert not shared.cmd_opts.disable_extension_access, "extension access disabled because of command line flags"
AssertionError: extension access disabled because of command line flags

Could you at least tell me where the directories are saved so I can manually remove the directory?

AlUlkesh commented 1 year ago

AssertionError: extension access disabled because of command line flags

That error message checks for this:

cmd_opts.disable_extension_access = (cmd_opts.share or cmd_opts.listen or cmd_opts.server_name) and not cmd_opts.enable_insecure

So, if you use share/listen/api you'll need to add --enable-insecure-extension-access to the commandline parameters.

If you want to remove the direcory manually, they are stored in the wib.sqlite3 database in the extension's main directory. Table name is path_recorder.

horribleCodes commented 1 year ago

It doesn't work without --listen either:

Traceback (most recent call last):
  File "C:\Users\stable-diffusion-webui\venv\lib\site-packages\gradio\routes.py", line 394, in run_predict
    output = await app.get_blocks().process_api(
  File "C:\Users\stable-diffusion-webui\venv\lib\site-packages\gradio\blocks.py", line 1075, in process_api
    result = await self.call_function(
  File "C:\Users\stable-diffusion-webui\venv\lib\site-packages\gradio\blocks.py", line 884, in call_function
    prediction = await anyio.to_thread.run_sync(
  File "C:\Users\stable-diffusion-webui\venv\lib\site-packages\anyio\to_thread.py", line 31, in run_sync
    return await get_asynclib().run_sync_in_worker_thread(
  File "C:\Users\stable-diffusion-webui\venv\lib\site-packages\anyio\_backends\_asyncio.py", line 937, in run_sync_in_worker_thread
    return await future
  File "C:\Users\stable-diffusion-webui\venv\lib\site-packages\anyio\_backends\_asyncio.py", line 867, in run
    result = context.run(func, *args)
  File "C:\Users\stable-diffusion-webui\extensions\stable-diffusion-webui-images-browser\scripts\image_browser.py", line 255, in img_path_add_remove
    return path_recorder, gr.update(choices=path_recorder_formatted, value=selected)
UnboundLocalError: local variable 'path_recorder_formatted' referenced before assignment

In this case, my flags were as follows: Launching Web UI with arguments: --xformers --opt-split-attention --deepdanbooru --no-half-vae

I am getting with same error with the --enable-insecure-extension-access flag, too.

AlUlkesh commented 1 year ago

That's a different error. It now gets further, but runs into a new issue.

This error should only happen, if you try to delete something that is not in the list. I'm not sure how one would do that.

Can you make screenshots of the dropdown with the directories and then the delete attempt?

horribleCodes commented 1 year ago

I've since switched to vladmanic's fork, but I am still getting an error, albeit yet another different one. brave_ZUuqRZjIxR And after selecting Remove from saved directories...

Traceback (most recent call last):
  File "C:\Users\jakob\source\repos\automatic\venv\lib\site-packages\gradio\routes.py", line 394, in run_predict
    output = await app.get_blocks().process_api(
  File "C:\Users\jakob\source\repos\automatic\venv\lib\site-packages\gradio\blocks.py", line 1075, in process_api
    result = await self.call_function(
  File "C:\Users\jakob\source\repos\automatic\venv\lib\site-packages\gradio\blocks.py", line 884, in call_function
    prediction = await anyio.to_thread.run_sync(
  File "C:\Users\jakob\source\repos\automatic\venv\lib\site-packages\anyio\to_thread.py", line 31, in run_sync
    return await get_asynclib().run_sync_in_worker_thread(
  File "C:\Users\jakob\source\repos\automatic\venv\lib\site-packages\anyio\_backends\_asyncio.py", line 937, in run_sync_in_worker_thread
    return await future
  File "C:\Users\jakob\source\repos\automatic\venv\lib\site-packages\anyio\_backends\_asyncio.py", line 867, in run
    result = context.run(func, *args)
  File "C:\Users\jakob\source\repos\automatic\extensions-builtin\stable-diffusion-webui-images-browser\scripts\image_browser.py", line 959, in change_dir
    img_dir, img_path_depth = pure_path(img_dir)
  File "C:\Users\jakob\source\repos\automatic\extensions-builtin\stable-diffusion-webui-images-browser\scripts\image_browser.py", line 276, in pure_path
    match = re.search(r" \[(\d+)\]$", path)
  File "C:\Users\jakob\AppData\Local\Programs\Python\Python310\lib\re.py", line 200, in search
    return _compile(pattern, flags).search(string)
TypeError: expected string or bytes-like object

Important to note is that this time, the directory is actually properly deleted. Back in the original repo, the process and screenshot would be exactly the same, just with a different error and result.

AlUlkesh commented 1 year ago

I think I found it. Can you try the latest update?

horribleCodes commented 1 year ago

image This time only the dropdown menu gets replaced with an error (as opposed to the Images Directory field and the dropdown menu), and the error message is different.

Traceback (most recent call last):
  File "C:\Users\source\repos\automatic\venv\lib\site-packages\gradio\routes.py", line 394, in run_predict
    output = await app.get_blocks().process_api(
  File "C:\Users\source\repos\automatic\venv\lib\site-packages\gradio\blocks.py", line 1075, in process_api
    result = await self.call_function(
  File "C:\Users\source\repos\automatic\venv\lib\site-packages\gradio\blocks.py", line 884, in call_function
    prediction = await anyio.to_thread.run_sync(
  File "C:\Users\source\repos\automatic\venv\lib\site-packages\anyio\to_thread.py", line 31, in run_sync
    return await get_asynclib().run_sync_in_worker_thread(
  File "C:\Users\source\repos\automatic\venv\lib\site-packages\anyio\_backends\_asyncio.py", line 937, in run_sync_in_worker_thread
    return await future
  File "C:\Users\source\repos\automatic\venv\lib\site-packages\anyio\_backends\_asyncio.py", line 867, in run
    result = context.run(func, *args)
  File "C:\Users\source\repos\automatic\extensions-builtin\stable-diffusion-webui-images-browser\scripts\image_browser.py", line 252, in img_path_add_remove
    selected = path_recorder[list(path_recorder.keys())[0]]["path_display"]
IndexError: list index out of range

My guess is the extension is trying to open the just deleted path? In any case, the directory still gets removed.

AlUlkesh commented 1 year ago

Ah. After the remove it's trying to position on the first element of the dropdown. But I think you have none left.

Not currently sure how to fix that, an empty directory gets the webui folder.

Akossimon commented 3 months ago

in addition there is no reset to default folder location for outputs and database location neither.... i find myself to have to deinstall and remove it, and to re install it , just to get the default settings back again

AlUlkesh commented 2 months ago

in addition there is no reset to default folder location for outputs and database location neither....

The database location is fixed to the extension's top directory. I'm not sure what you mean by resetting it.

As for the folder locations, that's set by webui, not the extension. image Or do you mean something different?