Skip to content
项目
群组
代码片段
帮助
当前项目
正在载入...
登录 / 注册
切换导航面板
Y
yolov5
项目
项目
详情
活动
周期分析
仓库
仓库
文件
提交
分支
标签
贡献者
图表
比较
统计图
议题
0
议题
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
CI / CD
CI / CD
流水线
作业
日程
统计图
Wiki
Wiki
代码片段
代码片段
成员
成员
折叠边栏
关闭边栏
活动
图像
聊天
创建新问题
作业
提交
问题看板
Open sidebar
Administrator
yolov5
Commits
43a616a9
提交
43a616a9
authored
7月 28, 2020
作者:
Glenn Jocher
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
PyTorch 1.6.0 compatability updates
上级
7f8471ea
显示空白字符变更
内嵌
并排
正在显示
3 个修改的文件
包含
7 行增加
和
6 行删除
+7
-6
detect.py
detect.py
+1
-1
yolo.py
models/yolo.py
+3
-2
test.py
test.py
+3
-3
没有找到文件。
detect.py
浏览文件 @
43a616a9
...
...
@@ -154,7 +154,7 @@ if __name__ == '__main__':
with
torch
.
no_grad
():
if
opt
.
update
:
# update all models (to fix SourceChangeWarning)
for
opt
.
weights
in
[
'yolov5s.pt'
,
'yolov5m.pt'
,
'yolov5l.pt'
,
'yolov5x.pt'
,
'yolov3-spp.pt'
]:
for
opt
.
weights
in
[
'yolov5s.pt'
,
'yolov5m.pt'
,
'yolov5l.pt'
,
'yolov5x.pt'
]:
detect
()
strip_optimizer
(
opt
.
weights
)
else
:
...
...
models/yolo.py
浏览文件 @
43a616a9
...
...
@@ -90,9 +90,9 @@ class Model(nn.Module):
yi
=
self
.
forward_once
(
xi
)[
0
]
# forward
# cv2.imwrite('img%g.jpg' % s, 255 * xi[0].numpy().transpose((1, 2, 0))[:, :, ::-1]) # save
yi
[
...
,
:
4
]
/=
si
# de-scale
if
fi
is
2
:
if
fi
==
2
:
yi
[
...
,
1
]
=
img_size
[
0
]
-
yi
[
...
,
1
]
# de-flip ud
elif
fi
is
3
:
elif
fi
==
3
:
yi
[
...
,
0
]
=
img_size
[
1
]
-
yi
[
...
,
0
]
# de-flip lr
y
.
append
(
yi
)
return
torch
.
cat
(
y
,
1
),
None
# augmented inference, train
...
...
@@ -148,6 +148,7 @@ class Model(nn.Module):
print
(
'Fusing layers... '
,
end
=
''
)
for
m
in
self
.
model
.
modules
():
if
type
(
m
)
is
Conv
:
m
.
_non_persistent_buffers_set
=
set
()
# pytorch 1.6.0 compatability
m
.
conv
=
torch_utils
.
fuse_conv_and_bn
(
m
.
conv
,
m
.
bn
)
# update conv
m
.
bn
=
None
# remove batchnorm
m
.
forward
=
m
.
fuseforward
# update forward
...
...
test.py
浏览文件 @
43a616a9
...
...
@@ -148,8 +148,8 @@ def test(data,
# Per target class
for
cls
in
torch
.
unique
(
tcls_tensor
):
ti
=
(
cls
==
tcls_tensor
)
.
nonzero
()
.
view
(
-
1
)
# prediction indices
pi
=
(
cls
==
pred
[:,
5
])
.
nonzero
()
.
view
(
-
1
)
# target indices
ti
=
(
cls
==
tcls_tensor
)
.
nonzero
(
as_tuple
=
False
)
.
view
(
-
1
)
# prediction indices
pi
=
(
cls
==
pred
[:,
5
])
.
nonzero
(
as_tuple
=
False
)
.
view
(
-
1
)
# target indices
# Search for detections
if
pi
.
shape
[
0
]:
...
...
@@ -157,7 +157,7 @@ def test(data,
ious
,
i
=
box_iou
(
pred
[
pi
,
:
4
],
tbox
[
ti
])
.
max
(
1
)
# best ious, indices
# Append detections
for
j
in
(
ious
>
iouv
[
0
])
.
nonzero
():
for
j
in
(
ious
>
iouv
[
0
])
.
nonzero
(
as_tuple
=
False
):
d
=
ti
[
i
[
j
]]
# detected target
if
d
not
in
detected
:
detected
.
append
(
d
)
...
...
编写
预览
Markdown
格式
0%
重试
或
添加新文件
添加附件
取消
您添加了
0
人
到此讨论。请谨慎行事。
请先完成此评论的编辑!
取消
请
注册
或者
登录
后发表评论