From e4fbf5f0dc99298bb5160f8c1338e62090651742 Mon Sep 17 00:00:00 2001 From: Vladimir Mandic Date: Mon, 13 Jan 2025 14:08:40 -0500 Subject: [PATCH] fix hf cache setting override Signed-off-by: Vladimir Mandic --- CHANGELOG.md | 1 + modules/shared.py | 12 ++---------- wiki | 2 +- 3 files changed, 4 insertions(+), 11 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 216f06d3f..8a4c7346e 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -64,6 +64,7 @@ - zluda installer - control inherit parent pipe settings - control logging + - hf cache folder settings ## Update for 2024-12-31 diff --git a/modules/shared.py b/modules/shared.py index 635ca86dd..707657d5d 100644 --- a/modules/shared.py +++ b/modules/shared.py @@ -84,15 +84,7 @@ console = Console(log_time=True, log_time_format='%H:%M:%S-%f') dir_timestamps = {} dir_cache = {} max_workers = 8 -if os.environ.get("SD_HFCACHEDIR", None) is not None: - hfcache_dir = os.environ.get("SD_HFCACHEDIR") -if os.environ.get("HF_HUB_CACHE", None) is not None: - hfcache_dir = os.environ.get("HF_HUB_CACHE") -elif os.environ.get("HF_HUB", None) is not None: - hfcache_dir = os.path.join(os.environ.get("HF_HUB"), '.cache') -else: - hfcache_dir = os.path.join(os.path.expanduser('~'), '.cache', 'huggingface', 'hub') - os.environ["HF_HUB_CACHE"] = hfcache_dir +default_hfcache_dir = os.environ.get("SD_HFCACHEDIR", None) or os.path.join(os.path.expanduser('~'), '.cache', 'huggingface', 'hub') class Backend(Enum): @@ -668,7 +660,7 @@ options_templates.update(options_section(('system-paths', "System Paths"), { "model_paths_sep_options": OptionInfo("

Paths for specific models

", "", gr.HTML), "ckpt_dir": OptionInfo(os.path.join(paths.models_path, 'Stable-diffusion'), "Folder with stable diffusion models", folder=True), "diffusers_dir": OptionInfo(os.path.join(paths.models_path, 'Diffusers'), "Folder with Huggingface models", folder=True), - "hfcache_dir": OptionInfo(hfcache_dir, "Folder for Huggingface cache", folder=True), + "hfcache_dir": OptionInfo(default_hfcache_dir, "Folder for Huggingface cache", folder=True), "vae_dir": OptionInfo(os.path.join(paths.models_path, 'VAE'), "Folder with VAE files", folder=True), "unet_dir": OptionInfo(os.path.join(paths.models_path, 'UNET'), "Folder with UNET files", folder=True), "te_dir": OptionInfo(os.path.join(paths.models_path, 'Text-encoder'), "Folder with Text encoder files", folder=True), diff --git a/wiki b/wiki index 29e37ad76..0a234ff83 160000 --- a/wiki +++ b/wiki @@ -1 +1 @@ -Subproject commit 29e37ad766904bc04f9e9701c2503a3f0898964a +Subproject commit 0a234ff830f861b5ebefeab6952a32804afdf911