glenn-jocher
commited on
Commit
•
d3e786e
1
Parent(s):
f310ca3
google_utils.py bug fix #355
Browse files- utils/google_utils.py +5 -5
utils/google_utils.py
CHANGED
@@ -9,10 +9,10 @@ from pathlib import Path
|
|
9 |
|
10 |
def attempt_download(weights):
|
11 |
# Attempt to download pretrained weights if not found locally
|
12 |
-
weights = weights.strip()
|
13 |
msg = weights + ' missing, try downloading from https://drive.google.com/drive/folders/1Drs_Aiu7xx6S-ix95f9kNsA6ueKRpN2J'
|
14 |
|
15 |
-
r = 1
|
16 |
if len(weights) > 0 and not os.path.isfile(weights):
|
17 |
d = {'yolov3-spp.pt': '1mM67oNw4fZoIOL1c8M3hHmj66d8e-ni_', # yolov3-spp.yaml
|
18 |
'yolov5s.pt': '1R5T6rIyy3lLwgFXNms8whc-387H0tMQO', # yolov5s.yaml
|
@@ -27,7 +27,7 @@ def attempt_download(weights):
|
|
27 |
|
28 |
if not (r == 0 and os.path.exists(weights) and os.path.getsize(weights) > 1E6): # weights exist and > 1MB
|
29 |
os.remove(weights) if os.path.exists(weights) else None # remove partial downloads
|
30 |
-
s = "curl -L -o %s '
|
31 |
r = os.system(s) # execute, capture return values
|
32 |
|
33 |
# Error check
|
@@ -36,8 +36,7 @@ def attempt_download(weights):
|
|
36 |
raise Exception(msg)
|
37 |
|
38 |
|
39 |
-
def gdrive_download(id='
|
40 |
-
# https://gist.github.com/tanaikech/f0f2d122e05bf5f971611258c22c110f
|
41 |
# Downloads a file from Google Drive, accepting presented query
|
42 |
# from utils.google_utils import *; gdrive_download()
|
43 |
t = time.time()
|
@@ -71,6 +70,7 @@ def gdrive_download(id='1HaXkef9z6y5l4vUnCYgdmEAj61c6bfWO', name='coco.zip'):
|
|
71 |
print('Done (%.1fs)' % (time.time() - t))
|
72 |
return r
|
73 |
|
|
|
74 |
# def upload_blob(bucket_name, source_file_name, destination_blob_name):
|
75 |
# # Uploads a file to a bucket
|
76 |
# # https://cloud.google.com/storage/docs/uploading-objects#storage-upload-object-python
|
|
|
9 |
|
10 |
def attempt_download(weights):
|
11 |
# Attempt to download pretrained weights if not found locally
|
12 |
+
weights = weights.strip().replace("'", '')
|
13 |
msg = weights + ' missing, try downloading from https://drive.google.com/drive/folders/1Drs_Aiu7xx6S-ix95f9kNsA6ueKRpN2J'
|
14 |
|
15 |
+
r = 1 # return
|
16 |
if len(weights) > 0 and not os.path.isfile(weights):
|
17 |
d = {'yolov3-spp.pt': '1mM67oNw4fZoIOL1c8M3hHmj66d8e-ni_', # yolov3-spp.yaml
|
18 |
'yolov5s.pt': '1R5T6rIyy3lLwgFXNms8whc-387H0tMQO', # yolov5s.yaml
|
|
|
27 |
|
28 |
if not (r == 0 and os.path.exists(weights) and os.path.getsize(weights) > 1E6): # weights exist and > 1MB
|
29 |
os.remove(weights) if os.path.exists(weights) else None # remove partial downloads
|
30 |
+
s = "curl -L -o %s 'storage.googleapis.com/ultralytics/yolov5/ckpt/%s'" % (weights, file)
|
31 |
r = os.system(s) # execute, capture return values
|
32 |
|
33 |
# Error check
|
|
|
36 |
raise Exception(msg)
|
37 |
|
38 |
|
39 |
+
def gdrive_download(id='1n_oKgR81BJtqk75b00eAjdv03qVCQn2f', name='coco128.zip'):
|
|
|
40 |
# Downloads a file from Google Drive, accepting presented query
|
41 |
# from utils.google_utils import *; gdrive_download()
|
42 |
t = time.time()
|
|
|
70 |
print('Done (%.1fs)' % (time.time() - t))
|
71 |
return r
|
72 |
|
73 |
+
|
74 |
# def upload_blob(bucket_name, source_file_name, destination_blob_name):
|
75 |
# # Uploads a file to a bucket
|
76 |
# # https://cloud.google.com/storage/docs/uploading-objects#storage-upload-object-python
|