From 9f93cf6110b859ff8c82d3f49039d82d12b37d10 Mon Sep 17 00:00:00 2001 From: Manuel Schmid Date: Wed, 17 Jul 2024 10:49:55 +0200 Subject: [PATCH] fix: resolve circular dependency for sha256, update files and init cache after initial model download fixes https://github.com/lllyasviel/Fooocus/issues/2372 (cherry picked from commit 5c43a4bece059a70fc6246dd01622093cac2c0c9) --- launch.py | 4 ++++ modules/config.py | 5 ----- modules/hash_cache.py | 3 +-- 3 files changed, 5 insertions(+), 7 deletions(-) diff --git a/launch.py b/launch.py index a4609927..77c2e2c2 100644 --- a/launch.py +++ b/launch.py @@ -85,6 +85,7 @@ if args.hf_mirror is not None : print("Set hf_mirror to:", args.hf_mirror) from modules import config +from modules.hash_cache import init_cache os.environ["U2NET_HOME"] = config.path_inpaint os.environ['GRADIO_TEMP_DIR'] = config.temp_path @@ -140,4 +141,7 @@ config.default_base_model_name, config.checkpoint_downloads = download_models( config.default_base_model_name, config.previous_default_models, config.checkpoint_downloads, config.embeddings_downloads, config.lora_downloads, config.vae_downloads) +config.update_files() +init_cache(config.model_filenames, config.paths_checkpoints, config.lora_filenames, config.paths_loras) + from webui import * diff --git a/modules/config.py b/modules/config.py index 05d17843..ee867e5f 100644 --- a/modules/config.py +++ b/modules/config.py @@ -7,7 +7,6 @@ import args_manager import tempfile import modules.flags import modules.sdxl_styles -from modules.hash_cache import init_cache from modules.model_loader import load_file_from_url from modules.extra_utils import makedirs_with_log, get_files_from_folder, try_eval_env_var @@ -889,7 +888,3 @@ def downloading_sam_vit_h(): file_name='sam_vit_h_4b8939.pth' ) return os.path.join(path_sam, 'sam_vit_h_4b8939.pth') - - -update_files() -init_cache(model_filenames, paths_checkpoints, lora_filenames, paths_loras) diff --git a/modules/hash_cache.py b/modules/hash_cache.py index c33e675e..e857b003 100644 --- a/modules/hash_cache.py +++ b/modules/hash_cache.py @@ -4,8 +4,7 @@ from concurrent.futures import ThreadPoolExecutor from multiprocessing import cpu_count import args_manager -from modules.util import get_file_from_folder_list -from modules.util import sha256, HASH_SHA256_LENGTH +from modules.util import sha256, HASH_SHA256_LENGTH, get_file_from_folder_list hash_cache_filename = 'hash_cache.txt' hash_cache = {}