From 36aee1457a4198840ddbd004d24d85547a0d7c16 Mon Sep 17 00:00:00 2001 From: Hacker 17082006 Date: Fri, 8 Mar 2024 21:43:14 +0700 Subject: [PATCH] Try to fix https://github.com/Fannovel16/comfyui_controlnet_aux/issues/264 --- src/controlnet_aux/util.py | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/src/controlnet_aux/util.py b/src/controlnet_aux/util.py index c6e5e38..ad089e1 100644 --- a/src/controlnet_aux/util.py +++ b/src/controlnet_aux/util.py @@ -8,6 +8,7 @@ import warnings from torch.hub import get_dir, download_url_to_file from huggingface_hub import hf_hub_download +import tempfile TORCHHUB_PATH = Path(__file__).parent / 'depth_anything' / 'torchhub' @@ -21,6 +22,7 @@ DEPTH_ANYTHING_MODEL_NAME = "LiheYoung/Depth-Anything" #HF Space DIFFUSION_EDGE_MODEL_NAME = "hr16/Diffusion-Edge" +temp_dir = tempfile.gettempdir() annotator_ckpts_path = os.path.join(Path(__file__).parents[2], 'ckpts') USE_SYMLINKS = False @@ -260,7 +262,7 @@ def custom_torch_download(filename, cache_dir=annotator_ckpts_path): print("Hash check passed") return model_path -def custom_hf_download(pretrained_model_or_path, filename, cache_dir=annotator_ckpts_path, subfolder='', use_symlinks=USE_SYMLINKS, repo_type="model"): +def custom_hf_download(pretrained_model_or_path, filename, cache_dir=temp_dir, subfolder='', use_symlinks=USE_SYMLINKS, repo_type="model"): local_dir = os.path.join(cache_dir, pretrained_model_or_path) model_path = os.path.join(local_dir, *subfolder.split('/'), filename) @@ -310,4 +312,5 @@ def custom_hf_download(pretrained_model_or_path, filename, cache_dir=annotator_c shutil.rmtree(cache_dir_d) except Exception as e : print(e) + return model_path