當前位置: 首頁>>代碼示例>>Python>>正文


Python gdown.download方法代碼示例

本文整理匯總了Python中gdown.download方法的典型用法代碼示例。如果您正苦於以下問題:Python gdown.download方法的具體用法?Python gdown.download怎麽用?Python gdown.download使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在gdown的用法示例。


在下文中一共展示了gdown.download方法的6個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。

示例1: cached_download

# 需要導入模塊: import gdown [as 別名]
# 或者: from gdown import download [as 別名]
def cached_download(url, path, md5=None, quiet=False, postprocess=None):

    def check_md5(path, md5):
        print('[{:s}] Checking md5 ({:s})'.format(path, md5))
        return md5sum(path) == md5

    if osp.exists(path) and not md5:
        print('[{:s}] File exists ({:s})'.format(path, md5sum(path)))
    elif osp.exists(path) and md5 and check_md5(path, md5):
        pass
    else:
        dirpath = osp.dirname(path)
        if not osp.exists(dirpath):
            os.makedirs(dirpath)
        gdown.download(url, path, quiet=quiet)

    if postprocess is not None:
        postprocess(path)

    return path 
開發者ID:wkentaro,項目名稱:fcn,代碼行數:22,代碼來源:data.py

示例2: main

# 需要導入模塊: import gdown [as 別名]
# 或者: from gdown import download [as 別名]
def main():
    parser = argparse.ArgumentParser(description='Download and unpack zipped results')
    parser.add_argument('--tracker', type=str, default='pytracking',
                        help='Name of tracker results to download, or "pytracking" (downloads results for PyTracking'
                             ' based trackers, or "external" (downloads results for external trackers) or "all"')
    parser.add_argument('--output_path', type=str, default=None,
                        help='Path to the directory where the results will be unpacked.')
    parser.add_argument('--temp_download_path', type=str, default=None,
                        help='Temporary path used for downloading the Zip files.')
    parser.add_argument('--download', type=bool, default=True,
                        help='Whether to download results or unpack existing downloaded files.')
    args = parser.parse_args()

    download_path = args.temp_download_path
    if download_path is None:
        download_path = '{}/pytracking_results/'.format(tempfile.gettempdir())

    if args.download:
        download_results(download_path, args.tracker)

    unpack_tracking_results(download_path, args.output_path) 
開發者ID:visionml,項目名稱:pytracking,代碼行數:23,代碼來源:download_results.py

示例3: maybe_download_files

# 需要導入模塊: import gdown [as 別名]
# 或者: from gdown import download [as 別名]
def maybe_download_files(data_dir: str = "data") -> None:
    if not os.path.exists(data_dir):
        os.makedirs(data_dir, exist_ok=True)
        if IS_TEST:
            # Sample data pickle
            gdown.download(SMALL_DATA_URL, output=SAMPLE_DATA, quiet=None)
        else:
            # Books
            gdown.download(YA_BOOKS_URL, output=BOOK_DATA, quiet=None)
            # Interactions
            gdown.download(YA_INTERACTIONS_URL, output=INTERACTIONS_DATA, quiet=None)
            # Reviews
            gdown.download(YA_REVIEWS_URL, output=REVIEWS_DATA, quiet=None) 
開發者ID:snorkel-team,項目名稱:snorkel-tutorials,代碼行數:15,代碼來源:utils.py

示例4: _download_file

# 需要導入模塊: import gdown [as 別名]
# 或者: from gdown import download [as 別名]
def _download_file(file_id, path):
    link = 'https://drive.google.com/uc?id=' + file_id
    gdown.download(link, path, quiet=True) 
開發者ID:visionml,項目名稱:pytracking,代碼行數:5,代碼來源:download_results.py

示例5: download_data_gdown

# 需要導入模塊: import gdown [as 別名]
# 或者: from gdown import download [as 別名]
def download_data_gdown(path):
    import gdown
    
    file_id = "1efHsY16pxK0lBD2gYCgCTnv1Swstq771"
    url = f"https://drive.google.com/uc?id={file_id}"
    data_zip = os.path.join(path, "data.zip")
    gdown.download(url, data_zip, quiet=False)
    
    with zipfile.ZipFile(data_zip, "r") as zip_ref:
        zip_ref.extractall(path)
    return 
開發者ID:ckiplab,項目名稱:ckiptagger,代碼行數:13,代碼來源:data_utils.py

示例6: download_results

# 需要導入模塊: import gdown [as 別名]
# 或者: from gdown import download [as 別名]
def download_results(download_path, trackers='pytracking'):
    """
    Script to automatically download tracker results for PyTracking.

    args:
        download_path - Directory where the zipped results are downloaded
        trackers - Tracker results which are to be downloaded.
                   If set to 'pytracking', results for all pytracking based trackers will be downloaded.
                   If set to 'external', results for available external trackers will be downloaded.
                   If set to 'all', all available results are downloaded.
                   If set to a name of a tracker (e.g. atom), all results for that tracker are downloaded.
                   Otherwise, it can be set to a dict, where the keys are the names of the trackers for which results are
                   downloaded. The value can be set to either 'all', in which case all available results for the
                    tracker are downloaded. Else the value should be a list of parameter file names.
    """
    print('Using download path ''{}'''.format(download_path))

    os.makedirs(download_path, exist_ok=True)

    if isinstance(trackers, str):
        if trackers == 'all':
            all_trackers = list(pytracking_results_link_dict.keys()) + list(external_results_link_dict.keys())
            trackers = {k: 'all' for k in all_trackers}
        elif trackers == 'pytracking':
            trackers = {k: 'all' for k in pytracking_results_link_dict.keys()}
        elif trackers == 'external':
            trackers = {k: 'all' for k in external_results_link_dict.keys()}
        elif trackers in pytracking_results_link_dict or trackers in external_results_link_dict:
            trackers = {trackers: 'all'}
        else:
            raise Exception('tracker_list must be set to ''all'', a tracker name, or be a dict')
    elif isinstance(trackers, dict):
        pass
    else:
        raise Exception('tracker_list must be set to ''all'', or be a dict')

    common_link_dict = pytracking_results_link_dict
    for k, v in external_results_link_dict.items():
        common_link_dict[k] = v

    for trk, runfiles in trackers.items():
        trk_path = os.path.join(download_path, trk)
        if not os.path.exists(trk_path):
            os.makedirs(trk_path)

        if runfiles == 'all':
            for params, fileid in common_link_dict[trk].items():
                print('Downloading: {}/{}'.format(trk, params))
                _download_file(fileid, os.path.join(trk_path, params))
        elif isinstance(runfiles, (list, tuple)):
            for p in runfiles:
                for params, fileid in common_link_dict[trk].items():
                    if re.match(r'{}(|_(\d\d\d)).zip'.format(p), params) is not None:
                        print('Downloading: {}/{}'.format(trk, params))
                        _download_file(fileid, os.path.join(trk_path, params))

        else:
            raise Exception('tracker_list values must either be set to ''all'', or be a list of param names') 
開發者ID:visionml,項目名稱:pytracking,代碼行數:60,代碼來源:download_results.py


注:本文中的gdown.download方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。