Skip to content
项目
群组
代码片段
帮助
当前项目
正在载入...
登录 / 注册
切换导航面板
Y
yolov5
项目
项目
详情
活动
周期分析
仓库
仓库
文件
提交
分支
标签
贡献者
图表
比较
统计图
议题
0
议题
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
CI / CD
CI / CD
流水线
作业
日程
统计图
Wiki
Wiki
代码片段
代码片段
成员
成员
折叠边栏
关闭边栏
活动
图像
聊天
创建新问题
作业
提交
问题看板
Open sidebar
Administrator
yolov5
Commits
b1be6850
Unverified
提交
b1be6850
authored
7月 19, 2021
作者:
Glenn Jocher
提交者:
GitHub
7月 19, 2021
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Module `super().__init__()` (#4065)
* Module `super().__init__()` * remove NMS
上级
f7d85620
隐藏空白字符变更
内嵌
并排
正在显示
3 个修改的文件
包含
27 行增加
和
47 行删除
+27
-47
common.py
models/common.py
+18
-24
experimental.py
models/experimental.py
+6
-6
yolo.py
models/yolo.py
+3
-17
没有找到文件。
models/common.py
浏览文件 @
b1be6850
...
@@ -36,7 +36,7 @@ def DWConv(c1, c2, k=1, s=1, act=True):
...
@@ -36,7 +36,7 @@ def DWConv(c1, c2, k=1, s=1, act=True):
class
Conv
(
nn
.
Module
):
class
Conv
(
nn
.
Module
):
# Standard convolution
# Standard convolution
def
__init__
(
self
,
c1
,
c2
,
k
=
1
,
s
=
1
,
p
=
None
,
g
=
1
,
act
=
True
):
# ch_in, ch_out, kernel, stride, padding, groups
def
__init__
(
self
,
c1
,
c2
,
k
=
1
,
s
=
1
,
p
=
None
,
g
=
1
,
act
=
True
):
# ch_in, ch_out, kernel, stride, padding, groups
super
(
Conv
,
self
)
.
__init__
()
super
()
.
__init__
()
self
.
conv
=
nn
.
Conv2d
(
c1
,
c2
,
k
,
s
,
autopad
(
k
,
p
),
groups
=
g
,
bias
=
False
)
self
.
conv
=
nn
.
Conv2d
(
c1
,
c2
,
k
,
s
,
autopad
(
k
,
p
),
groups
=
g
,
bias
=
False
)
self
.
bn
=
nn
.
BatchNorm2d
(
c2
)
self
.
bn
=
nn
.
BatchNorm2d
(
c2
)
self
.
act
=
nn
.
SiLU
()
if
act
is
True
else
(
act
if
isinstance
(
act
,
nn
.
Module
)
else
nn
.
Identity
())
self
.
act
=
nn
.
SiLU
()
if
act
is
True
else
(
act
if
isinstance
(
act
,
nn
.
Module
)
else
nn
.
Identity
())
...
@@ -87,7 +87,7 @@ class TransformerBlock(nn.Module):
...
@@ -87,7 +87,7 @@ class TransformerBlock(nn.Module):
class
Bottleneck
(
nn
.
Module
):
class
Bottleneck
(
nn
.
Module
):
# Standard bottleneck
# Standard bottleneck
def
__init__
(
self
,
c1
,
c2
,
shortcut
=
True
,
g
=
1
,
e
=
0.5
):
# ch_in, ch_out, shortcut, groups, expansion
def
__init__
(
self
,
c1
,
c2
,
shortcut
=
True
,
g
=
1
,
e
=
0.5
):
# ch_in, ch_out, shortcut, groups, expansion
super
(
Bottleneck
,
self
)
.
__init__
()
super
()
.
__init__
()
c_
=
int
(
c2
*
e
)
# hidden channels
c_
=
int
(
c2
*
e
)
# hidden channels
self
.
cv1
=
Conv
(
c1
,
c_
,
1
,
1
)
self
.
cv1
=
Conv
(
c1
,
c_
,
1
,
1
)
self
.
cv2
=
Conv
(
c_
,
c2
,
3
,
1
,
g
=
g
)
self
.
cv2
=
Conv
(
c_
,
c2
,
3
,
1
,
g
=
g
)
...
@@ -100,7 +100,7 @@ class Bottleneck(nn.Module):
...
@@ -100,7 +100,7 @@ class Bottleneck(nn.Module):
class
BottleneckCSP
(
nn
.
Module
):
class
BottleneckCSP
(
nn
.
Module
):
# CSP Bottleneck https://github.com/WongKinYiu/CrossStagePartialNetworks
# CSP Bottleneck https://github.com/WongKinYiu/CrossStagePartialNetworks
def
__init__
(
self
,
c1
,
c2
,
n
=
1
,
shortcut
=
True
,
g
=
1
,
e
=
0.5
):
# ch_in, ch_out, number, shortcut, groups, expansion
def
__init__
(
self
,
c1
,
c2
,
n
=
1
,
shortcut
=
True
,
g
=
1
,
e
=
0.5
):
# ch_in, ch_out, number, shortcut, groups, expansion
super
(
BottleneckCSP
,
self
)
.
__init__
()
super
()
.
__init__
()
c_
=
int
(
c2
*
e
)
# hidden channels
c_
=
int
(
c2
*
e
)
# hidden channels
self
.
cv1
=
Conv
(
c1
,
c_
,
1
,
1
)
self
.
cv1
=
Conv
(
c1
,
c_
,
1
,
1
)
self
.
cv2
=
nn
.
Conv2d
(
c1
,
c_
,
1
,
1
,
bias
=
False
)
self
.
cv2
=
nn
.
Conv2d
(
c1
,
c_
,
1
,
1
,
bias
=
False
)
...
@@ -119,7 +119,7 @@ class BottleneckCSP(nn.Module):
...
@@ -119,7 +119,7 @@ class BottleneckCSP(nn.Module):
class
C3
(
nn
.
Module
):
class
C3
(
nn
.
Module
):
# CSP Bottleneck with 3 convolutions
# CSP Bottleneck with 3 convolutions
def
__init__
(
self
,
c1
,
c2
,
n
=
1
,
shortcut
=
True
,
g
=
1
,
e
=
0.5
):
# ch_in, ch_out, number, shortcut, groups, expansion
def
__init__
(
self
,
c1
,
c2
,
n
=
1
,
shortcut
=
True
,
g
=
1
,
e
=
0.5
):
# ch_in, ch_out, number, shortcut, groups, expansion
super
(
C3
,
self
)
.
__init__
()
super
()
.
__init__
()
c_
=
int
(
c2
*
e
)
# hidden channels
c_
=
int
(
c2
*
e
)
# hidden channels
self
.
cv1
=
Conv
(
c1
,
c_
,
1
,
1
)
self
.
cv1
=
Conv
(
c1
,
c_
,
1
,
1
)
self
.
cv2
=
Conv
(
c1
,
c_
,
1
,
1
)
self
.
cv2
=
Conv
(
c1
,
c_
,
1
,
1
)
...
@@ -139,10 +139,18 @@ class C3TR(C3):
...
@@ -139,10 +139,18 @@ class C3TR(C3):
self
.
m
=
TransformerBlock
(
c_
,
c_
,
4
,
n
)
self
.
m
=
TransformerBlock
(
c_
,
c_
,
4
,
n
)
class
C3SPP
(
C3
):
# C3 module with SPP()
def
__init__
(
self
,
c1
,
c2
,
k
=
(
5
,
9
,
13
),
n
=
1
,
shortcut
=
True
,
g
=
1
,
e
=
0.5
):
super
()
.
__init__
(
c1
,
c2
,
n
,
shortcut
,
g
,
e
)
c_
=
int
(
c2
*
e
)
self
.
m
=
SPP
(
c_
,
c_
,
k
)
class
SPP
(
nn
.
Module
):
class
SPP
(
nn
.
Module
):
# Spatial pyramid pooling layer used in YOLOv3-SPP
# Spatial pyramid pooling layer used in YOLOv3-SPP
def
__init__
(
self
,
c1
,
c2
,
k
=
(
5
,
9
,
13
)):
def
__init__
(
self
,
c1
,
c2
,
k
=
(
5
,
9
,
13
)):
super
(
SPP
,
self
)
.
__init__
()
super
()
.
__init__
()
c_
=
c1
//
2
# hidden channels
c_
=
c1
//
2
# hidden channels
self
.
cv1
=
Conv
(
c1
,
c_
,
1
,
1
)
self
.
cv1
=
Conv
(
c1
,
c_
,
1
,
1
)
self
.
cv2
=
Conv
(
c_
*
(
len
(
k
)
+
1
),
c2
,
1
,
1
)
self
.
cv2
=
Conv
(
c_
*
(
len
(
k
)
+
1
),
c2
,
1
,
1
)
...
@@ -156,7 +164,7 @@ class SPP(nn.Module):
...
@@ -156,7 +164,7 @@ class SPP(nn.Module):
class
Focus
(
nn
.
Module
):
class
Focus
(
nn
.
Module
):
# Focus wh information into c-space
# Focus wh information into c-space
def
__init__
(
self
,
c1
,
c2
,
k
=
1
,
s
=
1
,
p
=
None
,
g
=
1
,
act
=
True
):
# ch_in, ch_out, kernel, stride, padding, groups
def
__init__
(
self
,
c1
,
c2
,
k
=
1
,
s
=
1
,
p
=
None
,
g
=
1
,
act
=
True
):
# ch_in, ch_out, kernel, stride, padding, groups
super
(
Focus
,
self
)
.
__init__
()
super
()
.
__init__
()
self
.
conv
=
Conv
(
c1
*
4
,
c2
,
k
,
s
,
p
,
g
,
act
)
self
.
conv
=
Conv
(
c1
*
4
,
c2
,
k
,
s
,
p
,
g
,
act
)
# self.contract = Contract(gain=2)
# self.contract = Contract(gain=2)
...
@@ -196,27 +204,13 @@ class Expand(nn.Module):
...
@@ -196,27 +204,13 @@ class Expand(nn.Module):
class
Concat
(
nn
.
Module
):
class
Concat
(
nn
.
Module
):
# Concatenate a list of tensors along dimension
# Concatenate a list of tensors along dimension
def
__init__
(
self
,
dimension
=
1
):
def
__init__
(
self
,
dimension
=
1
):
super
(
Concat
,
self
)
.
__init__
()
super
()
.
__init__
()
self
.
d
=
dimension
self
.
d
=
dimension
def
forward
(
self
,
x
):
def
forward
(
self
,
x
):
return
torch
.
cat
(
x
,
self
.
d
)
return
torch
.
cat
(
x
,
self
.
d
)
class
NMS
(
nn
.
Module
):
# Non-Maximum Suppression (NMS) module
conf
=
0.25
# confidence threshold
iou
=
0.45
# IoU threshold
classes
=
None
# (optional list) filter by class
max_det
=
1000
# maximum number of detections per image
def
__init__
(
self
):
super
(
NMS
,
self
)
.
__init__
()
def
forward
(
self
,
x
):
return
non_max_suppression
(
x
[
0
],
self
.
conf
,
iou_thres
=
self
.
iou
,
classes
=
self
.
classes
,
max_det
=
self
.
max_det
)
class
AutoShape
(
nn
.
Module
):
class
AutoShape
(
nn
.
Module
):
# YOLOv5 input-robust model wrapper for passing cv2/np/PIL/torch inputs. Includes preprocessing, inference and NMS
# YOLOv5 input-robust model wrapper for passing cv2/np/PIL/torch inputs. Includes preprocessing, inference and NMS
conf
=
0.25
# NMS confidence threshold
conf
=
0.25
# NMS confidence threshold
...
@@ -225,7 +219,7 @@ class AutoShape(nn.Module):
...
@@ -225,7 +219,7 @@ class AutoShape(nn.Module):
max_det
=
1000
# maximum number of detections per image
max_det
=
1000
# maximum number of detections per image
def
__init__
(
self
,
model
):
def
__init__
(
self
,
model
):
super
(
AutoShape
,
self
)
.
__init__
()
super
()
.
__init__
()
self
.
model
=
model
.
eval
()
self
.
model
=
model
.
eval
()
def
autoshape
(
self
):
def
autoshape
(
self
):
...
@@ -292,7 +286,7 @@ class AutoShape(nn.Module):
...
@@ -292,7 +286,7 @@ class AutoShape(nn.Module):
class
Detections
:
class
Detections
:
# YOLOv5 detections class for inference results
# YOLOv5 detections class for inference results
def
__init__
(
self
,
imgs
,
pred
,
files
,
times
=
None
,
names
=
None
,
shape
=
None
):
def
__init__
(
self
,
imgs
,
pred
,
files
,
times
=
None
,
names
=
None
,
shape
=
None
):
super
(
Detections
,
self
)
.
__init__
()
super
()
.
__init__
()
d
=
pred
[
0
]
.
device
# device
d
=
pred
[
0
]
.
device
# device
gn
=
[
torch
.
tensor
([
*
[
im
.
shape
[
i
]
for
i
in
[
1
,
0
,
1
,
0
]],
1.
,
1.
],
device
=
d
)
for
im
in
imgs
]
# normalizations
gn
=
[
torch
.
tensor
([
*
[
im
.
shape
[
i
]
for
i
in
[
1
,
0
,
1
,
0
]],
1.
,
1.
],
device
=
d
)
for
im
in
imgs
]
# normalizations
self
.
imgs
=
imgs
# list of images as numpy arrays
self
.
imgs
=
imgs
# list of images as numpy arrays
...
@@ -383,7 +377,7 @@ class Detections:
...
@@ -383,7 +377,7 @@ class Detections:
class
Classify
(
nn
.
Module
):
class
Classify
(
nn
.
Module
):
# Classification head, i.e. x(b,c1,20,20) to x(b,c2)
# Classification head, i.e. x(b,c1,20,20) to x(b,c2)
def
__init__
(
self
,
c1
,
c2
,
k
=
1
,
s
=
1
,
p
=
None
,
g
=
1
):
# ch_in, ch_out, kernel, stride, padding, groups
def
__init__
(
self
,
c1
,
c2
,
k
=
1
,
s
=
1
,
p
=
None
,
g
=
1
):
# ch_in, ch_out, kernel, stride, padding, groups
super
(
Classify
,
self
)
.
__init__
()
super
()
.
__init__
()
self
.
aap
=
nn
.
AdaptiveAvgPool2d
(
1
)
# to x(b,c1,1,1)
self
.
aap
=
nn
.
AdaptiveAvgPool2d
(
1
)
# to x(b,c1,1,1)
self
.
conv
=
nn
.
Conv2d
(
c1
,
c2
,
k
,
s
,
autopad
(
k
,
p
),
groups
=
g
)
# to x(b,c2,1,1)
self
.
conv
=
nn
.
Conv2d
(
c1
,
c2
,
k
,
s
,
autopad
(
k
,
p
),
groups
=
g
)
# to x(b,c2,1,1)
self
.
flat
=
nn
.
Flatten
()
self
.
flat
=
nn
.
Flatten
()
...
...
models/experimental.py
浏览文件 @
b1be6850
...
@@ -12,7 +12,7 @@ class CrossConv(nn.Module):
...
@@ -12,7 +12,7 @@ class CrossConv(nn.Module):
# Cross Convolution Downsample
# Cross Convolution Downsample
def
__init__
(
self
,
c1
,
c2
,
k
=
3
,
s
=
1
,
g
=
1
,
e
=
1.0
,
shortcut
=
False
):
def
__init__
(
self
,
c1
,
c2
,
k
=
3
,
s
=
1
,
g
=
1
,
e
=
1.0
,
shortcut
=
False
):
# ch_in, ch_out, kernel, stride, groups, expansion, shortcut
# ch_in, ch_out, kernel, stride, groups, expansion, shortcut
super
(
CrossConv
,
self
)
.
__init__
()
super
()
.
__init__
()
c_
=
int
(
c2
*
e
)
# hidden channels
c_
=
int
(
c2
*
e
)
# hidden channels
self
.
cv1
=
Conv
(
c1
,
c_
,
(
1
,
k
),
(
1
,
s
))
self
.
cv1
=
Conv
(
c1
,
c_
,
(
1
,
k
),
(
1
,
s
))
self
.
cv2
=
Conv
(
c_
,
c2
,
(
k
,
1
),
(
s
,
1
),
g
=
g
)
self
.
cv2
=
Conv
(
c_
,
c2
,
(
k
,
1
),
(
s
,
1
),
g
=
g
)
...
@@ -25,7 +25,7 @@ class CrossConv(nn.Module):
...
@@ -25,7 +25,7 @@ class CrossConv(nn.Module):
class
Sum
(
nn
.
Module
):
class
Sum
(
nn
.
Module
):
# Weighted sum of 2 or more layers https://arxiv.org/abs/1911.09070
# Weighted sum of 2 or more layers https://arxiv.org/abs/1911.09070
def
__init__
(
self
,
n
,
weight
=
False
):
# n: number of inputs
def
__init__
(
self
,
n
,
weight
=
False
):
# n: number of inputs
super
(
Sum
,
self
)
.
__init__
()
super
()
.
__init__
()
self
.
weight
=
weight
# apply weights boolean
self
.
weight
=
weight
# apply weights boolean
self
.
iter
=
range
(
n
-
1
)
# iter object
self
.
iter
=
range
(
n
-
1
)
# iter object
if
weight
:
if
weight
:
...
@@ -46,7 +46,7 @@ class Sum(nn.Module):
...
@@ -46,7 +46,7 @@ class Sum(nn.Module):
class
GhostConv
(
nn
.
Module
):
class
GhostConv
(
nn
.
Module
):
# Ghost Convolution https://github.com/huawei-noah/ghostnet
# Ghost Convolution https://github.com/huawei-noah/ghostnet
def
__init__
(
self
,
c1
,
c2
,
k
=
1
,
s
=
1
,
g
=
1
,
act
=
True
):
# ch_in, ch_out, kernel, stride, groups
def
__init__
(
self
,
c1
,
c2
,
k
=
1
,
s
=
1
,
g
=
1
,
act
=
True
):
# ch_in, ch_out, kernel, stride, groups
super
(
GhostConv
,
self
)
.
__init__
()
super
()
.
__init__
()
c_
=
c2
//
2
# hidden channels
c_
=
c2
//
2
# hidden channels
self
.
cv1
=
Conv
(
c1
,
c_
,
k
,
s
,
None
,
g
,
act
)
self
.
cv1
=
Conv
(
c1
,
c_
,
k
,
s
,
None
,
g
,
act
)
self
.
cv2
=
Conv
(
c_
,
c_
,
5
,
1
,
None
,
c_
,
act
)
self
.
cv2
=
Conv
(
c_
,
c_
,
5
,
1
,
None
,
c_
,
act
)
...
@@ -59,7 +59,7 @@ class GhostConv(nn.Module):
...
@@ -59,7 +59,7 @@ class GhostConv(nn.Module):
class
GhostBottleneck
(
nn
.
Module
):
class
GhostBottleneck
(
nn
.
Module
):
# Ghost Bottleneck https://github.com/huawei-noah/ghostnet
# Ghost Bottleneck https://github.com/huawei-noah/ghostnet
def
__init__
(
self
,
c1
,
c2
,
k
=
3
,
s
=
1
):
# ch_in, ch_out, kernel, stride
def
__init__
(
self
,
c1
,
c2
,
k
=
3
,
s
=
1
):
# ch_in, ch_out, kernel, stride
super
(
GhostBottleneck
,
self
)
.
__init__
()
super
()
.
__init__
()
c_
=
c2
//
2
c_
=
c2
//
2
self
.
conv
=
nn
.
Sequential
(
GhostConv
(
c1
,
c_
,
1
,
1
),
# pw
self
.
conv
=
nn
.
Sequential
(
GhostConv
(
c1
,
c_
,
1
,
1
),
# pw
DWConv
(
c_
,
c_
,
k
,
s
,
act
=
False
)
if
s
==
2
else
nn
.
Identity
(),
# dw
DWConv
(
c_
,
c_
,
k
,
s
,
act
=
False
)
if
s
==
2
else
nn
.
Identity
(),
# dw
...
@@ -74,7 +74,7 @@ class GhostBottleneck(nn.Module):
...
@@ -74,7 +74,7 @@ class GhostBottleneck(nn.Module):
class
MixConv2d
(
nn
.
Module
):
class
MixConv2d
(
nn
.
Module
):
# Mixed Depthwise Conv https://arxiv.org/abs/1907.09595
# Mixed Depthwise Conv https://arxiv.org/abs/1907.09595
def
__init__
(
self
,
c1
,
c2
,
k
=
(
1
,
3
),
s
=
1
,
equal_ch
=
True
):
def
__init__
(
self
,
c1
,
c2
,
k
=
(
1
,
3
),
s
=
1
,
equal_ch
=
True
):
super
(
MixConv2d
,
self
)
.
__init__
()
super
()
.
__init__
()
groups
=
len
(
k
)
groups
=
len
(
k
)
if
equal_ch
:
# equal c_ per group
if
equal_ch
:
# equal c_ per group
i
=
torch
.
linspace
(
0
,
groups
-
1E-6
,
c2
)
.
floor
()
# c2 indices
i
=
torch
.
linspace
(
0
,
groups
-
1E-6
,
c2
)
.
floor
()
# c2 indices
...
@@ -98,7 +98,7 @@ class MixConv2d(nn.Module):
...
@@ -98,7 +98,7 @@ class MixConv2d(nn.Module):
class
Ensemble
(
nn
.
ModuleList
):
class
Ensemble
(
nn
.
ModuleList
):
# Ensemble of models
# Ensemble of models
def
__init__
(
self
):
def
__init__
(
self
):
super
(
Ensemble
,
self
)
.
__init__
()
super
()
.
__init__
()
def
forward
(
self
,
x
,
augment
=
False
,
profile
=
False
,
visualize
=
False
):
def
forward
(
self
,
x
,
augment
=
False
,
profile
=
False
,
visualize
=
False
):
y
=
[]
y
=
[]
...
...
models/yolo.py
浏览文件 @
b1be6850
...
@@ -33,7 +33,7 @@ class Detect(nn.Module):
...
@@ -33,7 +33,7 @@ class Detect(nn.Module):
onnx_dynamic
=
False
# ONNX export parameter
onnx_dynamic
=
False
# ONNX export parameter
def
__init__
(
self
,
nc
=
80
,
anchors
=
(),
ch
=
(),
inplace
=
True
):
# detection layer
def
__init__
(
self
,
nc
=
80
,
anchors
=
(),
ch
=
(),
inplace
=
True
):
# detection layer
super
(
Detect
,
self
)
.
__init__
()
super
()
.
__init__
()
self
.
nc
=
nc
# number of classes
self
.
nc
=
nc
# number of classes
self
.
no
=
nc
+
5
# number of outputs per anchor
self
.
no
=
nc
+
5
# number of outputs per anchor
self
.
nl
=
len
(
anchors
)
# number of detection layers
self
.
nl
=
len
(
anchors
)
# number of detection layers
...
@@ -77,7 +77,7 @@ class Detect(nn.Module):
...
@@ -77,7 +77,7 @@ class Detect(nn.Module):
class
Model
(
nn
.
Module
):
class
Model
(
nn
.
Module
):
def
__init__
(
self
,
cfg
=
'yolov5s.yaml'
,
ch
=
3
,
nc
=
None
,
anchors
=
None
):
# model, input channels, number of classes
def
__init__
(
self
,
cfg
=
'yolov5s.yaml'
,
ch
=
3
,
nc
=
None
,
anchors
=
None
):
# model, input channels, number of classes
super
(
Model
,
self
)
.
__init__
()
super
()
.
__init__
()
if
isinstance
(
cfg
,
dict
):
if
isinstance
(
cfg
,
dict
):
self
.
yaml
=
cfg
# model dict
self
.
yaml
=
cfg
# model dict
else
:
# is *.yaml
else
:
# is *.yaml
...
@@ -209,20 +209,6 @@ class Model(nn.Module):
...
@@ -209,20 +209,6 @@ class Model(nn.Module):
self
.
info
()
self
.
info
()
return
self
return
self
def
nms
(
self
,
mode
=
True
):
# add or remove NMS module
present
=
type
(
self
.
model
[
-
1
])
is
NMS
# last layer is NMS
if
mode
and
not
present
:
LOGGER
.
info
(
'Adding NMS... '
)
m
=
NMS
()
# module
m
.
f
=
-
1
# from
m
.
i
=
self
.
model
[
-
1
]
.
i
+
1
# index
self
.
model
.
add_module
(
name
=
'
%
s'
%
m
.
i
,
module
=
m
)
# add
self
.
eval
()
elif
not
mode
and
present
:
LOGGER
.
info
(
'Removing NMS... '
)
self
.
model
=
self
.
model
[:
-
1
]
# remove
return
self
def
autoshape
(
self
):
# add AutoShape module
def
autoshape
(
self
):
# add AutoShape module
LOGGER
.
info
(
'Adding AutoShape... '
)
LOGGER
.
info
(
'Adding AutoShape... '
)
m
=
AutoShape
(
self
)
# wrap model
m
=
AutoShape
(
self
)
# wrap model
...
@@ -250,7 +236,7 @@ def parse_model(d, ch): # model_dict, input_channels(3)
...
@@ -250,7 +236,7 @@ def parse_model(d, ch): # model_dict, input_channels(3)
n
=
max
(
round
(
n
*
gd
),
1
)
if
n
>
1
else
n
# depth gain
n
=
max
(
round
(
n
*
gd
),
1
)
if
n
>
1
else
n
# depth gain
if
m
in
[
Conv
,
GhostConv
,
Bottleneck
,
GhostBottleneck
,
SPP
,
DWConv
,
MixConv2d
,
Focus
,
CrossConv
,
BottleneckCSP
,
if
m
in
[
Conv
,
GhostConv
,
Bottleneck
,
GhostBottleneck
,
SPP
,
DWConv
,
MixConv2d
,
Focus
,
CrossConv
,
BottleneckCSP
,
C3
,
C3TR
]:
C3
,
C3TR
,
C3SPP
]:
c1
,
c2
=
ch
[
f
],
args
[
0
]
c1
,
c2
=
ch
[
f
],
args
[
0
]
if
c2
!=
no
:
# if not output
if
c2
!=
no
:
# if not output
c2
=
make_divisible
(
c2
*
gw
,
8
)
c2
=
make_divisible
(
c2
*
gw
,
8
)
...
...
编写
预览
Markdown
格式
0%
重试
或
添加新文件
添加附件
取消
您添加了
0
人
到此讨论。请谨慎行事。
请先完成此评论的编辑!
取消
请
注册
或者
登录
后发表评论