0bc1db58d82c2482bfac1e32a3a43cfd5a533da2,utils/google_utils.py,,attempt_download,#,19

Before Change


        except Exception as e:  // GCP
            print("Download error: %s" % e)
            assert redundant, "No secondary mirror"
            url = "https://storage.googleapis.com/ultralytics/yolov3/ckpt/" + file
            print("Downloading %s to %s..." % (url, weights))
            r = os.system("curl -L %s -o %s" % (url, weights))  // torch.hub.download_url_to_file(url, weights)
        finally:
            if not (os.path.exists(weights) and os.path.getsize(weights) > 1E6):  // check
                os.remove(weights) if os.path.exists(weights) else None  // remove partial downloads

After Change



def attempt_download(file):
    // Attempt file download if does not exist
    file = Path(str(file).strip().replace(""", "").lower())

    if not file.exists():
        response = requests.get("https://api.github.com/repos/ultralytics/yolov3/releases/latest").json()  // github api
        assets = [x["name"] for x in response["assets"]]  // release assets ["yolov3.pt", "yolov3-spp.pt", ...]
        name = file.name

        if name in assets:
            msg = f"{file} missing, try downloading from https://github.com/ultralytics/yolov3/releases/"
            redundant = False  // second download option
Italian Trulli
In pattern: SUPERPATTERN

Frequency: 3

Non-data size: 4

Instances


Project Name: ultralytics/yolov3
Commit Name: 0bc1db58d82c2482bfac1e32a3a43cfd5a533da2
Time: 2021-01-10
Author: glenn.jocher@ultralytics.com
File Name: utils/google_utils.py
Class Name:
Method Name: attempt_download


Project Name: ultralytics/yolov3
Commit Name: 0bc1db58d82c2482bfac1e32a3a43cfd5a533da2
Time: 2021-01-10
Author: glenn.jocher@ultralytics.com
File Name: utils/google_utils.py
Class Name:
Method Name: gdrive_download


Project Name: comic/grand-challenge.org
Commit Name: a118c4aa15f23e2efbe5e69f8b254074dc7e6446
Time: 2018-12-05
Author: jamesmeakin@gmail.com
File Name: app/grandchallenge/core/validators.py
Class Name: ExtensionValidator
Method Name: _validate_filepath