Skip to content
项目
群组
代码片段
帮助
当前项目
正在载入...
登录 / 注册
切换导航面板
Y
yolov5
项目
项目
详情
活动
周期分析
仓库
仓库
文件
提交
分支
标签
贡献者
图表
比较
统计图
议题
0
议题
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
CI / CD
CI / CD
流水线
作业
日程
统计图
Wiki
Wiki
代码片段
代码片段
成员
成员
折叠边栏
关闭边栏
活动
图像
聊天
创建新问题
作业
提交
问题看板
Open sidebar
Administrator
yolov5
Commits
f8464b4f
Unverified
提交
f8464b4f
authored
2月 16, 2021
作者:
Glenn Jocher
提交者:
GitHub
2月 16, 2021
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Update yolo.py channel array (#2223)
上级
7b833e37
隐藏空白字符变更
内嵌
并排
正在显示
1 个修改的文件
包含
10 行增加
和
25 行删除
+10
-25
yolo.py
models/yolo.py
+10
-25
没有找到文件。
models/yolo.py
浏览文件 @
f8464b4f
...
...
@@ -2,7 +2,6 @@ import argparse
import
logging
import
sys
from
copy
import
deepcopy
from
pathlib
import
Path
sys
.
path
.
append
(
'./'
)
# to run '$ python *.py' files in subdirectories
logger
=
logging
.
getLogger
(
__name__
)
...
...
@@ -213,43 +212,27 @@ def parse_model(d, ch): # model_dict, input_channels(3)
if
m
in
[
Conv
,
GhostConv
,
Bottleneck
,
GhostBottleneck
,
SPP
,
DWConv
,
MixConv2d
,
Focus
,
CrossConv
,
BottleneckCSP
,
C3
]:
c1
,
c2
=
ch
[
f
],
args
[
0
]
# Normal
# if i > 0 and args[0] != no: # channel expansion factor
# ex = 1.75 # exponential (default 2.0)
# e = math.log(c2 / ch[1]) / math.log(2)
# c2 = int(ch[1] * ex ** e)
# if m != Focus:
c2
=
make_divisible
(
c2
*
gw
,
8
)
if
c2
!=
no
else
c2
# Experimental
# if i > 0 and args[0] != no: # channel expansion factor
# ex = 1 + gw # exponential (default 2.0)
# ch1 = 32 # ch[1]
# e = math.log(c2 / ch1) / math.log(2) # level 1-n
# c2 = int(ch1 * ex ** e)
# if m != Focus:
# c2 = make_divisible(c2, 8) if c2 != no else c2
if
c2
!=
no
:
# if not output
c2
=
make_divisible
(
c2
*
gw
,
8
)
args
=
[
c1
,
c2
,
*
args
[
1
:]]
if
m
in
[
BottleneckCSP
,
C3
]:
args
.
insert
(
2
,
n
)
args
.
insert
(
2
,
n
)
# number of repeats
n
=
1
elif
m
is
nn
.
BatchNorm2d
:
args
=
[
ch
[
f
]]
elif
m
is
Concat
:
c2
=
sum
([
ch
[
x
if
x
<
0
else
x
+
1
]
for
x
in
f
])
c2
=
sum
([
ch
[
x
]
for
x
in
f
])
elif
m
is
Detect
:
args
.
append
([
ch
[
x
+
1
]
for
x
in
f
])
args
.
append
([
ch
[
x
]
for
x
in
f
])
if
isinstance
(
args
[
1
],
int
):
# number of anchors
args
[
1
]
=
[
list
(
range
(
args
[
1
]
*
2
))]
*
len
(
f
)
elif
m
is
Contract
:
c2
=
ch
[
f
if
f
<
0
else
f
+
1
]
*
args
[
0
]
**
2
c2
=
ch
[
f
]
*
args
[
0
]
**
2
elif
m
is
Expand
:
c2
=
ch
[
f
if
f
<
0
else
f
+
1
]
//
args
[
0
]
**
2
c2
=
ch
[
f
]
//
args
[
0
]
**
2
else
:
c2
=
ch
[
f
if
f
<
0
else
f
+
1
]
c2
=
ch
[
f
]
m_
=
nn
.
Sequential
(
*
[
m
(
*
args
)
for
_
in
range
(
n
)])
if
n
>
1
else
m
(
*
args
)
# module
t
=
str
(
m
)[
8
:
-
2
]
.
replace
(
'__main__.'
,
''
)
# module type
...
...
@@ -258,6 +241,8 @@ def parse_model(d, ch): # model_dict, input_channels(3)
logger
.
info
(
'
%3
s
%18
s
%3
s
%10.0
f
%-40
s
%-30
s'
%
(
i
,
f
,
n
,
np
,
t
,
args
))
# print
save
.
extend
(
x
%
i
for
x
in
([
f
]
if
isinstance
(
f
,
int
)
else
f
)
if
x
!=
-
1
)
# append to savelist
layers
.
append
(
m_
)
if
i
==
0
:
ch
=
[]
ch
.
append
(
c2
)
return
nn
.
Sequential
(
*
layers
),
sorted
(
save
)
...
...
编写
预览
Markdown
格式
0%
重试
或
添加新文件
添加附件
取消
您添加了
0
人
到此讨论。请谨慎行事。
请先完成此评论的编辑!
取消
请
注册
或者
登录
后发表评论