mirror of
https://github.com/lllyasviel/Fooocus.git
synced 2026-08-16 13:13:16 +02:00
feat: add hash cache to metadata
This commit is contained in:
+11
-1
@@ -7,13 +7,23 @@ from PIL import Image
|
|||||||
import modules.config
|
import modules.config
|
||||||
import fooocus_version
|
import fooocus_version
|
||||||
# import advanced_parameters
|
# import advanced_parameters
|
||||||
from modules.util import quote, unquote, extract_styles_from_prompt, is_json
|
|
||||||
from modules.flags import MetadataScheme, Performance, Steps, lora_count_with_lcm
|
from modules.flags import MetadataScheme, Performance, Steps, lora_count_with_lcm
|
||||||
|
from modules.util import quote, unquote, extract_styles_from_prompt, is_json, calculate_sha256
|
||||||
|
|
||||||
re_param_code = r'\s*(\w[\w \-/]+):\s*("(?:\\.|[^\\"])+"|[^,]*)(?:,|$)'
|
re_param_code = r'\s*(\w[\w \-/]+):\s*("(?:\\.|[^\\"])+"|[^,]*)(?:,|$)'
|
||||||
re_param = re.compile(re_param_code)
|
re_param = re.compile(re_param_code)
|
||||||
re_imagesize = re.compile(r"^(\d+)x(\d+)$")
|
re_imagesize = re.compile(r"^(\d+)x(\d+)$")
|
||||||
|
|
||||||
|
hash_cache = {}
|
||||||
|
|
||||||
|
|
||||||
|
def get_sha256(filepath):
|
||||||
|
global hash_cache
|
||||||
|
|
||||||
|
if filepath not in hash_cache:
|
||||||
|
hash_cache[filepath] = calculate_sha256(filepath)
|
||||||
|
|
||||||
|
return hash_cache[filepath]
|
||||||
|
|
||||||
class MetadataParser(ABC):
|
class MetadataParser(ABC):
|
||||||
@abstractmethod
|
@abstractmethod
|
||||||
|
|||||||
Reference in New Issue
Block a user