mirror of
https://github.com/lllyasviel/Fooocus.git
synced 2026-08-16 13:13:16 +02:00
Addressed PR comments
This commit is contained in:
@@ -1,21 +0,0 @@
|
|||||||
|
|
||||||
import os
|
|
||||||
|
|
||||||
#TODO: Use refactor to use glob instead
|
|
||||||
def get_files_from_folder(folder_path, extensions=None, name_filter=None):
|
|
||||||
if not os.path.isdir(folder_path):
|
|
||||||
raise ValueError("Folder path is not a valid directory.")
|
|
||||||
|
|
||||||
filenames = []
|
|
||||||
|
|
||||||
for root, _, files in os.walk(folder_path, topdown=False):
|
|
||||||
relative_path = os.path.relpath(root, folder_path)
|
|
||||||
if relative_path == ".":
|
|
||||||
relative_path = ""
|
|
||||||
for filename in sorted(files, key=lambda s: s.casefold()):
|
|
||||||
_, file_extension = os.path.splitext(filename)
|
|
||||||
if (extensions is None or file_extension.lower() in extensions) and (name_filter is None or name_filter in _):
|
|
||||||
path = os.path.join(relative_path, filename)
|
|
||||||
filenames.append(path)
|
|
||||||
|
|
||||||
return filenames
|
|
||||||
+1
-1
@@ -20,7 +20,7 @@ LANCZOS = (Image.Resampling.LANCZOS if hasattr(Image, 'Resampling') else Image.L
|
|||||||
# Regexp compiled once. Matches entries with the following pattern:
|
# Regexp compiled once. Matches entries with the following pattern:
|
||||||
# <lora:some_lora:1>
|
# <lora:some_lora:1>
|
||||||
# <lora:aNotherLora:-1.6>
|
# <lora:aNotherLora:-1.6>
|
||||||
LORAS_PROMPT_PATTERN = re.compile(".*<lora:(.+):([-+]?(?:\d*\.*\d*))>.*")
|
LORAS_PROMPT_PATTERN = re.compile(r".* <lora : ([^:]+) : ([+-]? (?: (?:\d+ (?:\.\d*)?) | (?:\.\d+)))> .*", re.X)
|
||||||
|
|
||||||
HASH_SHA256_LENGTH = 10
|
HASH_SHA256_LENGTH = 10
|
||||||
|
|
||||||
|
|||||||
@@ -35,6 +35,10 @@ class TestUtils(unittest.TestCase):
|
|||||||
"input": ("some prompt, very cool, <lora:hey-lora:0.4><lora:you-lora:0.2>", [], 3),
|
"input": ("some prompt, very cool, <lora:hey-lora:0.4><lora:you-lora:0.2>", [], 3),
|
||||||
"output": [("you-lora.safetensors", 0.2)],
|
"output": [("you-lora.safetensors", 0.2)],
|
||||||
},
|
},
|
||||||
|
{
|
||||||
|
"input": ("<lora:foo:1..2>, <lora:bar:.>, <lora:baz:+> and <lora:quux:>",[], 6),
|
||||||
|
"output": []
|
||||||
|
}
|
||||||
]
|
]
|
||||||
|
|
||||||
for test in test_cases:
|
for test in test_cases:
|
||||||
|
|||||||
Reference in New Issue
Block a user