MrD05 commited on
Commit
ce7ac1c
1 Parent(s): 66c16ea

Update download-model.py

Browse files
Files changed (1) hide show
  1. download-model.py +6 -3
download-model.py CHANGED
@@ -94,7 +94,7 @@ facebook/opt-1.3b
94
 
95
  def get_download_links_from_huggingface(model, branch):
96
  base = "https://huggingface.co"
97
- page = f"/api/models/{model}/tree/{branch}?cursor="
98
  cursor = b""
99
 
100
  links = []
@@ -102,8 +102,11 @@ def get_download_links_from_huggingface(model, branch):
102
  has_pytorch = False
103
  has_safetensors = False
104
  while True:
105
- content = requests.get(f"{base}{page}{cursor.decode()}").content
106
-
 
 
 
107
  dict = json.loads(content)
108
  if len(dict) == 0:
109
  break
 
94
 
95
  def get_download_links_from_huggingface(model, branch):
96
  base = "https://huggingface.co"
97
+ page = f"/api/models/{model}/tree/{branch}"
98
  cursor = b""
99
 
100
  links = []
 
102
  has_pytorch = False
103
  has_safetensors = False
104
  while True:
105
+ url = f"{base}{page}" + (f"?cursor={cursor.decode()}" if cursor else "")
106
+ r = requests.get(url)
107
+ r.raise_for_status()
108
+ content = r.content
109
+
110
  dict = json.loads(content)
111
  if len(dict) == 0:
112
  break