Skip to content
项目
群组
代码片段
帮助
当前项目
正在载入...
登录 / 注册
切换导航面板
Y
yolov5
项目
项目
详情
活动
周期分析
仓库
仓库
文件
提交
分支
标签
贡献者
图表
比较
统计图
议题
0
议题
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
CI / CD
CI / CD
流水线
作业
日程
统计图
Wiki
Wiki
代码片段
代码片段
成员
成员
折叠边栏
关闭边栏
活动
图像
聊天
创建新问题
作业
提交
问题看板
Open sidebar
Administrator
yolov5
Commits
fab50856
Unverified
提交
fab50856
authored
3月 02, 2021
作者:
Glenn Jocher
提交者:
GitHub
3月 02, 2021
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
EMA bug fix 2 (#2330)
* EMA bug fix 2 * update
上级
fd968105
隐藏空白字符变更
内嵌
并排
正在显示
4 个修改的文件
包含
13 行增加
和
10 行删除
+13
-10
hubconf.py
hubconf.py
+1
-1
experimental.py
models/experimental.py
+2
-1
train.py
train.py
+5
-5
general.py
utils/general.py
+5
-3
没有找到文件。
hubconf.py
浏览文件 @
fab50856
...
@@ -120,7 +120,7 @@ def custom(path_or_model='path/to/model.pt', autoshape=True):
...
@@ -120,7 +120,7 @@ def custom(path_or_model='path/to/model.pt', autoshape=True):
"""
"""
model
=
torch
.
load
(
path_or_model
)
if
isinstance
(
path_or_model
,
str
)
else
path_or_model
# load checkpoint
model
=
torch
.
load
(
path_or_model
)
if
isinstance
(
path_or_model
,
str
)
else
path_or_model
# load checkpoint
if
isinstance
(
model
,
dict
):
if
isinstance
(
model
,
dict
):
model
=
model
[
'model'
]
# load model
model
=
model
[
'
ema'
if
model
.
get
(
'ema'
)
else
'
model'
]
# load model
hub_model
=
Model
(
model
.
yaml
)
.
to
(
next
(
model
.
parameters
())
.
device
)
# create
hub_model
=
Model
(
model
.
yaml
)
.
to
(
next
(
model
.
parameters
())
.
device
)
# create
hub_model
.
load_state_dict
(
model
.
float
()
.
state_dict
())
# load state_dict
hub_model
.
load_state_dict
(
model
.
float
()
.
state_dict
())
# load state_dict
...
...
models/experimental.py
浏览文件 @
fab50856
...
@@ -115,7 +115,8 @@ def attempt_load(weights, map_location=None):
...
@@ -115,7 +115,8 @@ def attempt_load(weights, map_location=None):
model
=
Ensemble
()
model
=
Ensemble
()
for
w
in
weights
if
isinstance
(
weights
,
list
)
else
[
weights
]:
for
w
in
weights
if
isinstance
(
weights
,
list
)
else
[
weights
]:
attempt_download
(
w
)
attempt_download
(
w
)
model
.
append
(
torch
.
load
(
w
,
map_location
=
map_location
)[
'model'
]
.
float
()
.
fuse
()
.
eval
())
# load FP32 model
ckpt
=
torch
.
load
(
w
,
map_location
=
map_location
)
# load
model
.
append
(
ckpt
[
'ema'
if
ckpt
.
get
(
'ema'
)
else
'model'
]
.
float
()
.
fuse
()
.
eval
())
# FP32 model
# Compatibility updates
# Compatibility updates
for
m
in
model
.
modules
():
for
m
in
model
.
modules
():
...
...
train.py
浏览文件 @
fab50856
...
@@ -151,8 +151,8 @@ def train(hyp, opt, device, tb_writer=None, wandb=None):
...
@@ -151,8 +151,8 @@ def train(hyp, opt, device, tb_writer=None, wandb=None):
# EMA
# EMA
if
ema
and
ckpt
.
get
(
'ema'
):
if
ema
and
ckpt
.
get
(
'ema'
):
ema
.
ema
.
load_state_dict
(
ckpt
[
'ema'
]
[
0
]
.
float
()
.
state_dict
())
ema
.
ema
.
load_state_dict
(
ckpt
[
'ema'
]
.
float
()
.
state_dict
())
ema
.
updates
=
ckpt
[
'
ema'
][
1
]
ema
.
updates
=
ckpt
[
'
updates'
]
# Results
# Results
if
ckpt
.
get
(
'training_results'
)
is
not
None
:
if
ckpt
.
get
(
'training_results'
)
is
not
None
:
...
@@ -383,9 +383,9 @@ def train(hyp, opt, device, tb_writer=None, wandb=None):
...
@@ -383,9 +383,9 @@ def train(hyp, opt, device, tb_writer=None, wandb=None):
ckpt
=
{
'epoch'
:
epoch
,
ckpt
=
{
'epoch'
:
epoch
,
'best_fitness'
:
best_fitness
,
'best_fitness'
:
best_fitness
,
'training_results'
:
results_file
.
read_text
(),
'training_results'
:
results_file
.
read_text
(),
'model'
:
ema
.
ema
if
final_epoch
else
deepcopy
(
'model'
:
deepcopy
(
model
.
module
if
is_parallel
(
model
)
else
model
)
.
half
(),
model
.
module
if
is_parallel
(
model
)
else
model
)
.
half
(),
'ema'
:
deepcopy
(
ema
.
ema
)
.
half
(),
'
ema'
:
(
deepcopy
(
ema
.
ema
)
.
half
(),
ema
.
updates
)
,
'
updates'
:
ema
.
updates
,
'optimizer'
:
optimizer
.
state_dict
(),
'optimizer'
:
optimizer
.
state_dict
(),
'wandb_id'
:
wandb_run
.
id
if
wandb
else
None
}
'wandb_id'
:
wandb_run
.
id
if
wandb
else
None
}
...
...
utils/general.py
浏览文件 @
fab50856
...
@@ -481,10 +481,12 @@ def non_max_suppression(prediction, conf_thres=0.25, iou_thres=0.45, classes=Non
...
@@ -481,10 +481,12 @@ def non_max_suppression(prediction, conf_thres=0.25, iou_thres=0.45, classes=Non
return
output
return
output
def
strip_optimizer
(
f
=
'
weights/
best.pt'
,
s
=
''
):
# from utils.general import *; strip_optimizer()
def
strip_optimizer
(
f
=
'best.pt'
,
s
=
''
):
# from utils.general import *; strip_optimizer()
# Strip optimizer from 'f' to finalize training, optionally save as 's'
# Strip optimizer from 'f' to finalize training, optionally save as 's'
x
=
torch
.
load
(
f
,
map_location
=
torch
.
device
(
'cpu'
))
x
=
torch
.
load
(
f
,
map_location
=
torch
.
device
(
'cpu'
))
for
k
in
'optimizer'
,
'training_results'
,
'wandb_id'
,
'ema'
:
# keys
if
x
.
get
(
'ema'
):
x
[
'model'
]
=
x
[
'ema'
]
# replace model with ema
for
k
in
'optimizer'
,
'training_results'
,
'wandb_id'
,
'ema'
,
'updates'
:
# keys
x
[
k
]
=
None
x
[
k
]
=
None
x
[
'epoch'
]
=
-
1
x
[
'epoch'
]
=
-
1
x
[
'model'
]
.
half
()
# to FP16
x
[
'model'
]
.
half
()
# to FP16
...
@@ -492,7 +494,7 @@ def strip_optimizer(f='weights/best.pt', s=''): # from utils.general import *;
...
@@ -492,7 +494,7 @@ def strip_optimizer(f='weights/best.pt', s=''): # from utils.general import *;
p
.
requires_grad
=
False
p
.
requires_grad
=
False
torch
.
save
(
x
,
s
or
f
)
torch
.
save
(
x
,
s
or
f
)
mb
=
os
.
path
.
getsize
(
s
or
f
)
/
1E6
# filesize
mb
=
os
.
path
.
getsize
(
s
or
f
)
/
1E6
# filesize
print
(
'Optimizer stripped from
%
s,
%
s
%.1
fMB'
%
(
f
,
(
' saved as
%
s,'
%
s
)
if
s
else
''
,
mb
)
)
print
(
f
"Optimizer stripped from {f},{(' saved as
%
s,'
%
s) if s else ''} {mb:.1f}MB"
)
def
print_mutation
(
hyp
,
results
,
yaml_file
=
'hyp_evolved.yaml'
,
bucket
=
''
):
def
print_mutation
(
hyp
,
results
,
yaml_file
=
'hyp_evolved.yaml'
,
bucket
=
''
):
...
...
编写
预览
Markdown
格式
0%
重试
或
添加新文件
添加附件
取消
您添加了
0
人
到此讨论。请谨慎行事。
请先完成此评论的编辑!
取消
请
注册
或者
登录
后发表评论