Spaces:
Sleeping
Sleeping
Leonardo Oliva
commited on
Commit
·
9097ea4
1
Parent(s):
ba076a5
- utils/utils_dl_utils.py +19 -0
utils/utils_dl_utils.py
ADDED
@@ -0,0 +1,19 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
import os
|
2 |
+
import requests
|
3 |
+
from tqdm import tqdm
|
4 |
+
|
5 |
+
|
6 |
+
def dl_guff_model(model_dir, url):
|
7 |
+
file_name = url.split('/')[-1]
|
8 |
+
folder = model_dir
|
9 |
+
file_path = os.path.join(folder, file_name)
|
10 |
+
if not os.path.exists(file_path):
|
11 |
+
response = requests.get(url, allow_redirects=True)
|
12 |
+
if response.status_code == 200:
|
13 |
+
with open(file_path, 'wb') as f:
|
14 |
+
f.write(response.content)
|
15 |
+
print(f'Downloaded {file_name}')
|
16 |
+
else:
|
17 |
+
print(f'Failed to download {file_name}')
|
18 |
+
else:
|
19 |
+
print(f'{file_name} already exists.')
|