Skip to content
项目
群组
代码片段
帮助
当前项目
正在载入...
登录 / 注册
切换导航面板
Y
yolov5
项目
项目
详情
活动
周期分析
仓库
仓库
文件
提交
分支
标签
贡献者
图表
比较
统计图
议题
0
议题
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
CI / CD
CI / CD
流水线
作业
日程
统计图
Wiki
Wiki
代码片段
代码片段
成员
成员
折叠边栏
关闭边栏
活动
图像
聊天
创建新问题
作业
提交
问题看板
Open sidebar
Administrator
yolov5
Commits
32661f75
Unverified
提交
32661f75
authored
4月 06, 2022
作者:
Glenn Jocher
提交者:
GitHub
4月 06, 2022
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Add `retry=3` to `download()` (#7313)
* Add `retry=3` to `download()` * Update general.py * Update general.py * Update general.py * Update VOC.yaml * Update VisDrone.yaml
上级
f7354589
隐藏空白字符变更
内嵌
并排
正在显示
3 个修改的文件
包含
20 行增加
和
8 行删除
+20
-8
VOC.yaml
data/VOC.yaml
+1
-1
VisDrone.yaml
data/VisDrone.yaml
+1
-1
general.py
utils/general.py
+18
-6
没有找到文件。
data/VOC.yaml
浏览文件 @
32661f75
...
@@ -62,7 +62,7 @@ download: |
...
@@ -62,7 +62,7 @@ download: |
urls = [url + 'VOCtrainval_06-Nov-2007.zip', # 446MB, 5012 images
urls = [url + 'VOCtrainval_06-Nov-2007.zip', # 446MB, 5012 images
url + 'VOCtest_06-Nov-2007.zip', # 438MB, 4953 images
url + 'VOCtest_06-Nov-2007.zip', # 438MB, 4953 images
url + 'VOCtrainval_11-May-2012.zip'] # 1.95GB, 17126 images
url + 'VOCtrainval_11-May-2012.zip'] # 1.95GB, 17126 images
download(urls, dir=dir / 'images', delete=False, threads=3)
download(urls, dir=dir / 'images', delete=False,
curl=True,
threads=3)
# Convert
# Convert
path = dir / f'images/VOCdevkit'
path = dir / f'images/VOCdevkit'
...
...
data/VisDrone.yaml
浏览文件 @
32661f75
...
@@ -54,7 +54,7 @@ download: |
...
@@ -54,7 +54,7 @@ download: |
'https://github.com/ultralytics/yolov5/releases/download/v1.0/VisDrone2019-DET-val.zip',
'https://github.com/ultralytics/yolov5/releases/download/v1.0/VisDrone2019-DET-val.zip',
'https://github.com/ultralytics/yolov5/releases/download/v1.0/VisDrone2019-DET-test-dev.zip',
'https://github.com/ultralytics/yolov5/releases/download/v1.0/VisDrone2019-DET-test-dev.zip',
'https://github.com/ultralytics/yolov5/releases/download/v1.0/VisDrone2019-DET-test-challenge.zip']
'https://github.com/ultralytics/yolov5/releases/download/v1.0/VisDrone2019-DET-test-challenge.zip']
download(urls, dir=dir, threads=4)
download(urls, dir=dir,
curl=True,
threads=4)
# Convert
# Convert
for d in 'VisDrone2019-DET-train', 'VisDrone2019-DET-val', 'VisDrone2019-DET-test-dev':
for d in 'VisDrone2019-DET-train', 'VisDrone2019-DET-val', 'VisDrone2019-DET-test-dev':
...
...
utils/general.py
浏览文件 @
32661f75
...
@@ -497,20 +497,32 @@ def url2file(url):
...
@@ -497,20 +497,32 @@ def url2file(url):
return
file
return
file
def
download
(
url
,
dir
=
'.'
,
unzip
=
True
,
delete
=
True
,
curl
=
False
,
threads
=
1
):
def
download
(
url
,
dir
=
'.'
,
unzip
=
True
,
delete
=
True
,
curl
=
False
,
threads
=
1
,
retry
=
3
):
# Multi-threaded file download and unzip function, used in data.yaml for autodownload
# Multi-threaded file download and unzip function, used in data.yaml for autodownload
def
download_one
(
url
,
dir
):
def
download_one
(
url
,
dir
):
# Download 1 file
# Download 1 file
success
=
True
f
=
dir
/
Path
(
url
)
.
name
# filename
f
=
dir
/
Path
(
url
)
.
name
# filename
if
Path
(
url
)
.
is_file
():
# exists in current path
if
Path
(
url
)
.
is_file
():
# exists in current path
Path
(
url
)
.
rename
(
f
)
# move to dir
Path
(
url
)
.
rename
(
f
)
# move to dir
elif
not
f
.
exists
():
elif
not
f
.
exists
():
LOGGER
.
info
(
f
'Downloading {url} to {f}...'
)
LOGGER
.
info
(
f
'Downloading {url} to {f}...'
)
if
curl
:
for
i
in
range
(
retry
+
1
):
os
.
system
(
f
"curl -L '{url}' -o '{f}' --retry 9 -C -"
)
# curl download, retry and resume on fail
if
curl
:
else
:
s
=
'sS'
if
threads
>
1
else
''
# silent
torch
.
hub
.
download_url_to_file
(
url
,
f
,
progress
=
threads
==
1
)
# torch download
r
=
os
.
system
(
f
"curl -{s}L '{url}' -o '{f}' --retry 9 -C -"
)
# curl download
if
unzip
and
f
.
suffix
in
(
'.zip'
,
'.gz'
):
success
=
r
==
0
else
:
torch
.
hub
.
download_url_to_file
(
url
,
f
,
progress
=
threads
==
1
)
# torch download
success
=
f
.
is_file
()
if
success
:
break
elif
i
<
retry
:
LOGGER
.
warning
(
f
'Download failure, retrying {i + 1}/{retry} {url}...'
)
else
:
LOGGER
.
warning
(
f
'Failed to download {url}...'
)
if
unzip
and
success
and
f
.
suffix
in
(
'.zip'
,
'.gz'
):
LOGGER
.
info
(
f
'Unzipping {f}...'
)
LOGGER
.
info
(
f
'Unzipping {f}...'
)
if
f
.
suffix
==
'.zip'
:
if
f
.
suffix
==
'.zip'
:
ZipFile
(
f
)
.
extractall
(
path
=
dir
)
# unzip
ZipFile
(
f
)
.
extractall
(
path
=
dir
)
# unzip
...
...
编写
预览
Markdown
格式
0%
重试
或
添加新文件
添加附件
取消
您添加了
0
人
到此讨论。请谨慎行事。
请先完成此评论的编辑!
取消
请
注册
或者
登录
后发表评论