Skip to content
项目
群组
代码片段
帮助
当前项目
正在载入...
登录 / 注册
切换导航面板
Y
yolov5
项目
项目
详情
活动
周期分析
仓库
仓库
文件
提交
分支
标签
贡献者
图表
比较
统计图
议题
0
议题
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
CI / CD
CI / CD
流水线
作业
日程
统计图
Wiki
Wiki
代码片段
代码片段
成员
成员
折叠边栏
关闭边栏
活动
图像
聊天
创建新问题
作业
提交
问题看板
Open sidebar
Administrator
yolov5
Commits
24c5a941
提交
24c5a941
authored
7月 09, 2020
作者:
Glenn Jocher
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
--resume EMA fix #292
上级
2b6209a9
隐藏空白字符变更
内嵌
并排
正在显示
2 个修改的文件
包含
5 行增加
和
9 行删除
+5
-9
train.py
train.py
+2
-2
torch_utils.py
utils/torch_utils.py
+3
-7
没有找到文件。
train.py
浏览文件 @
24c5a941
...
@@ -163,6 +163,7 @@ def train(hyp):
...
@@ -163,6 +163,7 @@ def train(hyp):
dataloader
,
dataset
=
create_dataloader
(
train_path
,
imgsz
,
batch_size
,
gs
,
opt
,
dataloader
,
dataset
=
create_dataloader
(
train_path
,
imgsz
,
batch_size
,
gs
,
opt
,
hyp
=
hyp
,
augment
=
True
,
cache
=
opt
.
cache_images
,
rect
=
opt
.
rect
)
hyp
=
hyp
,
augment
=
True
,
cache
=
opt
.
cache_images
,
rect
=
opt
.
rect
)
mlc
=
np
.
concatenate
(
dataset
.
labels
,
0
)[:,
0
]
.
max
()
# max label class
mlc
=
np
.
concatenate
(
dataset
.
labels
,
0
)[:,
0
]
.
max
()
# max label class
nb
=
len
(
dataloader
)
# number of batches
assert
mlc
<
nc
,
'Label class
%
g exceeds nc=
%
g in
%
s. Correct your labels or your model.'
%
(
mlc
,
nc
,
opt
.
cfg
)
assert
mlc
<
nc
,
'Label class
%
g exceeds nc=
%
g in
%
s. Correct your labels or your model.'
%
(
mlc
,
nc
,
opt
.
cfg
)
# Testloader
# Testloader
...
@@ -191,11 +192,10 @@ def train(hyp):
...
@@ -191,11 +192,10 @@ def train(hyp):
check_anchors
(
dataset
,
model
=
model
,
thr
=
hyp
[
'anchor_t'
],
imgsz
=
imgsz
)
check_anchors
(
dataset
,
model
=
model
,
thr
=
hyp
[
'anchor_t'
],
imgsz
=
imgsz
)
# Exponential moving average
# Exponential moving average
ema
=
torch_utils
.
ModelEMA
(
model
)
ema
=
torch_utils
.
ModelEMA
(
model
,
updates
=
start_epoch
*
nb
/
accumulate
)
# Start training
# Start training
t0
=
time
.
time
()
t0
=
time
.
time
()
nb
=
len
(
dataloader
)
# number of batches
nw
=
max
(
3
*
nb
,
1e3
)
# number of warmup iterations, max(3 epochs, 1k iterations)
nw
=
max
(
3
*
nb
,
1e3
)
# number of warmup iterations, max(3 epochs, 1k iterations)
maps
=
np
.
zeros
(
nc
)
# mAP per class
maps
=
np
.
zeros
(
nc
)
# mAP per class
results
=
(
0
,
0
,
0
,
0
,
0
,
0
,
0
)
# 'P', 'R', 'mAP', 'F1', 'val GIoU', 'val Objectness', 'val Classification'
results
=
(
0
,
0
,
0
,
0
,
0
,
0
,
0
)
# 'P', 'R', 'mAP', 'F1', 'val GIoU', 'val Objectness', 'val Classification'
...
...
utils/torch_utils.py
浏览文件 @
24c5a941
...
@@ -191,15 +191,11 @@ class ModelEMA:
...
@@ -191,15 +191,11 @@ class ModelEMA:
I've tested with the sequence in my own train.py for torch.DataParallel, apex.DDP, and single-GPU.
I've tested with the sequence in my own train.py for torch.DataParallel, apex.DDP, and single-GPU.
"""
"""
def
__init__
(
self
,
model
,
decay
=
0.9999
,
device
=
''
):
def
__init__
(
self
,
model
,
decay
=
0.9999
,
updates
=
0
):
# Create EMA
# Create EMA
self
.
ema
=
deepcopy
(
model
.
module
if
is_parallel
(
model
)
else
model
)
# FP32 EMA
self
.
ema
=
deepcopy
(
model
.
module
if
is_parallel
(
model
)
else
model
)
.
eval
()
# FP32 EMA
self
.
ema
.
eval
()
self
.
updates
=
updates
# number of EMA updates
self
.
updates
=
0
# number of EMA updates
self
.
decay
=
lambda
x
:
decay
*
(
1
-
math
.
exp
(
-
x
/
2000
))
# decay exponential ramp (to help early epochs)
self
.
decay
=
lambda
x
:
decay
*
(
1
-
math
.
exp
(
-
x
/
2000
))
# decay exponential ramp (to help early epochs)
self
.
device
=
device
# perform ema on different device from model if set
if
device
:
self
.
ema
.
to
(
device
)
for
p
in
self
.
ema
.
parameters
():
for
p
in
self
.
ema
.
parameters
():
p
.
requires_grad_
(
False
)
p
.
requires_grad_
(
False
)
...
...
编写
预览
Markdown
格式
0%
重试
或
添加新文件
添加附件
取消
您添加了
0
人
到此讨论。请谨慎行事。
请先完成此评论的编辑!
取消
请
注册
或者
登录
后发表评论