2021SC@SDUSC YOLO5 source code analysis (7) yolov5 utils.download

Hits: 0


This article analyzes [yolov5] ‘s utils.download.py

As the name implies, it is a bunch of methods for downloading (weight files, [data sets] ), not core code, you can take it with you if you learn the yolo model itself

def gsutil_getsize

This method assists google’s gsutil, which is only called in the implementation of the -bucket option of train. gsutil requires credit card registration, and uses subprocess, not platform-independent, and domestic ladders are generally not used.

def safe_download(file, url, url2=None, min_bytes=1E0, error_msg='')

This method is also downloaded as described in the title.
First, use the torch hub, which contains a series of pre-training resources for well-known models. Ladders are needed in China. If there is a problem, use curl to download url1 or url2 and try at most three times. Finally if the download fails print an error message to the console.

def attempt_download(file, repo='ultralytics/yolov5'):

This method calls safe_download() to try to download in various places~

def gdrive_download(id='16TiPfZj7htmTyhntwcZyEEAejOUxuT6m', file='tmp.zip'):

As the name implies, download and unzip from google drive, and no usage found in the project file, that is, it has never been called in the project ~
When there is a need to automatically download files in google drive, you can use the following commands:

$ wget "drive.google.com/uc?export=download&id={id}" -O {saved_Name}

Replace {id} with the id of the drive file, you need to set the share in google drive so that anyone who knows can download it, {saved_Name} is optional
and needs to run in a 100% external network environment, the ladder cannot be similar to ordinary global agents Or smart agent~

def get_token(cookie="./cookie"):

It is only called when gdrive_download gets the cookie, but it is not called~

You may also like...

Leave a Reply

Your email address will not be published.