Spaces:
Running
Running
Commit
·
ad9ea09
1
Parent(s):
1db513a
Migrate snapshot folder files to parent
Browse files- download_model.py +24 -30
download_model.py
CHANGED
@@ -9,37 +9,31 @@ MODEL_CACHE_DIR = "/app/model_cache"
|
|
9 |
print("⏳ Downloading the SentenceTransformer model...")
|
10 |
model_path = snapshot_download(repo_id=MODEL_REPO, cache_dir=MODEL_CACHE_DIR)
|
11 |
|
12 |
-
# Find the correct
|
13 |
-
|
14 |
-
|
15 |
-
|
16 |
-
|
17 |
-
|
18 |
-
|
19 |
-
|
20 |
-
|
21 |
-
|
22 |
-
|
23 |
-
|
24 |
-
|
25 |
-
|
26 |
-
|
27 |
-
|
28 |
-
# Move
|
29 |
-
|
30 |
-
|
31 |
-
|
32 |
-
|
33 |
-
|
34 |
-
|
35 |
-
shutil.move(source_path, dest_path)
|
36 |
-
|
37 |
-
print(f"✅ Model extracted and flattened in {MODEL_CACHE_DIR}")
|
38 |
-
else:
|
39 |
-
print("❌ No snapshot folder found!")
|
40 |
-
exit(1)
|
41 |
else:
|
42 |
-
print("❌
|
43 |
exit(1)
|
44 |
|
45 |
# Verify structure
|
|
|
9 |
print("⏳ Downloading the SentenceTransformer model...")
|
10 |
model_path = snapshot_download(repo_id=MODEL_REPO, cache_dir=MODEL_CACHE_DIR)
|
11 |
|
12 |
+
# Find the correct model path and move files
|
13 |
+
print("Model path: ", model_path)
|
14 |
+
|
15 |
+
if os.path.exists(model_path):
|
16 |
+
# Ensure the destination directory is clean
|
17 |
+
if os.path.exists(MODEL_CACHE_DIR):
|
18 |
+
shutil.rmtree(MODEL_CACHE_DIR)
|
19 |
+
os.makedirs(MODEL_CACHE_DIR, exist_ok=True)
|
20 |
+
|
21 |
+
print(f"📂 Moving model files from {model_path} to {MODEL_CACHE_DIR}...")
|
22 |
+
|
23 |
+
# Move all files and directories from model_path to MODEL_CACHE_DIR
|
24 |
+
for item in os.listdir(model_path):
|
25 |
+
src_path = os.path.join(model_path, item)
|
26 |
+
dest_path = os.path.join(MODEL_CACHE_DIR, item)
|
27 |
+
|
28 |
+
# Move directories and files while preserving structure
|
29 |
+
if os.path.isdir(src_path):
|
30 |
+
shutil.move(src_path, dest_path)
|
31 |
+
else:
|
32 |
+
shutil.move(src_path, dest_path)
|
33 |
+
|
34 |
+
print(f"✅ Model extracted and flattened in {MODEL_CACHE_DIR}")
|
|
|
|
|
|
|
|
|
|
|
|
|
35 |
else:
|
36 |
+
print("❌ Model download failed! Directory not found:", model_path)
|
37 |
exit(1)
|
38 |
|
39 |
# Verify structure
|