Skip to content
项目
群组
代码片段
帮助
当前项目
正在载入...
登录 / 注册
切换导航面板
Y
yolov5
项目
项目
详情
活动
周期分析
仓库
仓库
文件
提交
分支
标签
贡献者
图表
比较
统计图
议题
0
议题
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
CI / CD
CI / CD
流水线
作业
日程
统计图
Wiki
Wiki
代码片段
代码片段
成员
成员
折叠边栏
关闭边栏
活动
图像
聊天
创建新问题
作业
提交
问题看板
Open sidebar
Administrator
yolov5
Commits
d8f5fcfe
Unverified
提交
d8f5fcfe
authored
11月 14, 2020
作者:
Glenn Jocher
提交者:
GitHub
11月 14, 2020
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Improved FLOPS computation (#1398)
* Improved FLOPS computation * update comment
上级
0c26c4e8
隐藏空白字符变更
内嵌
并排
正在显示
2 个修改的文件
包含
8 行增加
和
6 行删除
+8
-6
yolo.py
models/yolo.py
+2
-2
torch_utils.py
utils/torch_utils.py
+6
-4
没有找到文件。
models/yolo.py
浏览文件 @
d8f5fcfe
...
@@ -192,8 +192,8 @@ class Model(nn.Module):
...
@@ -192,8 +192,8 @@ class Model(nn.Module):
copy_attr
(
m
,
self
,
include
=
(
'yaml'
,
'nc'
,
'hyp'
,
'names'
,
'stride'
),
exclude
=
())
# copy attributes
copy_attr
(
m
,
self
,
include
=
(
'yaml'
,
'nc'
,
'hyp'
,
'names'
,
'stride'
),
exclude
=
())
# copy attributes
return
m
return
m
def
info
(
self
,
verbose
=
False
):
# print model information
def
info
(
self
,
verbose
=
False
,
img_size
=
640
):
# print model information
model_info
(
self
,
verbose
)
model_info
(
self
,
verbose
,
img_size
)
def
parse_model
(
d
,
ch
):
# model_dict, input_channels(3)
def
parse_model
(
d
,
ch
):
# model_dict, input_channels(3)
...
...
utils/torch_utils.py
浏览文件 @
d8f5fcfe
...
@@ -139,8 +139,8 @@ def fuse_conv_and_bn(conv, bn):
...
@@ -139,8 +139,8 @@ def fuse_conv_and_bn(conv, bn):
return
fusedconv
return
fusedconv
def
model_info
(
model
,
verbose
=
False
):
def
model_info
(
model
,
verbose
=
False
,
img_size
=
640
):
#
Plots a line-by-line description of a PyTorch model
#
Model information. img_size may be int or list, i.e. img_size=640 or img_size=[640, 320]
n_p
=
sum
(
x
.
numel
()
for
x
in
model
.
parameters
())
# number parameters
n_p
=
sum
(
x
.
numel
()
for
x
in
model
.
parameters
())
# number parameters
n_g
=
sum
(
x
.
numel
()
for
x
in
model
.
parameters
()
if
x
.
requires_grad
)
# number gradients
n_g
=
sum
(
x
.
numel
()
for
x
in
model
.
parameters
()
if
x
.
requires_grad
)
# number gradients
if
verbose
:
if
verbose
:
...
@@ -152,8 +152,10 @@ def model_info(model, verbose=False):
...
@@ -152,8 +152,10 @@ def model_info(model, verbose=False):
try
:
# FLOPS
try
:
# FLOPS
from
thop
import
profile
from
thop
import
profile
flops
=
profile
(
deepcopy
(
model
),
inputs
=
(
torch
.
zeros
(
1
,
3
,
64
,
64
),),
verbose
=
False
)[
0
]
/
1E9
*
2
stride
=
int
(
model
.
stride
.
max
())
fs
=
',
%.1
f GFLOPS'
%
(
flops
*
100
)
# 640x640 FLOPS
flops
=
profile
(
deepcopy
(
model
),
inputs
=
(
torch
.
zeros
(
1
,
3
,
stride
,
stride
),),
verbose
=
False
)[
0
]
/
1E9
*
2
img_size
=
img_size
if
isinstance
(
img_size
,
list
)
else
[
img_size
,
img_size
]
# expand if int/float
fs
=
',
%.1
f GFLOPS'
%
(
flops
*
img_size
[
0
]
/
stride
*
img_size
[
1
]
/
stride
)
# 640x640 FLOPS
except
ImportError
:
except
ImportError
:
fs
=
''
fs
=
''
...
...
编写
预览
Markdown
格式
0%
重试
或
添加新文件
添加附件
取消
您添加了
0
人
到此讨论。请谨慎行事。
请先完成此评论的编辑!
取消
请
注册
或者
登录
后发表评论