TymaaHammouda commited on
Commit
08d65d3
·
1 Parent(s): bfb7b0e

Update download_folder_from_hf function

Browse files
Files changed (1) hide show
  1. app.py +10 -13
app.py CHANGED
@@ -11,30 +11,27 @@ os.makedirs(SINATOOLS_DIR, exist_ok=True)
11
  # Destination path
12
  dest_path = os.path.join(SINATOOLS_DIR)
13
 
14
-
15
  from huggingface_hub import snapshot_download
16
  import os
17
 
18
- def download_folder_from_hf(repo_id, folder_name):
19
- """
20
- Downloads a folder from a Hugging Face model repo into ~/.sinatools
21
- """
22
- target_dir = os.path.expanduser("~/.sinatools")
23
 
24
- local_path = snapshot_download(
25
- repo_id=repo_id,
26
- allow_patterns=f"{folder_name}/**",
27
- local_dir=target_dir,
28
  local_dir_use_symlinks=False
29
  )
30
 
31
- return os.path.join(local_path, folder_name)
32
 
33
 
34
  print("Start loading")
35
  # Download explicitly to the expected path
36
- download_folder_from_hf("SinaLab/ArabGlossBERT", "bert-base-arabertv02_22_May_2021_00h_allglosses_unused01")
37
- download_folder_from_hf("SinaLab/ArabGlossBERT", "bert-base-arabertv02")
 
38
 
39
  print("Finish loading")
40
 
 
11
  # Destination path
12
  dest_path = os.path.join(SINATOOLS_DIR)
13
 
 
14
  from huggingface_hub import snapshot_download
15
  import os
16
 
17
+ def download_folder_from_hf():
18
+ local_dir = os.path.expanduser("~/.sinatools")
 
 
 
19
 
20
+ snapshot_download(
21
+ repo_id="SinaLab/ArabGlossBERT",
22
+ allow_patterns="bert-base-arabertv02/**",
23
+ local_dir=local_dir,
24
  local_dir_use_symlinks=False
25
  )
26
 
27
+ return os.path.join(local_dir, "bert-base-arabertv02")
28
 
29
 
30
  print("Start loading")
31
  # Download explicitly to the expected path
32
+ # download_folder_from_hf("SinaLab/ArabGlossBERT", "bert-base-arabertv02_22_May_2021_00h_allglosses_unused01")
33
+ # download_folder_from_hf("SinaLab/ArabGlossBERT", "bert-base-arabertv02")
34
+ download_folder_from_hf()
35
 
36
  print("Finish loading")
37