Sanket17 commited on
Commit
0f9d8ab
·
verified ·
1 Parent(s): 8574f97

Update models.py

Browse files
Files changed (1) hide show
  1. models.py +5 -4
models.py CHANGED
@@ -6,16 +6,17 @@ import os
6
  from safetensors.torch import load_file # Safetensors loading method
7
 
8
  # Set a custom cache directory for gdown
9
- os.makedirs("cache", exist_ok=True)
10
- os.environ["GDOWN_CACHE"] = os.path.abspath("cache")
 
11
 
12
  def download_model_from_drive(file_id, destination_path):
13
  """Download the model from Google Drive using gdown."""
14
  # Construct the Google Drive download URL
15
  url = f"https://drive.google.com/uc?id={file_id}"
16
- # Extract the directory name from the destination path
17
  directory = os.path.dirname(destination_path)
18
- if directory: # Ensure the directory exists only if it's valid
19
  os.makedirs(directory, exist_ok=True)
20
  # Download the file
21
  gdown.download(url, destination_path, quiet=False)
 
6
  from safetensors.torch import load_file # Safetensors loading method
7
 
8
  # Set a custom cache directory for gdown
9
+ gdown_cache_dir = os.path.join(os.getcwd(), "cache")
10
+ os.makedirs(gdown_cache_dir, exist_ok=True)
11
+ os.environ["GDOWN_CACHE"] = gdown_cache_dir # Explicitly set GDOWN_CACHE
12
 
13
  def download_model_from_drive(file_id, destination_path):
14
  """Download the model from Google Drive using gdown."""
15
  # Construct the Google Drive download URL
16
  url = f"https://drive.google.com/uc?id={file_id}"
17
+ # Ensure the destination directory exists
18
  directory = os.path.dirname(destination_path)
19
+ if directory:
20
  os.makedirs(directory, exist_ok=True)
21
  # Download the file
22
  gdown.download(url, destination_path, quiet=False)