wissamantoun commited on
Commit
5d082b0
1 Parent(s): 0c075a9

new way to download models

Browse files
Files changed (1) hide show
  1. backend/utils.py +25 -12
backend/utils.py CHANGED
@@ -1,5 +1,4 @@
1
  import psutil
2
- from huggingface_hub import Repository
3
  import os
4
 
5
 
@@ -11,15 +10,29 @@ def get_current_ram_usage():
11
  def download_models(models):
12
  model_dirs = {}
13
  for model in models:
14
- model_dirs[model] = Repository(
15
- model, clone_from=f"https://huggingface.co/researchaccount/{model}"
16
- )
17
- return model_dirs
18
-
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
19
 
20
- def install_git_lfs():
21
- os.system(
22
- "curl -s https://packagecloud.io/install/repositories/github/git-lfs/script.deb.sh | bash"
23
- )
24
- os.system("apt-get install git-lfs")
25
- os.system("git lfs install")
 
1
  import psutil
 
2
  import os
3
 
4
 
 
10
  def download_models(models):
11
  model_dirs = {}
12
  for model in models:
13
+ model_dirs = {
14
+ model: model
15
+ } # useless i know, but i don't want to change the code
16
+ for i in range(0, 5):
17
+ curr_dir = f"{model}/train_{i}/best_model/"
18
+ os.makedirs(curr_dir)
19
+ os.system(
20
+ f"wget https://huggingface.co/researchaccount/{model}/resolve/main/train_{i}/best_model/config.json -P {curr_dir}"
21
+ )
22
+ os.system(
23
+ f"wget https://huggingface.co/researchaccount/{model}/resolve/main/train_{i}/best_model/pytorch_model.bin -P {curr_dir}"
24
+ )
25
+ os.system(
26
+ f"wget https://huggingface.co/researchaccount/{model}/resolve/main/train_{i}/best_model/special_tokens_map.json -P {curr_dir}"
27
+ )
28
+ os.system(
29
+ f"wget https://huggingface.co/researchaccount/{model}/resolve/main/train_{i}/best_model/tokenizer_config.json -P {curr_dir}"
30
+ )
31
+ os.system(
32
+ f"wget https://huggingface.co/researchaccount/{model}/resolve/main/train_{i}/best_model/training_args.bin -P {curr_dir}"
33
+ )
34
+ os.system(
35
+ f"wget https://huggingface.co/researchaccount/{model}/resolve/main/train_{i}/best_model/vocab.txt -P {curr_dir}"
36
+ )
37
 
38
+ return model_dirs