sam2ai commited on
Commit
2ef2341
·
1 Parent(s): bed5475

Synced repo using 'sync_with_huggingface' Github Action

Browse files
Files changed (1) hide show
  1. download.py +2 -42
download.py CHANGED
@@ -1,44 +1,4 @@
1
- import argparse
2
- import requests
3
- import os
4
- from tqdm import tqdm
5
 
6
- def download_file(url, path):
7
- response = requests.get(url, stream=True)
8
- total_size_in_bytes = int(response.headers.get('content-length', 0))
9
- block_size = 1024 #1 Kbyte
10
- progress_bar = tqdm(total=total_size_in_bytes, unit='iB', unit_scale=True)
11
 
12
- with open(path, 'wb') as file:
13
- for data in response.iter_content(block_size):
14
- progress_bar.update(len(data))
15
- file.write(data)
16
-
17
- progress_bar.close()
18
-
19
- def download_model(model_name, destination_folder="models"):
20
- # Define the base URL and headers for the Hugging Face API
21
- base_url = f"https://huggingface.co/{model_name}/resolve/main"
22
- headers = {"User-Agent": "Hugging Face Python"}
23
-
24
- # Send a GET request to the Hugging Face API to get a list of all files
25
- response = requests.get(f"https://huggingface.co/api/models/{model_name}", headers=headers)
26
- response.raise_for_status()
27
-
28
- # Extract the list of files from the response JSON
29
- files_to_download = [file["rfilename"] for file in response.json()["siblings"]]
30
-
31
- # Ensure the directory exists
32
- os.makedirs(f"{destination_folder}/{model_name}", exist_ok=True)
33
-
34
- # Download each file
35
- for file in files_to_download:
36
- print(f"Downloading {file}...")
37
- download_file(f"{base_url}/{file}", f"{destination_folder}/{model_name}/{file}")
38
-
39
- if __name__ == "__main__":
40
- # parser = argparse.ArgumentParser()
41
- # parser.add_argument("model_name", type=str, default="sam2ai/whisper-odia-small-finetune-int8-ct2", help="Name of the model to download.")
42
- # args = parser.parse_args()
43
-
44
- download_model("BAAI/bge-small-en-v1.5")
 
1
+ from huggingface_hub import snapshot_download
 
 
 
2
 
 
 
 
 
 
3
 
4
+ snapshot_download(repo_id="BAAI/bge-small-en-v1.5", local_dir='./models/BAAI/bge-small-en-v1.5')