From bd3e3891309416a00fcdc6a8ac81fe41a752a0ba Mon Sep 17 00:00:00 2001 From: Glenn Jocher Date: Mon, 15 Jun 2020 14:39:04 -0700 Subject: [PATCH] update google_utils.py --- utils/google_utils.py | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/utils/google_utils.py b/utils/google_utils.py index 9d80de1..0de6aa3 100644 --- a/utils/google_utils.py +++ b/utils/google_utils.py @@ -25,10 +25,15 @@ def attempt_download(weights): if file in d: r = gdrive_download(id=d[file], name=weights) - # Error check if not (r == 0 and os.path.exists(weights) and os.path.getsize(weights) > 1E6): # weights exist and > 1MB - os.system('rm ' + weights) # remove partial downloads - raise Exception(msg) + os.remove(weights) if os.path.exists(weights) else None # remove partial downloads + s = "curl -L -o %s 'https://storage.googleapis.com/ultralytics/yolov5/ckpt/%s'" % (weights, file) + r = os.system(s) # execute, capture return values + + # Error check + if not (r == 0 and os.path.exists(weights) and os.path.getsize(weights) > 1E6): # weights exist and > 1MB + os.remove(weights) if os.path.exists(weights) else None # remove partial downloads + raise Exception(msg) def gdrive_download(id='1HaXkef9z6y5l4vUnCYgdmEAj61c6bfWO', name='coco.zip'):