Skip to content
项目
群组
代码片段
帮助
当前项目
正在载入...
登录 / 注册
切换导航面板
Y
yolov5
项目
项目
详情
活动
周期分析
仓库
仓库
文件
提交
分支
标签
贡献者
图表
比较
统计图
议题
0
议题
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
CI / CD
CI / CD
流水线
作业
日程
统计图
Wiki
Wiki
代码片段
代码片段
成员
成员
折叠边栏
关闭边栏
活动
图像
聊天
创建新问题
作业
提交
问题看板
Open sidebar
Administrator
yolov5
Commits
04bdbe41
提交
04bdbe41
authored
7月 06, 2020
作者:
Glenn Jocher
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
fuse update
上级
5ba1de0c
隐藏空白字符变更
内嵌
并排
正在显示
3 个修改的文件
包含
6 行增加
和
9 行删除
+6
-9
detect.py
detect.py
+3
-6
yolo.py
models/yolo.py
+2
-2
test.py
test.py
+1
-1
没有找到文件。
detect.py
浏览文件 @
04bdbe41
...
@@ -21,13 +21,10 @@ def detect(save_img=False):
...
@@ -21,13 +21,10 @@ def detect(save_img=False):
# Load model
# Load model
google_utils
.
attempt_download
(
weights
)
google_utils
.
attempt_download
(
weights
)
model
=
torch
.
load
(
weights
,
map_location
=
device
)[
'model'
]
.
float
()
# load to FP32
model
=
torch
.
load
(
weights
,
map_location
=
device
)[
'model'
]
.
float
()
.
eval
()
# load FP32 model
# torch.save(torch.load(weights, map_location=device), weights) # update model if SourceChangeWarning
imgsz
=
check_img_size
(
imgsz
,
s
=
model
.
stride
.
max
())
# check img_size
# model.fuse()
model
.
to
(
device
)
.
eval
()
imgsz
=
check_img_size
(
imgsz
,
s
=
model
.
model
[
-
1
]
.
stride
.
max
())
# check img_size
if
half
:
if
half
:
model
.
half
()
# to FP16
model
.
float
()
# to FP16
# Second-stage classifier
# Second-stage classifier
classify
=
False
classify
=
False
...
...
models/yolo.py
浏览文件 @
04bdbe41
...
@@ -142,14 +142,14 @@ class Model(nn.Module):
...
@@ -142,14 +142,14 @@ class Model(nn.Module):
# print('%10.3g' % (m.w.detach().sigmoid() * 2)) # shortcut weights
# print('%10.3g' % (m.w.detach().sigmoid() * 2)) # shortcut weights
def
fuse
(
self
):
# fuse model Conv2d() + BatchNorm2d() layers
def
fuse
(
self
):
# fuse model Conv2d() + BatchNorm2d() layers
print
(
'Fusing layers...'
)
print
(
'Fusing layers...
'
,
end
=
'
'
)
for
m
in
self
.
model
.
modules
():
for
m
in
self
.
model
.
modules
():
if
type
(
m
)
is
Conv
:
if
type
(
m
)
is
Conv
:
m
.
conv
=
torch_utils
.
fuse_conv_and_bn
(
m
.
conv
,
m
.
bn
)
# update conv
m
.
conv
=
torch_utils
.
fuse_conv_and_bn
(
m
.
conv
,
m
.
bn
)
# update conv
m
.
bn
=
None
# remove batchnorm
m
.
bn
=
None
# remove batchnorm
m
.
forward
=
m
.
fuseforward
# update forward
m
.
forward
=
m
.
fuseforward
# update forward
torch_utils
.
model_info
(
self
)
torch_utils
.
model_info
(
self
)
return
self
def
parse_model
(
md
,
ch
):
# model_dict, input_channels(3)
def
parse_model
(
md
,
ch
):
# model_dict, input_channels(3)
print
(
'
\n
%3
s
%18
s
%3
s
%10
s
%-40
s
%-30
s'
%
(
''
,
'from'
,
'n'
,
'params'
,
'module'
,
'arguments'
))
print
(
'
\n
%3
s
%18
s
%3
s
%10
s
%-40
s
%-30
s'
%
(
''
,
'from'
,
'n'
,
'params'
,
'module'
,
'arguments'
))
...
...
test.py
浏览文件 @
04bdbe41
...
@@ -22,6 +22,7 @@ def test(data,
...
@@ -22,6 +22,7 @@ def test(data,
# Initialize/load model and set device
# Initialize/load model and set device
if
model
is
None
:
if
model
is
None
:
training
=
False
training
=
False
merge
=
opt
.
merge
# use Merge NMS
device
=
torch_utils
.
select_device
(
opt
.
device
,
batch_size
=
batch_size
)
device
=
torch_utils
.
select_device
(
opt
.
device
,
batch_size
=
batch_size
)
# Remove previous
# Remove previous
...
@@ -59,7 +60,6 @@ def test(data,
...
@@ -59,7 +60,6 @@ def test(data,
# Dataloader
# Dataloader
if
dataloader
is
None
:
# not training
if
dataloader
is
None
:
# not training
merge
=
opt
.
merge
# use Merge NMS
img
=
torch
.
zeros
((
1
,
3
,
imgsz
,
imgsz
),
device
=
device
)
# init img
img
=
torch
.
zeros
((
1
,
3
,
imgsz
,
imgsz
),
device
=
device
)
# init img
_
=
model
(
img
.
half
()
if
half
else
img
)
if
device
.
type
!=
'cpu'
else
None
# run once
_
=
model
(
img
.
half
()
if
half
else
img
)
if
device
.
type
!=
'cpu'
else
None
# run once
path
=
data
[
'test'
]
if
opt
.
task
==
'test'
else
data
[
'val'
]
# path to val/test images
path
=
data
[
'test'
]
if
opt
.
task
==
'test'
else
data
[
'val'
]
# path to val/test images
...
...
编写
预览
Markdown
格式
0%
重试
或
添加新文件
添加附件
取消
您添加了
0
人
到此讨论。请谨慎行事。
请先完成此评论的编辑!
取消
请
注册
或者
登录
后发表评论