Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
  • Loading branch information
Foligattilj authored and Fannovel16 committed Mar 8, 2024
1 parent 1d89118 commit 3c2c13d
Showing 1 changed file with 4 additions and 1 deletion.
5 changes: 4 additions & 1 deletion src/controlnet_aux/util.py
Original file line number Diff line number Diff line change
Expand Up @@ -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'
Expand All @@ -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

Expand Down Expand Up @@ -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)

Expand Down Expand Up @@ -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

0 comments on commit 3c2c13d

Please sign in to comment.