Compare commits

..

5 Commits
2.7.0 ... 2.7.3

Author SHA1 Message Date
DominikDoom
39ea33be9f Fix encoding for load too
Fixes #204
2023-07-22 21:15:44 +02:00
DominikDoom
1cac893e63 Create temp folder first before touching if it doesn't exist
Fixes #203
2023-07-22 20:46:10 +02:00
DominikDoom
94823b871c Add missing utf-8 encoding to cache write
Fixes #202
2023-07-22 18:17:30 +02:00
DominikDoom
599ff8a6f2 Don't load lycos if they point to the same path as loras
E.g. when using --lyco-patch-lora to replace built-in Loras.
Prevents duplicate entries.
2023-07-22 17:52:51 +02:00
DominikDoom
6893113e0b Fix typo 2023-07-22 15:51:04 +02:00
3 changed files with 12 additions and 6 deletions

View File

@@ -136,7 +136,7 @@ To add custom mappings for unknown Loras, you can use the UI provided by model-k
The only issue is that it has no official support for the Lycoris extension and doesn't scan its folder for files, so to add them through the UI you will have to temporarily move them into the Lora model folder to be able to select them in model-keywords dropdown.
Some are already included in the default list though, so trying it out first is advisable.
<details>
<summary>Walkthorugh to add custom keywords</summary>
<summary>Walkthrough to add custom keywords</summary>
![image](https://github.com/DominikDoom/a1111-sd-webui-tagcomplete/assets/34448969/4302c44e-c632-473d-a14a-76f164f966cb)
</details>

View File

@@ -7,6 +7,8 @@ from scripts.shared_paths import EXT_PATH, STATIC_TEMP_PATH, TEMP_PATH
# Set up our hash cache
known_hashes_file = TEMP_PATH.joinpath("known_lora_hashes.txt")
if not TEMP_PATH.exists():
TEMP_PATH.mkdir()
known_hashes_file.touch()
file_needs_update = False
@@ -15,7 +17,7 @@ hash_dict = {}
def load_hash_cache():
with open(known_hashes_file, "r") as file:
with open(known_hashes_file, "r", encoding="utf-8") as file:
for line in file:
name, hash, mtime = line.replace("\n", "").split(",")
hash_dict[name] = (hash, mtime)
@@ -24,7 +26,7 @@ def load_hash_cache():
def update_hash_cache():
global file_needs_update
if file_needs_update:
with open(known_hashes_file, "w") as file:
with open(known_hashes_file, "w", encoding="utf-8") as file:
for name, (hash, mtime) in hash_dict.items():
file.write(f"{name},{hash},{mtime}\n")

View File

@@ -263,15 +263,19 @@ def write_temp_files():
if model_keyword_installed:
load_hash_cache()
if LORA_PATH is not None and LORA_PATH.exists():
lora_exists = LORA_PATH is not None and LORA_PATH.exists()
if lora_exists:
lora = get_lora()
if lora:
write_to_temp_file('lora.txt', lora)
if LYCO_PATH is not None and LYCO_PATH.exists():
lyco_exists = LYCO_PATH is not None and LYCO_PATH.exists()
if lyco_exists and not (lora_exists and LYCO_PATH.samefile(LORA_PATH)):
lyco = get_lyco()
if lyco:
write_to_temp_file('lyco.txt', lyco)
elif lyco_exists and lora_exists and LYCO_PATH.samefile(LORA_PATH):
print("tag_autocomplete_helper: LyCORIS path is the same as LORA path, skipping")
if model_keyword_installed:
update_hash_cache()