From 7aa11973396a6efb211467f14cac82e5811abf4d Mon Sep 17 00:00:00 2001 From: Kaipeng Deng Date: Sat, 2 Nov 2019 12:13:54 +0800 Subject: [PATCH] fix download.py windows compatible (#15) --- ppdet/utils/download.py | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/ppdet/utils/download.py b/ppdet/utils/download.py index d5f8cc146..f561e3edd 100644 --- a/ppdet/utils/download.py +++ b/ppdet/utils/download.py @@ -154,7 +154,7 @@ def create_voc_list(data_dir, devkit_subdir='VOCdevkit'): def map_path(url, root_dir): # parse path after download to decompress under root_dir - fname = url.split('/')[-1] + fname = osp.split(url)[-1] zip_formats = ['.zip', '.tar', '.gz'] fpath = fname for zip_format in zip_formats: @@ -186,7 +186,7 @@ def get_path(url, root_dir, md5sum=None, check_exist=True): } for k, v in decompress_name_map.items(): if fullpath.find(k) >= 0: - fullpath = '/'.join(fullpath.split('/')[:-1] + [v]) + fullpath = osp.join(osp.split(fullpath)[0], v) exist_flag = False if osp.exists(fullpath) and check_exist: @@ -247,7 +247,7 @@ def _download(url, path, md5sum=None): if not osp.exists(path): os.makedirs(path) - fname = url.split('/')[-1] + fname = osp.split(url)[-1] fullname = osp.join(path, fname) retry_cnt = 0 @@ -314,7 +314,7 @@ def _decompress(fname): # decompress to fpath_tmp directory firstly, if decompress # successed, move decompress files to fpath and delete # fpath_tmp and remove download compress file. - fpath = '/'.join(fname.split('/')[:-1]) + fpath = osp.split(fname)[0] fpath_tmp = osp.join(fpath, 'tmp') if osp.isdir(fpath_tmp): shutil.rmtree(fpath_tmp) -- GitLab