[GH-ISSUE #251] Directory named .safetensors causes model-keyword to break and to break webui-tagcomplete in return #179

Closed
opened 2026-10-30 21:20:34 +00:00 by bsakaguchi · 1 comment
Owner

Originally created by @ivucica on GitHub (Nov 5, 2023).
Original GitHub issue: https://github.com/DominikDoom/a1111-sd-webui-tagcomplete/issues/251

When the only extensions installed are model-keyword and a1111-sd-webui-tagcomplete (all others being moved away), and when config.json has also been moved away, then an attempt to open a directory that happens to have a .safetensors "extension" fails and completely breaks the startup of the extension:

*** Error loading script: tag_autocomplete_helper.py
    Traceback (most recent call last):
      File "/mnt/aiart/stable-diffusion/stable-diffusion-webui/modules/scripts.py", line 382, in load_scripts
        script_module = script_loading.load_module(scriptfile.path)
                        ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
      File "/mnt/aiart/stable-diffusion/stable-diffusion-webui/modules/script_loading.py", line 10, in load_module
        module_spec.loader.exec_module(module)
      File "<frozen importlib._bootstrap_external>", line 940, in exec_module
      File "<frozen importlib._bootstrap>", line 241, in _call_with_frames_removed
      File "/mnt/aiart/stable-diffusion/stable-diffusion-webui/extensions/a1111-sd-webui-tagcomplete/scripts/tag_autocomplete_helper.py", line 326, in <module>
        write_temp_files()
      File "/mnt/aiart/stable-diffusion/stable-diffusion-webui/extensions/a1111-sd-webui-tagcomplete/scripts/tag_autocomplete_helper.py", line 310, in write_temp_files
        lora = get_lora()
               ^^^^^^^^^^
      File "/mnt/aiart/stable-diffusion/stable-diffusion-webui/extensions/a1111-sd-webui-tagcomplete/scripts/tag_autocomplete_helper.py", line 186, in get_lora
        hashes[name] = get_lora_simple_hash(l)
                       ^^^^^^^^^^^^^^^^^^^^^^^
      File "/mnt/aiart/stable-diffusion/stable-diffusion-webui/extensions/a1111-sd-webui-tagcomplete/scripts/model_keyword_support.py", line 48, in get_lora_simple_hash
        with open(path, "rb") as file:
             ^^^^^^^^^^^^^^^^
    IsADirectoryError: [Errno 21] Is a directory: '/mnt/aiart/stable-diffusion/stable-diffusion-webui/models/Lora/31817-xsarchitectural-19Houseplan.safetensors'

The extension does not load and its options do not appear in Settings of a1111.

This also causes #250.

Originally created by @ivucica on GitHub (Nov 5, 2023). Original GitHub issue: https://github.com/DominikDoom/a1111-sd-webui-tagcomplete/issues/251 When the only extensions installed are `model-keyword` and `a1111-sd-webui-tagcomplete` (all others being moved away), and when `config.json` has also been moved away, then an attempt to open a directory that happens to have a `.safetensors` "extension" fails and completely breaks the startup of the extension: ``` *** Error loading script: tag_autocomplete_helper.py Traceback (most recent call last): File "/mnt/aiart/stable-diffusion/stable-diffusion-webui/modules/scripts.py", line 382, in load_scripts script_module = script_loading.load_module(scriptfile.path) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/mnt/aiart/stable-diffusion/stable-diffusion-webui/modules/script_loading.py", line 10, in load_module module_spec.loader.exec_module(module) File "<frozen importlib._bootstrap_external>", line 940, in exec_module File "<frozen importlib._bootstrap>", line 241, in _call_with_frames_removed File "/mnt/aiart/stable-diffusion/stable-diffusion-webui/extensions/a1111-sd-webui-tagcomplete/scripts/tag_autocomplete_helper.py", line 326, in <module> write_temp_files() File "/mnt/aiart/stable-diffusion/stable-diffusion-webui/extensions/a1111-sd-webui-tagcomplete/scripts/tag_autocomplete_helper.py", line 310, in write_temp_files lora = get_lora() ^^^^^^^^^^ File "/mnt/aiart/stable-diffusion/stable-diffusion-webui/extensions/a1111-sd-webui-tagcomplete/scripts/tag_autocomplete_helper.py", line 186, in get_lora hashes[name] = get_lora_simple_hash(l) ^^^^^^^^^^^^^^^^^^^^^^^ File "/mnt/aiart/stable-diffusion/stable-diffusion-webui/extensions/a1111-sd-webui-tagcomplete/scripts/model_keyword_support.py", line 48, in get_lora_simple_hash with open(path, "rb") as file: ^^^^^^^^^^^^^^^^ IsADirectoryError: [Errno 21] Is a directory: '/mnt/aiart/stable-diffusion/stable-diffusion-webui/models/Lora/31817-xsarchitectural-19Houseplan.safetensors' ``` The extension does not load and its options do not appear in `Settings` of a1111. This also causes #250.
Author
Owner

@DominikDoom commented on GitHub (Nov 5, 2023):

Fixed by adding a filter condition that checks if the found path actually is a file. This would've likely also affected all other places where the extension searches for specific file types, so pretty much everything except embeddings. Good catch!
This should also fix #250 since that likely was only a symptom, feel free to reopen that if it is something else.

<!-- gh-comment-id:1793715657 --> @DominikDoom commented on GitHub (Nov 5, 2023): Fixed by adding a filter condition that checks if the found path actually is a file. This would've likely also affected all other places where the extension searches for specific file types, so pretty much everything except embeddings. Good catch! This should also fix #250 since that likely was only a symptom, feel free to reopen that if it is something else.
Sign in to join this conversation.
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference
DominikDoom/a1111-sd-webui-tagcomplete#179
No description provided.