Update models.py
Browse files
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.
|
| 10 |
-
os.
|
|
|
|
| 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 |
-
#
|
| 17 |
directory = os.path.dirname(destination_path)
|
| 18 |
-
if directory:
|
| 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)
|