Skip to content
项目
群组
代码片段
帮助
当前项目
正在载入...
登录 / 注册
切换导航面板
Y
yolov5
项目
项目
详情
活动
周期分析
仓库
仓库
文件
提交
分支
标签
贡献者
图表
比较
统计图
议题
0
议题
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
CI / CD
CI / CD
流水线
作业
日程
统计图
Wiki
Wiki
代码片段
代码片段
成员
成员
折叠边栏
关闭边栏
活动
图像
聊天
创建新问题
作业
提交
问题看板
Open sidebar
Administrator
yolov5
Commits
da9a1b71
Unverified
提交
da9a1b71
authored
12月 15, 2021
作者:
Glenn Jocher
提交者:
GitHub
12月 15, 2021
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Allow `--weights URL` (#5991)
上级
b7d18f36
显示空白字符变更
内嵌
并排
正在显示
2 个修改的文件
包含
8 行增加
和
5 行删除
+8
-5
common.py
models/common.py
+2
-2
downloads.py
utils/downloads.py
+6
-3
没有找到文件。
models/common.py
浏览文件 @
da9a1b71
...
@@ -296,7 +296,7 @@ class DetectMultiBackend(nn.Module):
...
@@ -296,7 +296,7 @@ class DetectMultiBackend(nn.Module):
check_suffix
(
w
,
suffixes
)
# check weights have acceptable suffix
check_suffix
(
w
,
suffixes
)
# check weights have acceptable suffix
pt
,
jit
,
onnx
,
engine
,
tflite
,
pb
,
saved_model
,
coreml
=
(
suffix
==
x
for
x
in
suffixes
)
# backend booleans
pt
,
jit
,
onnx
,
engine
,
tflite
,
pb
,
saved_model
,
coreml
=
(
suffix
==
x
for
x
in
suffixes
)
# backend booleans
stride
,
names
=
64
,
[
f
'class{i}'
for
i
in
range
(
1000
)]
# assign defaults
stride
,
names
=
64
,
[
f
'class{i}'
for
i
in
range
(
1000
)]
# assign defaults
attempt_download
(
w
)
# download if not local
w
=
attempt_download
(
w
)
# download if not local
if
jit
:
# TorchScript
if
jit
:
# TorchScript
LOGGER
.
info
(
f
'Loading {w} for TorchScript inference...'
)
LOGGER
.
info
(
f
'Loading {w} for TorchScript inference...'
)
...
@@ -306,7 +306,7 @@ class DetectMultiBackend(nn.Module):
...
@@ -306,7 +306,7 @@ class DetectMultiBackend(nn.Module):
d
=
json
.
loads
(
extra_files
[
'config.txt'
])
# extra_files dict
d
=
json
.
loads
(
extra_files
[
'config.txt'
])
# extra_files dict
stride
,
names
=
int
(
d
[
'stride'
]),
d
[
'names'
]
stride
,
names
=
int
(
d
[
'stride'
]),
d
[
'names'
]
elif
pt
:
# PyTorch
elif
pt
:
# PyTorch
model
=
attempt_load
(
weights
,
map_location
=
device
)
model
=
attempt_load
(
weights
if
isinstance
(
weights
,
list
)
else
w
,
map_location
=
device
)
stride
=
int
(
model
.
stride
.
max
())
# model stride
stride
=
int
(
model
.
stride
.
max
())
# model stride
names
=
model
.
module
.
names
if
hasattr
(
model
,
'module'
)
else
model
.
names
# get class names
names
=
model
.
module
.
names
if
hasattr
(
model
,
'module'
)
else
model
.
names
# get class names
self
.
model
=
model
# explicitly assign for to(), cpu(), cuda(), half()
self
.
model
=
model
# explicitly assign for to(), cpu(), cuda(), half()
...
...
utils/downloads.py
浏览文件 @
da9a1b71
...
@@ -49,9 +49,12 @@ def attempt_download(file, repo='ultralytics/yolov5'): # from utils.downloads i
...
@@ -49,9 +49,12 @@ def attempt_download(file, repo='ultralytics/yolov5'): # from utils.downloads i
name
=
Path
(
urllib
.
parse
.
unquote
(
str
(
file
)))
.
name
# decode '%2F' to '/' etc.
name
=
Path
(
urllib
.
parse
.
unquote
(
str
(
file
)))
.
name
# decode '%2F' to '/' etc.
if
str
(
file
)
.
startswith
((
'http:/'
,
'https:/'
)):
# download
if
str
(
file
)
.
startswith
((
'http:/'
,
'https:/'
)):
# download
url
=
str
(
file
)
.
replace
(
':/'
,
'://'
)
# Pathlib turns :// -> :/
url
=
str
(
file
)
.
replace
(
':/'
,
'://'
)
# Pathlib turns :// -> :/
name
=
name
.
split
(
'?'
)[
0
]
# parse authentication https://url.com/file.txt?auth...
file
=
name
.
split
(
'?'
)[
0
]
# parse authentication https://url.com/file.txt?auth...
safe_download
(
file
=
name
,
url
=
url
,
min_bytes
=
1E5
)
if
Path
(
file
)
.
is_file
():
return
name
print
(
f
'Found {url} locally at {file}'
)
# file already exists
else
:
safe_download
(
file
=
file
,
url
=
url
,
min_bytes
=
1E5
)
return
file
# GitHub assets
# GitHub assets
file
.
parent
.
mkdir
(
parents
=
True
,
exist_ok
=
True
)
# make parent dir (if required)
file
.
parent
.
mkdir
(
parents
=
True
,
exist_ok
=
True
)
# make parent dir (if required)
...
...
编写
预览
Markdown
格式
0%
重试
或
添加新文件
添加附件
取消
您添加了
0
人
到此讨论。请谨慎行事。
请先完成此评论的编辑!
取消
请
注册
或者
登录
后发表评论